documentation.d.ts 3.8 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674876758767687677876788767987680876818768287683876848768587686876878768887689876908769187692876938769487695876968769787698876998770087701877028770387704877058770687707877088770987710877118771287713877148771587716877178771887719877208772187722877238772487725877268772787728877298773087731877328773387734877358773687737877388773987740877418774287743877448774587746877478774887749877508775187752877538775487755877568775787758877598776087761877628776387764877658776687767877688776987770877718777287773877748777587776877778777887779877808778187782877838778487785877868778787788877898779087791877928779387794877958779687797877988779987800878018780287803878048780587806878078780887809878108781187812878138781487815878168781787818878198782087821878228782387824878258782687827878288782987830878318783287833878348783587836878378783887839878408784187842878438784487845878468784787848878498785087851878528785387854878558785687857878588785987860878618786287863878648786587866878678786887869878708787187872878738787487875878768787787878878798788087881878828788387884878858788687887878888788987890878918789287893878948789587896878978789887899879008790187902879038790487905879068790787908879098791087911879128791387914879158791687917879188791987920879218792287923879248792587926879278792887929879308793187932879338793487935879368793787938879398794087941879428794387944879458794687947879488794987950879518795287953879548795587956879578795887959879608796187962879638796487965879668796787968879698797087971879728797387974879758797687977879788797987980879818798287983879848798587986879878798887989879908799187992879938799487995879968799787998879998800088001880028800388004880058800688007880088800988010880118801288013880148801588016880178801888019880208802188022880238802488025880268802788028880298803088031880328803388034880358803688037880388803988040880418804288043880448804588046880478804888049880508805188052880538805488055880568805788058880598806088061880628806388064880658806688067880688806988070880718807288073880748807588076880778807888079880808808188082880838808488085880868808788088880898809088091880928809388094880958809688097880988809988100881018810288103881048810588106881078810888109881108811188112881138811488115881168811788118881198812088121881228812388124881258812688127881288812988130881318813288133881348813588136881378813888139881408814188142881438814488145881468814788148881498815088151881528815388154881558815688157881588815988160881618816288163881648816588166881678816888169881708817188172881738817488175881768817788178881798818088181881828818388184881858818688187881888818988190881918819288193881948819588196881978819888199882008820188202882038820488205882068820788208882098821088211882128821388214882158821688217882188821988220882218822288223882248822588226882278822888229882308823188232882338823488235882368823788238882398824088241882428824388244882458824688247882488824988250882518825288253882548825588256882578825888259882608826188262882638826488265882668826788268882698827088271882728827388274882758827688277882788827988280882818828288283882848828588286882878828888289882908829188292882938829488295882968829788298882998830088301883028830388304883058830688307883088830988310883118831288313883148831588316883178831888319883208832188322883238832488325883268832788328883298833088331883328833388334883358833688337883388833988340883418834288343883448834588346883478834888349883508835188352883538835488355883568835788358883598836088361883628836388364883658836688367883688836988370883718837288373883748837588376883778837888379883808838188382883838838488385883868838788388883898839088391883928839388394883958839688397883988839988400884018840288403884048840588406884078840888409884108841188412884138841488415884168841788418884198842088421884228842388424884258842688427884288842988430884318843288433884348843588436884378843888439884408844188442884438844488445884468844788448884498845088451884528845388454884558845688457884588845988460884618846288463884648846588466884678846888469884708847188472884738847488475884768847788478884798848088481884828848388484884858848688487884888848988490884918849288493884948849588496884978849888499885008850188502885038850488505885068850788508885098851088511885128851388514885158851688517885188851988520885218852288523885248852588526885278852888529885308853188532885338853488535885368853788538885398854088541885428854388544885458854688547885488854988550885518855288553885548855588556885578855888559885608856188562885638856488565885668856788568885698857088571885728857388574885758857688577885788857988580885818858288583885848858588586885878858888589885908859188592885938859488595885968859788598885998860088601886028860388604886058860688607886088860988610886118861288613886148861588616886178861888619886208862188622886238862488625886268862788628886298863088631886328863388634886358863688637886388863988640886418864288643886448864588646886478864888649886508865188652886538865488655886568865788658886598866088661886628866388664886658866688667886688866988670886718867288673886748867588676886778867888679886808868188682886838868488685886868868788688886898869088691886928869388694886958869688697886988869988700887018870288703887048870588706887078870888709887108871188712887138871488715887168871788718887198872088721887228872388724887258872688727887288872988730887318873288733887348873588736887378873888739887408874188742887438874488745887468874788748887498875088751887528875388754887558875688757887588875988760887618876288763887648876588766887678876888769887708877188772887738877488775887768877788778887798878088781887828878388784887858878688787887888878988790887918879288793887948879588796887978879888799888008880188802888038880488805888068880788808888098881088811888128881388814888158881688817888188881988820888218882288823888248882588826888278882888829888308883188832888338883488835888368883788838888398884088841888428884388844888458884688847888488884988850888518885288853888548885588856888578885888859888608886188862888638886488865888668886788868888698887088871888728887388874888758887688877888788887988880888818888288883888848888588886888878888888889888908889188892888938889488895888968889788898888998890088901889028890388904889058890688907889088890988910889118891288913889148891588916889178891888919889208892188922889238892488925889268892788928889298893088931889328893388934889358893688937889388893988940889418894288943889448894588946889478894888949889508895188952889538895488955889568895788958889598896088961889628896388964889658896688967889688896988970889718897288973889748897588976889778897888979889808898188982889838898488985889868898788988889898899088991889928899388994889958899688997889988899989000890018900289003890048900589006890078900889009890108901189012890138901489015890168901789018890198902089021890228902389024890258902689027890288902989030890318903289033890348903589036890378903889039890408904189042890438904489045890468904789048890498905089051890528905389054890558905689057890588905989060890618906289063890648906589066890678906889069890708907189072890738907489075890768907789078890798908089081890828908389084890858908689087890888908989090890918909289093890948909589096890978909889099891008910189102891038910489105891068910789108891098911089111891128911389114891158911689117891188911989120891218912289123891248912589126891278912889129891308913189132891338913489135891368913789138891398914089141891428914389144891458914689147891488914989150891518915289153891548915589156891578915889159891608916189162891638916489165891668916789168891698917089171891728917389174891758917689177891788917989180891818918289183891848918589186891878918889189891908919189192891938919489195891968919789198891998920089201892028920389204892058920689207892088920989210892118921289213892148921589216892178921889219892208922189222892238922489225892268922789228892298923089231892328923389234892358923689237892388923989240892418924289243892448924589246892478924889249892508925189252892538925489255892568925789258892598926089261892628926389264892658926689267892688926989270892718927289273892748927589276892778927889279892808928189282892838928489285892868928789288892898929089291892928929389294892958929689297892988929989300893018930289303893048930589306893078930889309893108931189312893138931489315893168931789318893198932089321893228932389324893258932689327893288932989330893318933289333893348933589336893378933889339893408934189342893438934489345893468934789348893498935089351893528935389354893558935689357893588935989360893618936289363893648936589366893678936889369893708937189372893738937489375893768937789378893798938089381893828938389384893858938689387893888938989390893918939289393893948939589396893978939889399894008940189402894038940489405894068940789408894098941089411894128941389414894158941689417894188941989420894218942289423894248942589426894278942889429894308943189432894338943489435894368943789438894398944089441894428944389444894458944689447894488944989450894518945289453894548945589456894578945889459894608946189462894638946489465894668946789468894698947089471894728947389474894758947689477894788947989480894818948289483894848948589486894878948889489894908949189492894938949489495894968949789498894998950089501895028950389504895058950689507895088950989510895118951289513895148951589516895178951889519895208952189522895238952489525895268952789528895298953089531895328953389534895358953689537895388953989540895418954289543895448954589546895478954889549895508955189552895538955489555895568955789558895598956089561895628956389564895658956689567895688956989570895718957289573895748957589576895778957889579895808958189582895838958489585895868958789588895898959089591895928959389594895958959689597895988959989600896018960289603896048960589606896078960889609896108961189612896138961489615896168961789618896198962089621896228962389624896258962689627896288962989630896318963289633896348963589636896378963889639896408964189642896438964489645896468964789648896498965089651896528965389654896558965689657896588965989660896618966289663896648966589666896678966889669896708967189672896738967489675896768967789678896798968089681896828968389684896858968689687896888968989690896918969289693896948969589696896978969889699897008970189702897038970489705897068970789708897098971089711897128971389714897158971689717897188971989720897218972289723897248972589726897278972889729897308973189732897338973489735897368973789738897398974089741897428974389744897458974689747897488974989750897518975289753897548975589756897578975889759897608976189762897638976489765897668976789768897698977089771897728977389774897758977689777897788977989780897818978289783897848978589786897878978889789897908979189792897938979489795897968979789798897998980089801898028980389804898058980689807898088980989810898118981289813898148981589816898178981889819898208982189822898238982489825898268982789828898298983089831898328983389834898358983689837898388983989840898418984289843898448984589846898478984889849898508985189852898538985489855898568985789858898598986089861898628986389864898658986689867898688986989870898718987289873898748987589876898778987889879898808988189882898838988489885898868988789888898898989089891898928989389894898958989689897898988989989900899018990289903899048990589906899078990889909899108991189912899138991489915899168991789918899198992089921899228992389924899258992689927899288992989930899318993289933899348993589936899378993889939899408994189942899438994489945899468994789948899498995089951899528995389954899558995689957899588995989960899618996289963899648996589966899678996889969899708997189972899738997489975899768997789978899798998089981899828998389984899858998689987899888998989990899918999289993899948999589996899978999889999900009000190002900039000490005900069000790008900099001090011900129001390014900159001690017900189001990020900219002290023900249002590026900279002890029900309003190032900339003490035900369003790038900399004090041900429004390044900459004690047900489004990050900519005290053900549005590056900579005890059900609006190062900639006490065900669006790068900699007090071900729007390074900759007690077900789007990080900819008290083900849008590086900879008890089900909009190092900939009490095900969009790098900999010090101901029010390104901059010690107901089010990110901119011290113901149011590116901179011890119901209012190122901239012490125901269012790128901299013090131901329013390134901359013690137901389013990140901419014290143901449014590146901479014890149901509015190152901539015490155901569015790158901599016090161901629016390164901659016690167901689016990170901719017290173901749017590176901779017890179901809018190182901839018490185901869018790188901899019090191901929019390194901959019690197901989019990200902019020290203902049020590206902079020890209902109021190212902139021490215902169021790218902199022090221902229022390224902259022690227902289022990230902319023290233902349023590236902379023890239902409024190242902439024490245902469024790248902499025090251902529025390254902559025690257902589025990260902619026290263902649026590266902679026890269902709027190272902739027490275902769027790278902799028090281902829028390284902859028690287902889028990290902919029290293902949029590296902979029890299903009030190302903039030490305903069030790308903099031090311903129031390314903159031690317903189031990320903219032290323903249032590326903279032890329903309033190332903339033490335903369033790338903399034090341903429034390344903459034690347903489034990350903519035290353903549035590356903579035890359903609036190362903639036490365903669036790368903699037090371903729037390374903759037690377903789037990380903819038290383903849038590386903879038890389903909039190392903939039490395903969039790398903999040090401904029040390404904059040690407904089040990410904119041290413904149041590416904179041890419904209042190422904239042490425904269042790428904299043090431904329043390434904359043690437904389043990440904419044290443904449044590446904479044890449904509045190452904539045490455904569045790458904599046090461904629046390464904659046690467904689046990470904719047290473904749047590476904779047890479904809048190482904839048490485904869048790488904899049090491904929049390494904959049690497904989049990500905019050290503905049050590506905079050890509905109051190512905139051490515905169051790518905199052090521905229052390524905259052690527905289052990530905319053290533905349053590536905379053890539905409054190542905439054490545905469054790548905499055090551905529055390554905559055690557905589055990560905619056290563905649056590566905679056890569905709057190572905739057490575905769057790578905799058090581905829058390584905859058690587905889058990590905919059290593905949059590596905979059890599906009060190602906039060490605906069060790608906099061090611906129061390614906159061690617906189061990620906219062290623906249062590626906279062890629906309063190632906339063490635906369063790638906399064090641906429064390644906459064690647906489064990650906519065290653906549065590656906579065890659906609066190662906639066490665906669066790668906699067090671906729067390674906759067690677906789067990680906819068290683906849068590686906879068890689906909069190692906939069490695906969069790698906999070090701907029070390704907059070690707907089070990710907119071290713907149071590716907179071890719907209072190722907239072490725907269072790728907299073090731907329073390734907359073690737907389073990740907419074290743907449074590746907479074890749907509075190752907539075490755907569075790758907599076090761907629076390764907659076690767907689076990770907719077290773907749077590776907779077890779907809078190782907839078490785907869078790788907899079090791907929079390794907959079690797907989079990800908019080290803908049080590806908079080890809908109081190812908139081490815908169081790818908199082090821908229082390824908259082690827908289082990830908319083290833908349083590836908379083890839908409084190842908439084490845908469084790848908499085090851908529085390854908559085690857908589085990860908619086290863908649086590866908679086890869908709087190872908739087490875908769087790878908799088090881908829088390884908859088690887908889088990890908919089290893908949089590896908979089890899909009090190902909039090490905909069090790908909099091090911909129091390914909159091690917909189091990920909219092290923909249092590926909279092890929909309093190932909339093490935909369093790938909399094090941909429094390944909459094690947909489094990950909519095290953909549095590956909579095890959909609096190962909639096490965909669096790968909699097090971909729097390974909759097690977909789097990980909819098290983909849098590986909879098890989909909099190992909939099490995909969099790998909999100091001910029100391004910059100691007910089100991010910119101291013910149101591016910179101891019910209102191022910239102491025910269102791028910299103091031910329103391034910359103691037910389103991040910419104291043910449104591046910479104891049910509105191052910539105491055910569105791058910599106091061910629106391064910659106691067910689106991070910719107291073910749107591076910779107891079910809108191082910839108491085910869108791088910899109091091910929109391094910959109691097910989109991100911019110291103911049110591106911079110891109911109111191112911139111491115911169111791118911199112091121911229112391124911259112691127911289112991130911319113291133911349113591136911379113891139911409114191142911439114491145911469114791148911499115091151911529115391154911559115691157911589115991160911619116291163911649116591166911679116891169911709117191172911739117491175911769117791178911799118091181911829118391184911859118691187911889118991190911919119291193911949119591196911979119891199912009120191202912039120491205912069120791208912099121091211912129121391214912159121691217912189121991220912219122291223912249122591226912279122891229912309123191232912339123491235912369123791238912399124091241912429124391244912459124691247912489124991250912519125291253912549125591256912579125891259912609126191262912639126491265912669126791268912699127091271912729127391274912759127691277912789127991280912819128291283912849128591286912879128891289912909129191292912939129491295912969129791298912999130091301913029130391304913059130691307913089130991310913119131291313913149131591316913179131891319913209132191322913239132491325913269132791328913299133091331913329133391334913359133691337913389133991340913419134291343913449134591346913479134891349913509135191352913539135491355913569135791358913599136091361913629136391364913659136691367913689136991370913719137291373913749137591376913779137891379913809138191382913839138491385913869138791388913899139091391913929139391394913959139691397913989139991400914019140291403914049140591406914079140891409914109141191412914139141491415914169141791418914199142091421914229142391424914259142691427914289142991430914319143291433914349143591436914379143891439914409144191442914439144491445914469144791448914499145091451914529145391454914559145691457914589145991460914619146291463914649146591466914679146891469914709147191472914739147491475914769147791478914799148091481914829148391484914859148691487914889148991490914919149291493914949149591496914979149891499915009150191502915039150491505915069150791508915099151091511915129151391514915159151691517915189151991520915219152291523915249152591526915279152891529915309153191532915339153491535915369153791538915399154091541915429154391544915459154691547915489154991550915519155291553915549155591556915579155891559915609156191562915639156491565915669156791568915699157091571915729157391574915759157691577915789157991580915819158291583915849158591586915879158891589915909159191592915939159491595915969159791598915999160091601916029160391604916059160691607916089160991610916119161291613916149161591616916179161891619916209162191622916239162491625916269162791628916299163091631916329163391634916359163691637916389163991640916419164291643916449164591646916479164891649916509165191652916539165491655916569165791658916599166091661916629166391664916659166691667916689166991670916719167291673916749167591676916779167891679916809168191682916839168491685916869168791688916899169091691916929169391694916959169691697916989169991700917019170291703917049170591706917079170891709917109171191712917139171491715917169171791718917199172091721917229172391724917259172691727917289172991730917319173291733917349173591736917379173891739917409174191742917439174491745917469174791748917499175091751917529175391754917559175691757917589175991760917619176291763917649176591766917679176891769917709177191772917739177491775917769177791778917799178091781917829178391784917859178691787917889178991790917919179291793917949179591796917979179891799918009180191802918039180491805918069180791808918099181091811918129181391814918159181691817918189181991820918219182291823918249182591826918279182891829918309183191832918339183491835918369183791838918399184091841918429184391844918459184691847918489184991850918519185291853918549185591856918579185891859918609186191862918639186491865918669186791868918699187091871918729187391874918759187691877918789187991880918819188291883918849188591886918879188891889918909189191892918939189491895918969189791898918999190091901919029190391904919059190691907919089190991910919119191291913919149191591916919179191891919919209192191922919239192491925919269192791928919299193091931919329193391934919359193691937919389193991940919419194291943919449194591946919479194891949919509195191952919539195491955919569195791958919599196091961919629196391964919659196691967919689196991970919719197291973919749197591976919779197891979919809198191982919839198491985919869198791988919899199091991919929199391994919959199691997919989199992000920019200292003920049200592006920079200892009920109201192012920139201492015920169201792018920199202092021920229202392024920259202692027920289202992030920319203292033920349203592036920379203892039920409204192042920439204492045920469204792048920499205092051920529205392054920559205692057920589205992060920619206292063920649206592066920679206892069920709207192072920739207492075920769207792078920799208092081920829208392084920859208692087920889208992090920919209292093920949209592096920979209892099921009210192102921039210492105921069210792108921099211092111921129211392114921159211692117921189211992120921219212292123921249212592126921279212892129921309213192132921339213492135921369213792138921399214092141921429214392144921459214692147921489214992150921519215292153921549215592156921579215892159921609216192162921639216492165921669216792168921699217092171921729217392174921759217692177921789217992180921819218292183921849218592186921879218892189921909219192192921939219492195921969219792198921999220092201922029220392204922059220692207922089220992210922119221292213922149221592216922179221892219922209222192222922239222492225922269222792228922299223092231922329223392234922359223692237922389223992240922419224292243922449224592246922479224892249922509225192252922539225492255922569225792258922599226092261922629226392264922659226692267922689226992270922719227292273922749227592276922779227892279922809228192282922839228492285922869228792288922899229092291922929229392294922959229692297922989229992300923019230292303923049230592306923079230892309923109231192312923139231492315923169231792318923199232092321923229232392324923259232692327923289232992330923319233292333923349233592336923379233892339923409234192342923439234492345923469234792348923499235092351923529235392354923559235692357923589235992360923619236292363923649236592366923679236892369923709237192372923739237492375923769237792378923799238092381923829238392384923859238692387923889238992390923919239292393923949239592396923979239892399924009240192402924039240492405924069240792408924099241092411924129241392414924159241692417924189241992420924219242292423924249242592426924279242892429924309243192432924339243492435924369243792438924399244092441924429244392444924459244692447924489244992450924519245292453924549245592456924579245892459924609246192462924639246492465924669246792468924699247092471924729247392474924759247692477924789247992480924819248292483924849248592486924879248892489924909249192492924939249492495924969249792498924999250092501925029250392504925059250692507925089250992510925119251292513925149251592516925179251892519925209252192522925239252492525925269252792528925299253092531925329253392534925359253692537925389253992540925419254292543925449254592546925479254892549925509255192552925539255492555925569255792558925599256092561925629256392564925659256692567925689256992570925719257292573925749257592576925779257892579925809258192582925839258492585925869258792588925899259092591925929259392594925959259692597925989259992600926019260292603926049260592606926079260892609926109261192612926139261492615926169261792618926199262092621926229262392624926259262692627926289262992630926319263292633926349263592636926379263892639926409264192642926439264492645926469264792648926499265092651926529265392654926559265692657926589265992660926619266292663926649266592666926679266892669926709267192672926739267492675926769267792678926799268092681926829268392684926859268692687926889268992690926919269292693926949269592696926979269892699927009270192702927039270492705927069270792708927099271092711927129271392714927159271692717927189271992720927219272292723927249272592726927279272892729927309273192732927339273492735927369273792738927399274092741927429274392744927459274692747927489274992750927519275292753927549275592756927579275892759927609276192762927639276492765927669276792768927699277092771927729277392774927759277692777927789277992780927819278292783927849278592786927879278892789927909279192792927939279492795927969279792798927999280092801928029280392804928059280692807928089280992810928119281292813928149281592816928179281892819928209282192822928239282492825928269282792828928299283092831928329283392834928359283692837928389283992840928419284292843928449284592846928479284892849928509285192852928539285492855928569285792858928599286092861928629286392864
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. /**
  94. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  166. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. /**
  333. * Message to display when a message has been logged too many times
  334. */
  335. static MessageLimitReached: string;
  336. private static _LogCache;
  337. private static _LogLimitOutputs;
  338. /**
  339. * Gets a value indicating the number of loading errors
  340. * @ignorenaming
  341. */
  342. static errorsCount: number;
  343. /**
  344. * Callback called when a new log is added
  345. */
  346. static OnNewCacheEntry: (entry: string) => void;
  347. private static _CheckLimit;
  348. private static _GenerateLimitMessage;
  349. private static _AddLogEntry;
  350. private static _FormatMessage;
  351. private static _LogDisabled;
  352. private static _LogEnabled;
  353. private static _WarnDisabled;
  354. private static _WarnEnabled;
  355. private static _ErrorDisabled;
  356. private static _ErrorEnabled;
  357. /**
  358. * Log a message to the console
  359. */
  360. static Log: (message: string, limit?: number) => void;
  361. /**
  362. * Write a warning message to the console
  363. */
  364. static Warn: (message: string, limit?: number) => void;
  365. /**
  366. * Write an error message to the console
  367. */
  368. static Error: (message: string, limit?: number) => void;
  369. /**
  370. * Gets current log cache (list of logs)
  371. */
  372. static get LogCache(): string;
  373. /**
  374. * Clears the log cache
  375. */
  376. static ClearLogCache(): void;
  377. /**
  378. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  379. */
  380. static set LogLevels(level: number);
  381. }
  382. }
  383. declare module BABYLON {
  384. /** @hidden */
  385. export class _TypeStore {
  386. /** @hidden */
  387. static RegisteredTypes: {
  388. [key: string]: Object;
  389. };
  390. /** @hidden */
  391. static GetClass(fqdn: string): any;
  392. }
  393. }
  394. declare module BABYLON {
  395. /**
  396. * Helper to manipulate strings
  397. */
  398. export class StringTools {
  399. /**
  400. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static EndsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  408. * @param str Source string
  409. * @param suffix Suffix to search for in the source string
  410. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  411. */
  412. static StartsWith(str: string, suffix: string): boolean;
  413. /**
  414. * Decodes a buffer into a string
  415. * @param buffer The buffer to decode
  416. * @returns The decoded string
  417. */
  418. static Decode(buffer: Uint8Array | Uint16Array): string;
  419. /**
  420. * Encode a buffer to a base64 string
  421. * @param buffer defines the buffer to encode
  422. * @returns the encoded string
  423. */
  424. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  425. /**
  426. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  427. * @param num the number to convert and pad
  428. * @param length the expected length of the string
  429. * @returns the padded string
  430. */
  431. static PadNumber(num: number, length: number): string;
  432. }
  433. }
  434. declare module BABYLON {
  435. /**
  436. * Class containing a set of static utilities functions for deep copy.
  437. */
  438. export class DeepCopier {
  439. /**
  440. * Tries to copy an object by duplicating every property
  441. * @param source defines the source object
  442. * @param destination defines the target object
  443. * @param doNotCopyList defines a list of properties to avoid
  444. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  445. */
  446. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  447. }
  448. }
  449. declare module BABYLON {
  450. /**
  451. * Class containing a set of static utilities functions for precision date
  452. */
  453. export class PrecisionDate {
  454. /**
  455. * Gets either window.performance.now() if supported or Date.now() else
  456. */
  457. static get Now(): number;
  458. }
  459. }
  460. declare module BABYLON {
  461. /** @hidden */
  462. export class _DevTools {
  463. static WarnImport(name: string): string;
  464. }
  465. }
  466. declare module BABYLON {
  467. /**
  468. * Interface used to define the mechanism to get data from the network
  469. */
  470. export interface IWebRequest {
  471. /**
  472. * Returns client's response url
  473. */
  474. responseURL: string;
  475. /**
  476. * Returns client's status
  477. */
  478. status: number;
  479. /**
  480. * Returns client's status as a text
  481. */
  482. statusText: string;
  483. }
  484. }
  485. declare module BABYLON {
  486. /**
  487. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  488. */
  489. export class WebRequest implements IWebRequest {
  490. private readonly _xhr;
  491. /**
  492. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  493. * i.e. when loading files, where the server/service expects an Authorization header
  494. */
  495. static CustomRequestHeaders: {
  496. [key: string]: string;
  497. };
  498. /**
  499. * Add callback functions in this array to update all the requests before they get sent to the network
  500. */
  501. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  502. private _injectCustomRequestHeaders;
  503. /**
  504. * Gets or sets a function to be called when loading progress changes
  505. */
  506. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  507. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  508. /**
  509. * Returns client's state
  510. */
  511. get readyState(): number;
  512. /**
  513. * Returns client's status
  514. */
  515. get status(): number;
  516. /**
  517. * Returns client's status as a text
  518. */
  519. get statusText(): string;
  520. /**
  521. * Returns client's response
  522. */
  523. get response(): any;
  524. /**
  525. * Returns client's response url
  526. */
  527. get responseURL(): string;
  528. /**
  529. * Returns client's response as text
  530. */
  531. get responseText(): string;
  532. /**
  533. * Gets or sets the expected response type
  534. */
  535. get responseType(): XMLHttpRequestResponseType;
  536. set responseType(value: XMLHttpRequestResponseType);
  537. /** @hidden */
  538. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  539. /** @hidden */
  540. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  541. /**
  542. * Cancels any network activity
  543. */
  544. abort(): void;
  545. /**
  546. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  547. * @param body defines an optional request body
  548. */
  549. send(body?: Document | BodyInit | null): void;
  550. /**
  551. * Sets the request method, request URL
  552. * @param method defines the method to use (GET, POST, etc..)
  553. * @param url defines the url to connect with
  554. */
  555. open(method: string, url: string): void;
  556. /**
  557. * Sets the value of a request header.
  558. * @param name The name of the header whose value is to be set
  559. * @param value The value to set as the body of the header
  560. */
  561. setRequestHeader(name: string, value: string): void;
  562. /**
  563. * Get the string containing the text of a particular header's value.
  564. * @param name The name of the header
  565. * @returns The string containing the text of the given header name
  566. */
  567. getResponseHeader(name: string): Nullable<string>;
  568. }
  569. }
  570. declare module BABYLON {
  571. /**
  572. * File request interface
  573. */
  574. export interface IFileRequest {
  575. /**
  576. * Raised when the request is complete (success or error).
  577. */
  578. onCompleteObservable: Observable<IFileRequest>;
  579. /**
  580. * Aborts the request for a file.
  581. */
  582. abort: () => void;
  583. }
  584. }
  585. declare module BABYLON {
  586. /**
  587. * Define options used to create a render target texture
  588. */
  589. export class RenderTargetCreationOptions {
  590. /**
  591. * Specifies if mipmaps must be created. If undefined, the value from generateMipMaps is taken instead
  592. */
  593. createMipMaps?: boolean;
  594. /**
  595. * Specifies if mipmaps must be generated
  596. */
  597. generateMipMaps?: boolean;
  598. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  599. generateDepthBuffer?: boolean;
  600. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  601. generateStencilBuffer?: boolean;
  602. /** Defines texture type (int by default) */
  603. type?: number;
  604. /** Defines sampling mode (trilinear by default) */
  605. samplingMode?: number;
  606. /** Defines format (RGBA by default) */
  607. format?: number;
  608. /** Defines sample count (1 by default) */
  609. samples?: number;
  610. }
  611. }
  612. declare module BABYLON {
  613. /** Defines the cross module used constants to avoid circular dependncies */
  614. export class Constants {
  615. /** Defines that alpha blending is disabled */
  616. static readonly ALPHA_DISABLE: number;
  617. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  618. static readonly ALPHA_ADD: number;
  619. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  620. static readonly ALPHA_COMBINE: number;
  621. /** Defines that alpha blending is DEST - SRC * DEST */
  622. static readonly ALPHA_SUBTRACT: number;
  623. /** Defines that alpha blending is SRC * DEST */
  624. static readonly ALPHA_MULTIPLY: number;
  625. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  626. static readonly ALPHA_MAXIMIZED: number;
  627. /** Defines that alpha blending is SRC + DEST */
  628. static readonly ALPHA_ONEONE: number;
  629. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  630. static readonly ALPHA_PREMULTIPLIED: number;
  631. /**
  632. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  633. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  634. */
  635. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  636. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  637. static readonly ALPHA_INTERPOLATE: number;
  638. /**
  639. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  640. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  641. */
  642. static readonly ALPHA_SCREENMODE: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA + DST ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEONE: number;
  648. /**
  649. * Defines that alpha blending is SRC * DST ALPHA + DST
  650. * Alpha will be set to 0
  651. */
  652. static readonly ALPHA_ALPHATOCOLOR: number;
  653. /**
  654. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  655. */
  656. static readonly ALPHA_REVERSEONEMINUS: number;
  657. /**
  658. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  659. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  660. */
  661. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  662. /**
  663. * Defines that alpha blending is SRC + DST
  664. * Alpha will be set to SRC ALPHA
  665. */
  666. static readonly ALPHA_ONEONE_ONEZERO: number;
  667. /**
  668. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  669. * Alpha will be set to DST ALPHA
  670. */
  671. static readonly ALPHA_EXCLUSION: number;
  672. /** Defines that alpha blending equation a SUM */
  673. static readonly ALPHA_EQUATION_ADD: number;
  674. /** Defines that alpha blending equation a SUBSTRACTION */
  675. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  676. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  677. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  678. /** Defines that alpha blending equation a MAX operation */
  679. static readonly ALPHA_EQUATION_MAX: number;
  680. /** Defines that alpha blending equation a MIN operation */
  681. static readonly ALPHA_EQUATION_MIN: number;
  682. /**
  683. * Defines that alpha blending equation a DARKEN operation:
  684. * It takes the min of the src and sums the alpha channels.
  685. */
  686. static readonly ALPHA_EQUATION_DARKEN: number;
  687. /** Defines that the ressource is not delayed*/
  688. static readonly DELAYLOADSTATE_NONE: number;
  689. /** Defines that the ressource was successfully delay loaded */
  690. static readonly DELAYLOADSTATE_LOADED: number;
  691. /** Defines that the ressource is currently delay loading */
  692. static readonly DELAYLOADSTATE_LOADING: number;
  693. /** Defines that the ressource is delayed and has not started loading */
  694. static readonly DELAYLOADSTATE_NOTLOADED: number;
  695. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  696. static readonly NEVER: number;
  697. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  698. static readonly ALWAYS: number;
  699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  700. static readonly LESS: number;
  701. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  702. static readonly EQUAL: number;
  703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  704. static readonly LEQUAL: number;
  705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  706. static readonly GREATER: number;
  707. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  708. static readonly GEQUAL: number;
  709. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  710. static readonly NOTEQUAL: number;
  711. /** Passed to stencilOperation to specify that stencil value must be kept */
  712. static readonly KEEP: number;
  713. /** Passed to stencilOperation to specify that stencil value must be zero */
  714. static readonly ZERO: number;
  715. /** Passed to stencilOperation to specify that stencil value must be replaced */
  716. static readonly REPLACE: number;
  717. /** Passed to stencilOperation to specify that stencil value must be incremented */
  718. static readonly INCR: number;
  719. /** Passed to stencilOperation to specify that stencil value must be decremented */
  720. static readonly DECR: number;
  721. /** Passed to stencilOperation to specify that stencil value must be inverted */
  722. static readonly INVERT: number;
  723. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  724. static readonly INCR_WRAP: number;
  725. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  726. static readonly DECR_WRAP: number;
  727. /** Texture is not repeating outside of 0..1 UVs */
  728. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  729. /** Texture is repeating outside of 0..1 UVs */
  730. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  731. /** Texture is repeating and mirrored */
  732. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  733. /** ALPHA */
  734. static readonly TEXTUREFORMAT_ALPHA: number;
  735. /** LUMINANCE */
  736. static readonly TEXTUREFORMAT_LUMINANCE: number;
  737. /** LUMINANCE_ALPHA */
  738. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  739. /** RGB */
  740. static readonly TEXTUREFORMAT_RGB: number;
  741. /** RGBA */
  742. static readonly TEXTUREFORMAT_RGBA: number;
  743. /** RED */
  744. static readonly TEXTUREFORMAT_RED: number;
  745. /** RED (2nd reference) */
  746. static readonly TEXTUREFORMAT_R: number;
  747. /** RG */
  748. static readonly TEXTUREFORMAT_RG: number;
  749. /** RED_INTEGER */
  750. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  751. /** RED_INTEGER (2nd reference) */
  752. static readonly TEXTUREFORMAT_R_INTEGER: number;
  753. /** RG_INTEGER */
  754. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  755. /** RGB_INTEGER */
  756. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  757. /** RGBA_INTEGER */
  758. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  759. /** BGRA */
  760. static readonly TEXTUREFORMAT_BGRA: number;
  761. /** Depth 24 bits + Stencil 8 bits */
  762. static readonly TEXTUREFORMAT_DEPTH24_STENCIL8: number;
  763. /** Depth 32 bits float */
  764. static readonly TEXTUREFORMAT_DEPTH32_FLOAT: number;
  765. /** Compressed BC7 */
  766. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM: number;
  767. /** Compressed BC6 unsigned float */
  768. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT: number;
  769. /** Compressed BC6 signed float */
  770. static readonly TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT: number;
  771. /** Compressed BC3 */
  772. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5: number;
  773. /** Compressed BC2 */
  774. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3: number;
  775. /** Compressed BC1 */
  776. static readonly TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1: number;
  777. /** UNSIGNED_BYTE */
  778. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  779. /** UNSIGNED_BYTE (2nd reference) */
  780. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  781. /** FLOAT */
  782. static readonly TEXTURETYPE_FLOAT: number;
  783. /** HALF_FLOAT */
  784. static readonly TEXTURETYPE_HALF_FLOAT: number;
  785. /** BYTE */
  786. static readonly TEXTURETYPE_BYTE: number;
  787. /** SHORT */
  788. static readonly TEXTURETYPE_SHORT: number;
  789. /** UNSIGNED_SHORT */
  790. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  791. /** INT */
  792. static readonly TEXTURETYPE_INT: number;
  793. /** UNSIGNED_INT */
  794. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  795. /** UNSIGNED_SHORT_4_4_4_4 */
  796. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  797. /** UNSIGNED_SHORT_5_5_5_1 */
  798. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  799. /** UNSIGNED_SHORT_5_6_5 */
  800. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  801. /** UNSIGNED_INT_2_10_10_10_REV */
  802. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  803. /** UNSIGNED_INT_24_8 */
  804. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  805. /** UNSIGNED_INT_10F_11F_11F_REV */
  806. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  807. /** UNSIGNED_INT_5_9_9_9_REV */
  808. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  809. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  810. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  811. /** nearest is mag = nearest and min = nearest and no mip */
  812. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  813. /** mag = nearest and min = nearest and mip = none */
  814. static readonly TEXTURE_NEAREST_NEAREST: number;
  815. /** Bilinear is mag = linear and min = linear and no mip */
  816. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  817. /** mag = linear and min = linear and mip = none */
  818. static readonly TEXTURE_LINEAR_LINEAR: number;
  819. /** Trilinear is mag = linear and min = linear and mip = linear */
  820. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  821. /** Trilinear is mag = linear and min = linear and mip = linear */
  822. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  823. /** mag = nearest and min = nearest and mip = nearest */
  824. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  825. /** mag = nearest and min = linear and mip = nearest */
  826. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  827. /** mag = nearest and min = linear and mip = linear */
  828. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  829. /** mag = nearest and min = linear and mip = none */
  830. static readonly TEXTURE_NEAREST_LINEAR: number;
  831. /** nearest is mag = nearest and min = nearest and mip = linear */
  832. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  833. /** mag = linear and min = nearest and mip = nearest */
  834. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  835. /** mag = linear and min = nearest and mip = linear */
  836. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  837. /** Bilinear is mag = linear and min = linear and mip = nearest */
  838. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  839. /** mag = linear and min = nearest and mip = none */
  840. static readonly TEXTURE_LINEAR_NEAREST: number;
  841. /** Explicit coordinates mode */
  842. static readonly TEXTURE_EXPLICIT_MODE: number;
  843. /** Spherical coordinates mode */
  844. static readonly TEXTURE_SPHERICAL_MODE: number;
  845. /** Planar coordinates mode */
  846. static readonly TEXTURE_PLANAR_MODE: number;
  847. /** Cubic coordinates mode */
  848. static readonly TEXTURE_CUBIC_MODE: number;
  849. /** Projection coordinates mode */
  850. static readonly TEXTURE_PROJECTION_MODE: number;
  851. /** Skybox coordinates mode */
  852. static readonly TEXTURE_SKYBOX_MODE: number;
  853. /** Inverse Cubic coordinates mode */
  854. static readonly TEXTURE_INVCUBIC_MODE: number;
  855. /** Equirectangular coordinates mode */
  856. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  857. /** Equirectangular Fixed coordinates mode */
  858. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  859. /** Equirectangular Fixed Mirrored coordinates mode */
  860. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  861. /** Offline (baking) quality for texture filtering */
  862. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  863. /** High quality for texture filtering */
  864. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  865. /** Medium quality for texture filtering */
  866. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  867. /** Low quality for texture filtering */
  868. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  869. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  870. static readonly SCALEMODE_FLOOR: number;
  871. /** Defines that texture rescaling will look for the nearest power of 2 size */
  872. static readonly SCALEMODE_NEAREST: number;
  873. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  874. static readonly SCALEMODE_CEILING: number;
  875. /**
  876. * The dirty texture flag value
  877. */
  878. static readonly MATERIAL_TextureDirtyFlag: number;
  879. /**
  880. * The dirty light flag value
  881. */
  882. static readonly MATERIAL_LightDirtyFlag: number;
  883. /**
  884. * The dirty fresnel flag value
  885. */
  886. static readonly MATERIAL_FresnelDirtyFlag: number;
  887. /**
  888. * The dirty attribute flag value
  889. */
  890. static readonly MATERIAL_AttributesDirtyFlag: number;
  891. /**
  892. * The dirty misc flag value
  893. */
  894. static readonly MATERIAL_MiscDirtyFlag: number;
  895. /**
  896. * The dirty prepass flag value
  897. */
  898. static readonly MATERIAL_PrePassDirtyFlag: number;
  899. /**
  900. * The all dirty flag value
  901. */
  902. static readonly MATERIAL_AllDirtyFlag: number;
  903. /**
  904. * Returns the triangle fill mode
  905. */
  906. static readonly MATERIAL_TriangleFillMode: number;
  907. /**
  908. * Returns the wireframe mode
  909. */
  910. static readonly MATERIAL_WireFrameFillMode: number;
  911. /**
  912. * Returns the point fill mode
  913. */
  914. static readonly MATERIAL_PointFillMode: number;
  915. /**
  916. * Returns the point list draw mode
  917. */
  918. static readonly MATERIAL_PointListDrawMode: number;
  919. /**
  920. * Returns the line list draw mode
  921. */
  922. static readonly MATERIAL_LineListDrawMode: number;
  923. /**
  924. * Returns the line loop draw mode
  925. */
  926. static readonly MATERIAL_LineLoopDrawMode: number;
  927. /**
  928. * Returns the line strip draw mode
  929. */
  930. static readonly MATERIAL_LineStripDrawMode: number;
  931. /**
  932. * Returns the triangle strip draw mode
  933. */
  934. static readonly MATERIAL_TriangleStripDrawMode: number;
  935. /**
  936. * Returns the triangle fan draw mode
  937. */
  938. static readonly MATERIAL_TriangleFanDrawMode: number;
  939. /**
  940. * Stores the clock-wise side orientation
  941. */
  942. static readonly MATERIAL_ClockWiseSideOrientation: number;
  943. /**
  944. * Stores the counter clock-wise side orientation
  945. */
  946. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  947. /**
  948. * Nothing
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_NothingTrigger: number;
  952. /**
  953. * On pick
  954. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  955. */
  956. static readonly ACTION_OnPickTrigger: number;
  957. /**
  958. * On left pick
  959. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  960. */
  961. static readonly ACTION_OnLeftPickTrigger: number;
  962. /**
  963. * On right pick
  964. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  965. */
  966. static readonly ACTION_OnRightPickTrigger: number;
  967. /**
  968. * On center pick
  969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  970. */
  971. static readonly ACTION_OnCenterPickTrigger: number;
  972. /**
  973. * On pick down
  974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  975. */
  976. static readonly ACTION_OnPickDownTrigger: number;
  977. /**
  978. * On double pick
  979. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  980. */
  981. static readonly ACTION_OnDoublePickTrigger: number;
  982. /**
  983. * On pick up
  984. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  985. */
  986. static readonly ACTION_OnPickUpTrigger: number;
  987. /**
  988. * On pick out.
  989. * This trigger will only be raised if you also declared a OnPickDown
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnPickOutTrigger: number;
  993. /**
  994. * On long press
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnLongPressTrigger: number;
  998. /**
  999. * On pointer over
  1000. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1001. */
  1002. static readonly ACTION_OnPointerOverTrigger: number;
  1003. /**
  1004. * On pointer out
  1005. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1006. */
  1007. static readonly ACTION_OnPointerOutTrigger: number;
  1008. /**
  1009. * On every frame
  1010. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1011. */
  1012. static readonly ACTION_OnEveryFrameTrigger: number;
  1013. /**
  1014. * On intersection enter
  1015. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1016. */
  1017. static readonly ACTION_OnIntersectionEnterTrigger: number;
  1018. /**
  1019. * On intersection exit
  1020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1021. */
  1022. static readonly ACTION_OnIntersectionExitTrigger: number;
  1023. /**
  1024. * On key down
  1025. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1026. */
  1027. static readonly ACTION_OnKeyDownTrigger: number;
  1028. /**
  1029. * On key up
  1030. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1031. */
  1032. static readonly ACTION_OnKeyUpTrigger: number;
  1033. /**
  1034. * Billboard mode will only apply to Y axis
  1035. */
  1036. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1037. /**
  1038. * Billboard mode will apply to all axes
  1039. */
  1040. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1041. /**
  1042. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1043. */
  1044. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1045. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1046. * Test order :
  1047. * Is the bounding sphere outside the frustum ?
  1048. * If not, are the bounding box vertices outside the frustum ?
  1049. * It not, then the cullable object is in the frustum.
  1050. */
  1051. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1052. /** Culling strategy : Bounding Sphere Only.
  1053. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1054. * It's also less accurate than the standard because some not visible objects can still be selected.
  1055. * Test : is the bounding sphere outside the frustum ?
  1056. * If not, then the cullable object is in the frustum.
  1057. */
  1058. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1059. /** Culling strategy : Optimistic Inclusion.
  1060. * This in an inclusion test first, then the standard exclusion test.
  1061. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1062. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1063. * Anyway, it's as accurate as the standard strategy.
  1064. * Test :
  1065. * Is the cullable object bounding sphere center in the frustum ?
  1066. * If not, apply the default culling strategy.
  1067. */
  1068. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1069. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1070. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1071. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1072. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1073. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1074. * Test :
  1075. * Is the cullable object bounding sphere center in the frustum ?
  1076. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1077. */
  1078. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1079. /**
  1080. * No logging while loading
  1081. */
  1082. static readonly SCENELOADER_NO_LOGGING: number;
  1083. /**
  1084. * Minimal logging while loading
  1085. */
  1086. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1087. /**
  1088. * Summary logging while loading
  1089. */
  1090. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1091. /**
  1092. * Detailled logging while loading
  1093. */
  1094. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1095. /**
  1096. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1097. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1098. */
  1099. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1100. /**
  1101. * Constant used to retrieve the position texture index in the textures array in the prepass
  1102. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1103. */
  1104. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1105. /**
  1106. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1107. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1108. */
  1109. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1110. /**
  1111. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1112. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1113. */
  1114. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1115. /**
  1116. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1117. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1118. */
  1119. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1120. /**
  1121. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1122. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1123. */
  1124. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1125. /**
  1126. * Constant used to retrieve albedo index in the textures array in the prepass
  1127. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1128. */
  1129. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1130. /**
  1131. * Prefixes used by the engine for custom effects
  1132. */
  1133. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1134. }
  1135. }
  1136. declare module BABYLON {
  1137. /** @hidden */
  1138. export interface HardwareTextureWrapper {
  1139. underlyingResource: any;
  1140. set(hardwareTexture: any): void;
  1141. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1142. reset(): void;
  1143. release(): void;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /**
  1148. * This represents the required contract to create a new type of texture loader.
  1149. */
  1150. export interface IInternalTextureLoader {
  1151. /**
  1152. * Defines wether the loader supports cascade loading the different faces.
  1153. */
  1154. supportCascades: boolean;
  1155. /**
  1156. * This returns if the loader support the current file information.
  1157. * @param extension defines the file extension of the file being loaded
  1158. * @param mimeType defines the optional mime type of the file being loaded
  1159. * @returns true if the loader can load the specified file
  1160. */
  1161. canLoad(extension: string, mimeType?: string): boolean;
  1162. /**
  1163. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1164. * @param data contains the texture data
  1165. * @param texture defines the BabylonJS internal texture
  1166. * @param createPolynomials will be true if polynomials have been requested
  1167. * @param onLoad defines the callback to trigger once the texture is ready
  1168. * @param onError defines the callback to trigger in case of error
  1169. * @param options options to be passed to the loader
  1170. */
  1171. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1172. /**
  1173. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1174. * @param data contains the texture data
  1175. * @param texture defines the BabylonJS internal texture
  1176. * @param callback defines the method to call once ready to upload
  1177. * @param options options to be passed to the loader
  1178. */
  1179. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1180. }
  1181. }
  1182. declare module BABYLON {
  1183. /**
  1184. * @hidden
  1185. */
  1186. export interface IColor4Like {
  1187. r: float;
  1188. g: float;
  1189. b: float;
  1190. a: float;
  1191. }
  1192. /**
  1193. * @hidden
  1194. */
  1195. export interface IColor3Like {
  1196. r: float;
  1197. g: float;
  1198. b: float;
  1199. }
  1200. /**
  1201. * @hidden
  1202. */
  1203. export interface IVector4Like {
  1204. x: float;
  1205. y: float;
  1206. z: float;
  1207. w: float;
  1208. }
  1209. /**
  1210. * @hidden
  1211. */
  1212. export interface IVector3Like {
  1213. x: float;
  1214. y: float;
  1215. z: float;
  1216. }
  1217. /**
  1218. * @hidden
  1219. */
  1220. export interface IVector2Like {
  1221. x: float;
  1222. y: float;
  1223. }
  1224. /**
  1225. * @hidden
  1226. */
  1227. export interface IMatrixLike {
  1228. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1229. updateFlag: int;
  1230. }
  1231. /**
  1232. * @hidden
  1233. */
  1234. export interface IViewportLike {
  1235. x: float;
  1236. y: float;
  1237. width: float;
  1238. height: float;
  1239. }
  1240. /**
  1241. * @hidden
  1242. */
  1243. export interface IPlaneLike {
  1244. normal: IVector3Like;
  1245. d: float;
  1246. normalize(): void;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to store and describe the pipeline context associated with an effect
  1252. */
  1253. export interface IPipelineContext {
  1254. /**
  1255. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1256. */
  1257. isAsync: boolean;
  1258. /**
  1259. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1260. */
  1261. isReady: boolean;
  1262. /** @hidden */
  1263. _name?: string;
  1264. /** @hidden */
  1265. _getVertexShaderCode(): string | null;
  1266. /** @hidden */
  1267. _getFragmentShaderCode(): string | null;
  1268. /** @hidden */
  1269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1270. /** @hidden */
  1271. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1272. [key: string]: number;
  1273. }, uniformsNames: string[], uniforms: {
  1274. [key: string]: Nullable<WebGLUniformLocation>;
  1275. }, samplerList: string[], samplers: {
  1276. [key: string]: number;
  1277. }, attributesNames: string[], attributes: number[]): void;
  1278. /** Releases the resources associated with the pipeline. */
  1279. dispose(): void;
  1280. /**
  1281. * Sets an integer value on a uniform variable.
  1282. * @param uniformName Name of the variable.
  1283. * @param value Value to be set.
  1284. */
  1285. setInt(uniformName: string, value: number): void;
  1286. /**
  1287. * Sets an int2 value on a uniform variable.
  1288. * @param uniformName Name of the variable.
  1289. * @param x First int in int2.
  1290. * @param y Second int in int2.
  1291. */
  1292. setInt2(uniformName: string, x: number, y: number): void;
  1293. /**
  1294. * Sets an int3 value on a uniform variable.
  1295. * @param uniformName Name of the variable.
  1296. * @param x First int in int3.
  1297. * @param y Second int in int3.
  1298. * @param z Third int in int3.
  1299. */
  1300. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1301. /**
  1302. * Sets an int4 value on a uniform variable.
  1303. * @param uniformName Name of the variable.
  1304. * @param x First int in int4.
  1305. * @param y Second int in int4.
  1306. * @param z Third int in int4.
  1307. * @param w Fourth int in int4.
  1308. */
  1309. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1310. /**
  1311. * Sets an int array on a uniform variable.
  1312. * @param uniformName Name of the variable.
  1313. * @param array array to be set.
  1314. */
  1315. setIntArray(uniformName: string, array: Int32Array): void;
  1316. /**
  1317. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1318. * @param uniformName Name of the variable.
  1319. * @param array array to be set.
  1320. */
  1321. setIntArray2(uniformName: string, array: Int32Array): void;
  1322. /**
  1323. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1324. * @param uniformName Name of the variable.
  1325. * @param array array to be set.
  1326. */
  1327. setIntArray3(uniformName: string, array: Int32Array): void;
  1328. /**
  1329. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1330. * @param uniformName Name of the variable.
  1331. * @param array array to be set.
  1332. */
  1333. setIntArray4(uniformName: string, array: Int32Array): void;
  1334. /**
  1335. * Sets an array on a uniform variable.
  1336. * @param uniformName Name of the variable.
  1337. * @param array array to be set.
  1338. */
  1339. setArray(uniformName: string, array: number[] | Float32Array): void;
  1340. /**
  1341. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  1342. * @param uniformName Name of the variable.
  1343. * @param array array to be set.
  1344. */
  1345. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1346. /**
  1347. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  1348. * @param uniformName Name of the variable.
  1349. * @param array array to be set.
  1350. */
  1351. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1352. /**
  1353. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  1354. * @param uniformName Name of the variable.
  1355. * @param array array to be set.
  1356. */
  1357. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1358. /**
  1359. * Sets matrices on a uniform variable.
  1360. * @param uniformName Name of the variable.
  1361. * @param matrices matrices to be set.
  1362. */
  1363. setMatrices(uniformName: string, matrices: Float32Array): void;
  1364. /**
  1365. * Sets matrix on a uniform variable.
  1366. * @param uniformName Name of the variable.
  1367. * @param matrix matrix to be set.
  1368. */
  1369. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1370. /**
  1371. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  1372. * @param uniformName Name of the variable.
  1373. * @param matrix matrix to be set.
  1374. */
  1375. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1376. /**
  1377. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1378. * @param uniformName Name of the variable.
  1379. * @param matrix matrix to be set.
  1380. */
  1381. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1382. /**
  1383. * Sets a float on a uniform variable.
  1384. * @param uniformName Name of the variable.
  1385. * @param value value to be set.
  1386. */
  1387. setFloat(uniformName: string, value: number): void;
  1388. /**
  1389. * Sets a Vector2 on a uniform variable.
  1390. * @param uniformName Name of the variable.
  1391. * @param vector2 vector2 to be set.
  1392. */
  1393. setVector2(uniformName: string, vector2: IVector2Like): void;
  1394. /**
  1395. * Sets a float2 on a uniform variable.
  1396. * @param uniformName Name of the variable.
  1397. * @param x First float in float2.
  1398. * @param y Second float in float2.
  1399. */
  1400. setFloat2(uniformName: string, x: number, y: number): void;
  1401. /**
  1402. * Sets a Vector3 on a uniform variable.
  1403. * @param uniformName Name of the variable.
  1404. * @param vector3 Value to be set.
  1405. */
  1406. setVector3(uniformName: string, vector3: IVector3Like): void;
  1407. /**
  1408. * Sets a float3 on a uniform variable.
  1409. * @param uniformName Name of the variable.
  1410. * @param x First float in float3.
  1411. * @param y Second float in float3.
  1412. * @param z Third float in float3.
  1413. */
  1414. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1415. /**
  1416. * Sets a Vector4 on a uniform variable.
  1417. * @param uniformName Name of the variable.
  1418. * @param vector4 Value to be set.
  1419. */
  1420. setVector4(uniformName: string, vector4: IVector4Like): void;
  1421. /**
  1422. * Sets a float4 on a uniform variable.
  1423. * @param uniformName Name of the variable.
  1424. * @param x First float in float4.
  1425. * @param y Second float in float4.
  1426. * @param z Third float in float4.
  1427. * @param w Fourth float in float4.
  1428. */
  1429. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1430. /**
  1431. * Sets a Color3 on a uniform variable.
  1432. * @param uniformName Name of the variable.
  1433. * @param color3 Value to be set.
  1434. */
  1435. setColor3(uniformName: string, color3: IColor3Like): void;
  1436. /**
  1437. * Sets a Color4 on a uniform variable.
  1438. * @param uniformName Name of the variable.
  1439. * @param color3 Value to be set.
  1440. * @param alpha Alpha value to be set.
  1441. */
  1442. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1443. /**
  1444. * Sets a Color4 on a uniform variable
  1445. * @param uniformName defines the name of the variable
  1446. * @param color4 defines the value to be set
  1447. */
  1448. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1449. }
  1450. }
  1451. declare module BABYLON {
  1452. /**
  1453. * Class used to store gfx data (like WebGLBuffer)
  1454. */
  1455. export class DataBuffer {
  1456. /**
  1457. * Gets or sets the number of objects referencing this buffer
  1458. */
  1459. references: number;
  1460. /** Gets or sets the size of the underlying buffer */
  1461. capacity: number;
  1462. /**
  1463. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1464. */
  1465. is32Bits: boolean;
  1466. /**
  1467. * Gets the underlying buffer
  1468. */
  1469. get underlyingResource(): any;
  1470. }
  1471. }
  1472. declare module BABYLON {
  1473. /** @hidden */
  1474. export interface IShaderProcessor {
  1475. attributeProcessor?: (attribute: string, preProcessors: {
  1476. [key: string]: string;
  1477. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1478. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1479. [key: string]: string;
  1480. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1481. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1482. [key: string]: string;
  1483. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1486. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1487. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1488. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1489. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1490. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1491. vertexCode: string;
  1492. fragmentCode: string;
  1493. };
  1494. }
  1495. }
  1496. declare module BABYLON {
  1497. /** @hidden */
  1498. export interface ShaderProcessingContext {
  1499. }
  1500. /** @hidden */
  1501. export interface ProcessingOptions {
  1502. defines: string[];
  1503. indexParameters: any;
  1504. isFragment: boolean;
  1505. shouldUseHighPrecisionShader: boolean;
  1506. supportsUniformBuffers: boolean;
  1507. shadersRepository: string;
  1508. includesShadersStore: {
  1509. [key: string]: string;
  1510. };
  1511. processor: Nullable<IShaderProcessor>;
  1512. version: string;
  1513. platformName: string;
  1514. lookForClosingBracketForUniformBuffer?: boolean;
  1515. processingContext: Nullable<ShaderProcessingContext>;
  1516. }
  1517. }
  1518. declare module BABYLON {
  1519. /** @hidden */
  1520. export class ShaderCodeNode {
  1521. line: string;
  1522. children: ShaderCodeNode[];
  1523. additionalDefineKey?: string;
  1524. additionalDefineValue?: string;
  1525. isValid(preprocessors: {
  1526. [key: string]: string;
  1527. }): boolean;
  1528. process(preprocessors: {
  1529. [key: string]: string;
  1530. }, options: ProcessingOptions): string;
  1531. }
  1532. }
  1533. declare module BABYLON {
  1534. /** @hidden */
  1535. export class ShaderCodeCursor {
  1536. private _lines;
  1537. lineIndex: number;
  1538. get currentLine(): string;
  1539. get canRead(): boolean;
  1540. set lines(value: string[]);
  1541. }
  1542. }
  1543. declare module BABYLON {
  1544. /** @hidden */
  1545. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1546. process(preprocessors: {
  1547. [key: string]: string;
  1548. }, options: ProcessingOptions): string;
  1549. }
  1550. }
  1551. declare module BABYLON {
  1552. /** @hidden */
  1553. export class ShaderDefineExpression {
  1554. isTrue(preprocessors: {
  1555. [key: string]: string;
  1556. }): boolean;
  1557. private static _OperatorPriority;
  1558. private static _Stack;
  1559. static postfixToInfix(postfix: string[]): string;
  1560. static infixToPostfix(infix: string): string[];
  1561. }
  1562. }
  1563. declare module BABYLON {
  1564. /** @hidden */
  1565. export class ShaderCodeTestNode extends ShaderCodeNode {
  1566. testExpression: ShaderDefineExpression;
  1567. isValid(preprocessors: {
  1568. [key: string]: string;
  1569. }): boolean;
  1570. }
  1571. }
  1572. declare module BABYLON {
  1573. /** @hidden */
  1574. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1575. define: string;
  1576. not: boolean;
  1577. constructor(define: string, not?: boolean);
  1578. isTrue(preprocessors: {
  1579. [key: string]: string;
  1580. }): boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /** @hidden */
  1585. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1586. leftOperand: ShaderDefineExpression;
  1587. rightOperand: ShaderDefineExpression;
  1588. isTrue(preprocessors: {
  1589. [key: string]: string;
  1590. }): boolean;
  1591. }
  1592. }
  1593. declare module BABYLON {
  1594. /** @hidden */
  1595. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1596. leftOperand: ShaderDefineExpression;
  1597. rightOperand: ShaderDefineExpression;
  1598. isTrue(preprocessors: {
  1599. [key: string]: string;
  1600. }): boolean;
  1601. }
  1602. }
  1603. declare module BABYLON {
  1604. /** @hidden */
  1605. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1606. define: string;
  1607. operand: string;
  1608. testValue: string;
  1609. constructor(define: string, operand: string, testValue: string);
  1610. isTrue(preprocessors: {
  1611. [key: string]: string;
  1612. }): boolean;
  1613. }
  1614. }
  1615. declare module BABYLON {
  1616. /**
  1617. * Class used to enable access to offline support
  1618. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1619. */
  1620. export interface IOfflineProvider {
  1621. /**
  1622. * Gets a boolean indicating if scene must be saved in the database
  1623. */
  1624. enableSceneOffline: boolean;
  1625. /**
  1626. * Gets a boolean indicating if textures must be saved in the database
  1627. */
  1628. enableTexturesOffline: boolean;
  1629. /**
  1630. * Open the offline support and make it available
  1631. * @param successCallback defines the callback to call on success
  1632. * @param errorCallback defines the callback to call on error
  1633. */
  1634. open(successCallback: () => void, errorCallback: () => void): void;
  1635. /**
  1636. * Loads an image from the offline support
  1637. * @param url defines the url to load from
  1638. * @param image defines the target DOM image
  1639. */
  1640. loadImage(url: string, image: HTMLImageElement): void;
  1641. /**
  1642. * Loads a file from offline support
  1643. * @param url defines the URL to load from
  1644. * @param sceneLoaded defines a callback to call on success
  1645. * @param progressCallBack defines a callback to call when progress changed
  1646. * @param errorCallback defines a callback to call on error
  1647. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1648. */
  1649. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1650. }
  1651. }
  1652. declare module BABYLON {
  1653. /**
  1654. * Class used to help managing file picking and drag'n'drop
  1655. * File Storage
  1656. */
  1657. export class FilesInputStore {
  1658. /**
  1659. * List of files ready to be loaded
  1660. */
  1661. static FilesToLoad: {
  1662. [key: string]: File;
  1663. };
  1664. }
  1665. }
  1666. declare module BABYLON {
  1667. /**
  1668. * Class used to define a retry strategy when error happens while loading assets
  1669. */
  1670. export class RetryStrategy {
  1671. /**
  1672. * Function used to defines an exponential back off strategy
  1673. * @param maxRetries defines the maximum number of retries (3 by default)
  1674. * @param baseInterval defines the interval between retries
  1675. * @returns the strategy function to use
  1676. */
  1677. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1678. }
  1679. }
  1680. declare module BABYLON {
  1681. /**
  1682. * @ignore
  1683. * Application error to support additional information when loading a file
  1684. */
  1685. export abstract class BaseError extends Error {
  1686. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1687. }
  1688. }
  1689. declare module BABYLON {
  1690. /** @ignore */
  1691. export class LoadFileError extends BaseError {
  1692. request?: WebRequest;
  1693. file?: File;
  1694. /**
  1695. * Creates a new LoadFileError
  1696. * @param message defines the message of the error
  1697. * @param request defines the optional web request
  1698. * @param file defines the optional file
  1699. */
  1700. constructor(message: string, object?: WebRequest | File);
  1701. }
  1702. /** @ignore */
  1703. export class RequestFileError extends BaseError {
  1704. request: WebRequest;
  1705. /**
  1706. * Creates a new LoadFileError
  1707. * @param message defines the message of the error
  1708. * @param request defines the optional web request
  1709. */
  1710. constructor(message: string, request: WebRequest);
  1711. }
  1712. /** @ignore */
  1713. export class ReadFileError extends BaseError {
  1714. file: File;
  1715. /**
  1716. * Creates a new ReadFileError
  1717. * @param message defines the message of the error
  1718. * @param file defines the optional file
  1719. */
  1720. constructor(message: string, file: File);
  1721. }
  1722. /**
  1723. * @hidden
  1724. */
  1725. export class FileTools {
  1726. /**
  1727. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1728. */
  1729. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1730. /**
  1731. * Gets or sets the base URL to use to load assets
  1732. */
  1733. static BaseUrl: string;
  1734. /**
  1735. * Default behaviour for cors in the application.
  1736. * It can be a string if the expected behavior is identical in the entire app.
  1737. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1738. */
  1739. static CorsBehavior: string | ((url: string | string[]) => string);
  1740. /**
  1741. * Gets or sets a function used to pre-process url before using them to load assets
  1742. */
  1743. static PreprocessUrl: (url: string) => string;
  1744. /**
  1745. * Removes unwanted characters from an url
  1746. * @param url defines the url to clean
  1747. * @returns the cleaned url
  1748. */
  1749. private static _CleanUrl;
  1750. /**
  1751. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1752. * @param url define the url we are trying
  1753. * @param element define the dom element where to configure the cors policy
  1754. */
  1755. static SetCorsBehavior(url: string | string[], element: {
  1756. crossOrigin: string | null;
  1757. }): void;
  1758. /**
  1759. * Loads an image as an HTMLImageElement.
  1760. * @param input url string, ArrayBuffer, or Blob to load
  1761. * @param onLoad callback called when the image successfully loads
  1762. * @param onError callback called when the image fails to load
  1763. * @param offlineProvider offline provider for caching
  1764. * @param mimeType optional mime type
  1765. * @returns the HTMLImageElement of the loaded image
  1766. */
  1767. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1768. /**
  1769. * Reads a file from a File object
  1770. * @param file defines the file to load
  1771. * @param onSuccess defines the callback to call when data is loaded
  1772. * @param onProgress defines the callback to call during loading process
  1773. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1774. * @param onError defines the callback to call when an error occurs
  1775. * @returns a file request object
  1776. */
  1777. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1778. /**
  1779. * Loads a file from a url
  1780. * @param url url to load
  1781. * @param onSuccess callback called when the file successfully loads
  1782. * @param onProgress callback called while file is loading (if the server supports this mode)
  1783. * @param offlineProvider defines the offline provider for caching
  1784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1785. * @param onError callback called when the file fails to load
  1786. * @returns a file request object
  1787. */
  1788. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1789. /**
  1790. * Loads a file
  1791. * @param url url to load
  1792. * @param onSuccess callback called when the file successfully loads
  1793. * @param onProgress callback called while file is loading (if the server supports this mode)
  1794. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1795. * @param onError callback called when the file fails to load
  1796. * @param onOpened callback called when the web request is opened
  1797. * @returns a file request object
  1798. */
  1799. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1800. /**
  1801. * Checks if the loaded document was accessed via `file:`-Protocol.
  1802. * @returns boolean
  1803. */
  1804. static IsFileURL(): boolean;
  1805. }
  1806. }
  1807. declare module BABYLON {
  1808. /** @hidden */
  1809. export class ShaderProcessor {
  1810. static Initialize(options: ProcessingOptions): void;
  1811. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1812. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1813. vertexCode: string;
  1814. fragmentCode: string;
  1815. };
  1816. private static _ProcessPrecision;
  1817. private static _ExtractOperation;
  1818. private static _BuildSubExpression;
  1819. private static _BuildExpression;
  1820. private static _MoveCursorWithinIf;
  1821. private static _MoveCursor;
  1822. private static _EvaluatePreProcessors;
  1823. private static _PreparePreProcessors;
  1824. private static _ProcessShaderConversion;
  1825. private static _ProcessIncludes;
  1826. /**
  1827. * Loads a file from a url
  1828. * @param url url to load
  1829. * @param onSuccess callback called when the file successfully loads
  1830. * @param onProgress callback called while file is loading (if the server supports this mode)
  1831. * @param offlineProvider defines the offline provider for caching
  1832. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1833. * @param onError callback called when the file fails to load
  1834. * @returns a file request object
  1835. * @hidden
  1836. */
  1837. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1838. }
  1839. }
  1840. declare module BABYLON {
  1841. /**
  1842. * Interface used to define common properties for effect fallbacks
  1843. */
  1844. export interface IEffectFallbacks {
  1845. /**
  1846. * Removes the defines that should be removed when falling back.
  1847. * @param currentDefines defines the current define statements for the shader.
  1848. * @param effect defines the current effect we try to compile
  1849. * @returns The resulting defines with defines of the current rank removed.
  1850. */
  1851. reduce(currentDefines: string, effect: Effect): string;
  1852. /**
  1853. * Removes the fallback from the bound mesh.
  1854. */
  1855. unBindMesh(): void;
  1856. /**
  1857. * Checks to see if more fallbacks are still availible.
  1858. */
  1859. hasMoreFallbacks: boolean;
  1860. }
  1861. }
  1862. declare module BABYLON {
  1863. /**
  1864. * Interface for the size containing width and height
  1865. */
  1866. export interface ISize {
  1867. /**
  1868. * Width
  1869. */
  1870. width: number;
  1871. /**
  1872. * Heighht
  1873. */
  1874. height: number;
  1875. }
  1876. /**
  1877. * Size containing widht and height
  1878. */
  1879. export class Size implements ISize {
  1880. /**
  1881. * Width
  1882. */
  1883. width: number;
  1884. /**
  1885. * Height
  1886. */
  1887. height: number;
  1888. /**
  1889. * Creates a Size object from the given width and height (floats).
  1890. * @param width width of the new size
  1891. * @param height height of the new size
  1892. */
  1893. constructor(width: number, height: number);
  1894. /**
  1895. * Returns a string with the Size width and height
  1896. * @returns a string with the Size width and height
  1897. */
  1898. toString(): string;
  1899. /**
  1900. * "Size"
  1901. * @returns the string "Size"
  1902. */
  1903. getClassName(): string;
  1904. /**
  1905. * Returns the Size hash code.
  1906. * @returns a hash code for a unique width and height
  1907. */
  1908. getHashCode(): number;
  1909. /**
  1910. * Updates the current size from the given one.
  1911. * @param src the given size
  1912. */
  1913. copyFrom(src: Size): void;
  1914. /**
  1915. * Updates in place the current Size from the given floats.
  1916. * @param width width of the new size
  1917. * @param height height of the new size
  1918. * @returns the updated Size.
  1919. */
  1920. copyFromFloats(width: number, height: number): Size;
  1921. /**
  1922. * Updates in place the current Size from the given floats.
  1923. * @param width width to set
  1924. * @param height height to set
  1925. * @returns the updated Size.
  1926. */
  1927. set(width: number, height: number): Size;
  1928. /**
  1929. * Multiplies the width and height by numbers
  1930. * @param w factor to multiple the width by
  1931. * @param h factor to multiple the height by
  1932. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1933. */
  1934. multiplyByFloats(w: number, h: number): Size;
  1935. /**
  1936. * Clones the size
  1937. * @returns a new Size copied from the given one.
  1938. */
  1939. clone(): Size;
  1940. /**
  1941. * True if the current Size and the given one width and height are strictly equal.
  1942. * @param other the other size to compare against
  1943. * @returns True if the current Size and the given one width and height are strictly equal.
  1944. */
  1945. equals(other: Size): boolean;
  1946. /**
  1947. * The surface of the Size : width * height (float).
  1948. */
  1949. get surface(): number;
  1950. /**
  1951. * Create a new size of zero
  1952. * @returns a new Size set to (0.0, 0.0)
  1953. */
  1954. static Zero(): Size;
  1955. /**
  1956. * Sums the width and height of two sizes
  1957. * @param otherSize size to add to this size
  1958. * @returns a new Size set as the addition result of the current Size and the given one.
  1959. */
  1960. add(otherSize: Size): Size;
  1961. /**
  1962. * Subtracts the width and height of two
  1963. * @param otherSize size to subtract to this size
  1964. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1965. */
  1966. subtract(otherSize: Size): Size;
  1967. /**
  1968. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1969. * @param start starting size to lerp between
  1970. * @param end end size to lerp between
  1971. * @param amount amount to lerp between the start and end values
  1972. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1973. */
  1974. static Lerp(start: Size, end: Size, amount: number): Size;
  1975. }
  1976. }
  1977. declare module BABYLON {
  1978. /**
  1979. * Base class of all the textures in babylon.
  1980. * It groups all the common properties required to work with Thin Engine.
  1981. */
  1982. export class ThinTexture {
  1983. protected _wrapU: number;
  1984. /**
  1985. * | Value | Type | Description |
  1986. * | ----- | ------------------ | ----------- |
  1987. * | 0 | CLAMP_ADDRESSMODE | |
  1988. * | 1 | WRAP_ADDRESSMODE | |
  1989. * | 2 | MIRROR_ADDRESSMODE | |
  1990. */
  1991. get wrapU(): number;
  1992. set wrapU(value: number);
  1993. protected _wrapV: number;
  1994. /**
  1995. * | Value | Type | Description |
  1996. * | ----- | ------------------ | ----------- |
  1997. * | 0 | CLAMP_ADDRESSMODE | |
  1998. * | 1 | WRAP_ADDRESSMODE | |
  1999. * | 2 | MIRROR_ADDRESSMODE | |
  2000. */
  2001. get wrapV(): number;
  2002. set wrapV(value: number);
  2003. /**
  2004. * | Value | Type | Description |
  2005. * | ----- | ------------------ | ----------- |
  2006. * | 0 | CLAMP_ADDRESSMODE | |
  2007. * | 1 | WRAP_ADDRESSMODE | |
  2008. * | 2 | MIRROR_ADDRESSMODE | |
  2009. */
  2010. wrapR: number;
  2011. /**
  2012. * With compliant hardware and browser (supporting anisotropic filtering)
  2013. * this defines the level of anisotropic filtering in the texture.
  2014. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2015. */
  2016. anisotropicFilteringLevel: number;
  2017. /**
  2018. * Define the current state of the loading sequence when in delayed load mode.
  2019. */
  2020. delayLoadState: number;
  2021. /**
  2022. * How a texture is mapped.
  2023. * Unused in thin texture mode.
  2024. */
  2025. get coordinatesMode(): number;
  2026. /**
  2027. * Define if the texture is a cube texture or if false a 2d texture.
  2028. */
  2029. get isCube(): boolean;
  2030. set isCube(value: boolean);
  2031. /**
  2032. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2033. */
  2034. get is3D(): boolean;
  2035. set is3D(value: boolean);
  2036. /**
  2037. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2038. */
  2039. get is2DArray(): boolean;
  2040. set is2DArray(value: boolean);
  2041. /**
  2042. * Get the class name of the texture.
  2043. * @returns "ThinTexture"
  2044. */
  2045. getClassName(): string;
  2046. /** @hidden */
  2047. _texture: Nullable<InternalTexture>;
  2048. protected _engine: Nullable<ThinEngine>;
  2049. private _cachedSize;
  2050. private _cachedBaseSize;
  2051. /**
  2052. * Instantiates a new ThinTexture.
  2053. * Base class of all the textures in babylon.
  2054. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2055. * @param internalTexture Define the internalTexture to wrap
  2056. */
  2057. constructor(internalTexture: Nullable<InternalTexture>);
  2058. /**
  2059. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2060. * @returns true if fully ready
  2061. */
  2062. isReady(): boolean;
  2063. /**
  2064. * Triggers the load sequence in delayed load mode.
  2065. */
  2066. delayLoad(): void;
  2067. /**
  2068. * Get the underlying lower level texture from Babylon.
  2069. * @returns the insternal texture
  2070. */
  2071. getInternalTexture(): Nullable<InternalTexture>;
  2072. /**
  2073. * Get the size of the texture.
  2074. * @returns the texture size.
  2075. */
  2076. getSize(): ISize;
  2077. /**
  2078. * Get the base size of the texture.
  2079. * It can be different from the size if the texture has been resized for POT for instance
  2080. * @returns the base size
  2081. */
  2082. getBaseSize(): ISize;
  2083. /**
  2084. * Update the sampling mode of the texture.
  2085. * Default is Trilinear mode.
  2086. *
  2087. * | Value | Type | Description |
  2088. * | ----- | ------------------ | ----------- |
  2089. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2090. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2091. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2092. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2093. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2094. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2095. * | 7 | NEAREST_LINEAR | |
  2096. * | 8 | NEAREST_NEAREST | |
  2097. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2098. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2099. * | 11 | LINEAR_LINEAR | |
  2100. * | 12 | LINEAR_NEAREST | |
  2101. *
  2102. * > _mag_: magnification filter (close to the viewer)
  2103. * > _min_: minification filter (far from the viewer)
  2104. * > _mip_: filter used between mip map levels
  2105. *@param samplingMode Define the new sampling mode of the texture
  2106. */
  2107. updateSamplingMode(samplingMode: number): void;
  2108. /**
  2109. * Release and destroy the underlying lower level texture aka internalTexture.
  2110. */
  2111. releaseInternalTexture(): void;
  2112. /**
  2113. * Dispose the texture and release its associated resources.
  2114. */
  2115. dispose(): void;
  2116. }
  2117. }
  2118. declare module BABYLON {
  2119. /**
  2120. * Defines an array and its length.
  2121. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  2122. */
  2123. export interface ISmartArrayLike<T> {
  2124. /**
  2125. * The data of the array.
  2126. */
  2127. data: Array<T>;
  2128. /**
  2129. * The active length of the array.
  2130. */
  2131. length: number;
  2132. }
  2133. /**
  2134. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2135. */
  2136. export class SmartArray<T> implements ISmartArrayLike<T> {
  2137. /**
  2138. * The full set of data from the array.
  2139. */
  2140. data: Array<T>;
  2141. /**
  2142. * The active length of the array.
  2143. */
  2144. length: number;
  2145. protected _id: number;
  2146. /**
  2147. * Instantiates a Smart Array.
  2148. * @param capacity defines the default capacity of the array.
  2149. */
  2150. constructor(capacity: number);
  2151. /**
  2152. * Pushes a value at the end of the active data.
  2153. * @param value defines the object to push in the array.
  2154. */
  2155. push(value: T): void;
  2156. /**
  2157. * Iterates over the active data and apply the lambda to them.
  2158. * @param func defines the action to apply on each value.
  2159. */
  2160. forEach(func: (content: T) => void): void;
  2161. /**
  2162. * Sorts the full sets of data.
  2163. * @param compareFn defines the comparison function to apply.
  2164. */
  2165. sort(compareFn: (a: T, b: T) => number): void;
  2166. /**
  2167. * Resets the active data to an empty array.
  2168. */
  2169. reset(): void;
  2170. /**
  2171. * Releases all the data from the array as well as the array.
  2172. */
  2173. dispose(): void;
  2174. /**
  2175. * Concats the active data with a given array.
  2176. * @param array defines the data to concatenate with.
  2177. */
  2178. concat(array: any): void;
  2179. /**
  2180. * Returns the position of a value in the active data.
  2181. * @param value defines the value to find the index for
  2182. * @returns the index if found in the active data otherwise -1
  2183. */
  2184. indexOf(value: T): number;
  2185. /**
  2186. * Returns whether an element is part of the active data.
  2187. * @param value defines the value to look for
  2188. * @returns true if found in the active data otherwise false
  2189. */
  2190. contains(value: T): boolean;
  2191. private static _GlobalId;
  2192. }
  2193. /**
  2194. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2195. * The data in this array can only be present once
  2196. */
  2197. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2198. private _duplicateId;
  2199. /**
  2200. * Pushes a value at the end of the active data.
  2201. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2202. * @param value defines the object to push in the array.
  2203. */
  2204. push(value: T): void;
  2205. /**
  2206. * Pushes a value at the end of the active data.
  2207. * If the data is already present, it won t be added again
  2208. * @param value defines the object to push in the array.
  2209. * @returns true if added false if it was already present
  2210. */
  2211. pushNoDuplicate(value: T): boolean;
  2212. /**
  2213. * Resets the active data to an empty array.
  2214. */
  2215. reset(): void;
  2216. /**
  2217. * Concats the active data with a given array.
  2218. * This ensures no dupplicate will be present in the result.
  2219. * @param array defines the data to concatenate with.
  2220. */
  2221. concatWithNoDuplicate(array: any): void;
  2222. }
  2223. }
  2224. declare module BABYLON {
  2225. /**
  2226. * Class used to evalaute queries containing `and` and `or` operators
  2227. */
  2228. export class AndOrNotEvaluator {
  2229. /**
  2230. * Evaluate a query
  2231. * @param query defines the query to evaluate
  2232. * @param evaluateCallback defines the callback used to filter result
  2233. * @returns true if the query matches
  2234. */
  2235. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2236. private static _HandleParenthesisContent;
  2237. private static _SimplifyNegation;
  2238. }
  2239. }
  2240. declare module BABYLON {
  2241. /**
  2242. * Class used to store custom tags
  2243. */
  2244. export class Tags {
  2245. /**
  2246. * Adds support for tags on the given object
  2247. * @param obj defines the object to use
  2248. */
  2249. static EnableFor(obj: any): void;
  2250. /**
  2251. * Removes tags support
  2252. * @param obj defines the object to use
  2253. */
  2254. static DisableFor(obj: any): void;
  2255. /**
  2256. * Gets a boolean indicating if the given object has tags
  2257. * @param obj defines the object to use
  2258. * @returns a boolean
  2259. */
  2260. static HasTags(obj: any): boolean;
  2261. /**
  2262. * Gets the tags available on a given object
  2263. * @param obj defines the object to use
  2264. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2265. * @returns the tags
  2266. */
  2267. static GetTags(obj: any, asString?: boolean): any;
  2268. /**
  2269. * Adds tags to an object
  2270. * @param obj defines the object to use
  2271. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2272. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2273. */
  2274. static AddTagsTo(obj: any, tagsString: string): void;
  2275. /**
  2276. * @hidden
  2277. */
  2278. static _AddTagTo(obj: any, tag: string): void;
  2279. /**
  2280. * Removes specific tags from a specific object
  2281. * @param obj defines the object to use
  2282. * @param tagsString defines the tags to remove
  2283. */
  2284. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2285. /**
  2286. * @hidden
  2287. */
  2288. static _RemoveTagFrom(obj: any, tag: string): void;
  2289. /**
  2290. * Defines if tags hosted on an object match a given query
  2291. * @param obj defines the object to use
  2292. * @param tagsQuery defines the tag query
  2293. * @returns a boolean
  2294. */
  2295. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2296. }
  2297. }
  2298. declare module BABYLON {
  2299. /**
  2300. * Scalar computation library
  2301. */
  2302. export class Scalar {
  2303. /**
  2304. * Two pi constants convenient for computation.
  2305. */
  2306. static TwoPi: number;
  2307. /**
  2308. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2309. * @param a number
  2310. * @param b number
  2311. * @param epsilon (default = 1.401298E-45)
  2312. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2313. */
  2314. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2315. /**
  2316. * Returns a string : the upper case translation of the number i to hexadecimal.
  2317. * @param i number
  2318. * @returns the upper case translation of the number i to hexadecimal.
  2319. */
  2320. static ToHex(i: number): string;
  2321. /**
  2322. * Returns -1 if value is negative and +1 is value is positive.
  2323. * @param value the value
  2324. * @returns the value itself if it's equal to zero.
  2325. */
  2326. static Sign(value: number): number;
  2327. /**
  2328. * Returns the value itself if it's between min and max.
  2329. * Returns min if the value is lower than min.
  2330. * Returns max if the value is greater than max.
  2331. * @param value the value to clmap
  2332. * @param min the min value to clamp to (default: 0)
  2333. * @param max the max value to clamp to (default: 1)
  2334. * @returns the clamped value
  2335. */
  2336. static Clamp(value: number, min?: number, max?: number): number;
  2337. /**
  2338. * the log2 of value.
  2339. * @param value the value to compute log2 of
  2340. * @returns the log2 of value.
  2341. */
  2342. static Log2(value: number): number;
  2343. /**
  2344. * the floor part of a log2 value.
  2345. * @param value the value to compute log2 of
  2346. * @returns the log2 of value.
  2347. */
  2348. static ILog2(value: number): number;
  2349. /**
  2350. * Loops the value, so that it is never larger than length and never smaller than 0.
  2351. *
  2352. * This is similar to the modulo operator but it works with floating point numbers.
  2353. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2354. * With t = 5 and length = 2.5, the result would be 0.0.
  2355. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2356. * @param value the value
  2357. * @param length the length
  2358. * @returns the looped value
  2359. */
  2360. static Repeat(value: number, length: number): number;
  2361. /**
  2362. * Normalize the value between 0.0 and 1.0 using min and max values
  2363. * @param value value to normalize
  2364. * @param min max to normalize between
  2365. * @param max min to normalize between
  2366. * @returns the normalized value
  2367. */
  2368. static Normalize(value: number, min: number, max: number): number;
  2369. /**
  2370. * Denormalize the value from 0.0 and 1.0 using min and max values
  2371. * @param normalized value to denormalize
  2372. * @param min max to denormalize between
  2373. * @param max min to denormalize between
  2374. * @returns the denormalized value
  2375. */
  2376. static Denormalize(normalized: number, min: number, max: number): number;
  2377. /**
  2378. * Calculates the shortest difference between two given angles given in degrees.
  2379. * @param current current angle in degrees
  2380. * @param target target angle in degrees
  2381. * @returns the delta
  2382. */
  2383. static DeltaAngle(current: number, target: number): number;
  2384. /**
  2385. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2386. * @param tx value
  2387. * @param length length
  2388. * @returns The returned value will move back and forth between 0 and length
  2389. */
  2390. static PingPong(tx: number, length: number): number;
  2391. /**
  2392. * Interpolates between min and max with smoothing at the limits.
  2393. *
  2394. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2395. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2396. * @param from from
  2397. * @param to to
  2398. * @param tx value
  2399. * @returns the smooth stepped value
  2400. */
  2401. static SmoothStep(from: number, to: number, tx: number): number;
  2402. /**
  2403. * Moves a value current towards target.
  2404. *
  2405. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2406. * Negative values of maxDelta pushes the value away from target.
  2407. * @param current current value
  2408. * @param target target value
  2409. * @param maxDelta max distance to move
  2410. * @returns resulting value
  2411. */
  2412. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2413. /**
  2414. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2415. *
  2416. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2417. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2418. * @param current current value
  2419. * @param target target value
  2420. * @param maxDelta max distance to move
  2421. * @returns resulting angle
  2422. */
  2423. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2424. /**
  2425. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2426. * @param start start value
  2427. * @param end target value
  2428. * @param amount amount to lerp between
  2429. * @returns the lerped value
  2430. */
  2431. static Lerp(start: number, end: number, amount: number): number;
  2432. /**
  2433. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2434. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2435. * @param start start value
  2436. * @param end target value
  2437. * @param amount amount to lerp between
  2438. * @returns the lerped value
  2439. */
  2440. static LerpAngle(start: number, end: number, amount: number): number;
  2441. /**
  2442. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2443. * @param a start value
  2444. * @param b target value
  2445. * @param value value between a and b
  2446. * @returns the inverseLerp value
  2447. */
  2448. static InverseLerp(a: number, b: number, value: number): number;
  2449. /**
  2450. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2451. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2452. * @param value1 spline value
  2453. * @param tangent1 spline value
  2454. * @param value2 spline value
  2455. * @param tangent2 spline value
  2456. * @param amount input value
  2457. * @returns hermite result
  2458. */
  2459. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2460. /**
  2461. * Returns a random float number between and min and max values
  2462. * @param min min value of random
  2463. * @param max max value of random
  2464. * @returns random value
  2465. */
  2466. static RandomRange(min: number, max: number): number;
  2467. /**
  2468. * This function returns percentage of a number in a given range.
  2469. *
  2470. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2471. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2472. * @param number to convert to percentage
  2473. * @param min min range
  2474. * @param max max range
  2475. * @returns the percentage
  2476. */
  2477. static RangeToPercent(number: number, min: number, max: number): number;
  2478. /**
  2479. * This function returns number that corresponds to the percentage in a given range.
  2480. *
  2481. * PercentToRange(0.34,0,100) will return 34.
  2482. * @param percent to convert to number
  2483. * @param min min range
  2484. * @param max max range
  2485. * @returns the number
  2486. */
  2487. static PercentToRange(percent: number, min: number, max: number): number;
  2488. /**
  2489. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2490. * @param angle The angle to normalize in radian.
  2491. * @return The converted angle.
  2492. */
  2493. static NormalizeRadians(angle: number): number;
  2494. }
  2495. }
  2496. declare module BABYLON {
  2497. /**
  2498. * Constant used to convert a value to gamma space
  2499. * @ignorenaming
  2500. */
  2501. export const ToGammaSpace: number;
  2502. /**
  2503. * Constant used to convert a value to linear space
  2504. * @ignorenaming
  2505. */
  2506. export const ToLinearSpace = 2.2;
  2507. /**
  2508. * Constant used to define the minimal number value in Babylon.js
  2509. * @ignorenaming
  2510. */
  2511. let Epsilon: number;
  2512. }
  2513. declare module BABYLON {
  2514. /**
  2515. * Class used to represent a viewport on screen
  2516. */
  2517. export class Viewport {
  2518. /** viewport left coordinate */
  2519. x: number;
  2520. /** viewport top coordinate */
  2521. y: number;
  2522. /**viewport width */
  2523. width: number;
  2524. /** viewport height */
  2525. height: number;
  2526. /**
  2527. * Creates a Viewport object located at (x, y) and sized (width, height)
  2528. * @param x defines viewport left coordinate
  2529. * @param y defines viewport top coordinate
  2530. * @param width defines the viewport width
  2531. * @param height defines the viewport height
  2532. */
  2533. constructor(
  2534. /** viewport left coordinate */
  2535. x: number,
  2536. /** viewport top coordinate */
  2537. y: number,
  2538. /**viewport width */
  2539. width: number,
  2540. /** viewport height */
  2541. height: number);
  2542. /**
  2543. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2544. * @param renderWidth defines the rendering width
  2545. * @param renderHeight defines the rendering height
  2546. * @returns a new Viewport
  2547. */
  2548. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2549. /**
  2550. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2551. * @param renderWidth defines the rendering width
  2552. * @param renderHeight defines the rendering height
  2553. * @param ref defines the target viewport
  2554. * @returns the current viewport
  2555. */
  2556. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2557. /**
  2558. * Returns a new Viewport copied from the current one
  2559. * @returns a new Viewport
  2560. */
  2561. clone(): Viewport;
  2562. }
  2563. }
  2564. declare module BABYLON {
  2565. /**
  2566. * Class containing a set of static utilities functions for arrays.
  2567. */
  2568. export class ArrayTools {
  2569. /**
  2570. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2571. * @param size the number of element to construct and put in the array
  2572. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2573. * @returns a new array filled with new objects
  2574. */
  2575. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2576. }
  2577. }
  2578. declare module BABYLON {
  2579. /**
  2580. * Represents a plane by the equation ax + by + cz + d = 0
  2581. */
  2582. export class Plane {
  2583. private static _TmpMatrix;
  2584. /**
  2585. * Normal of the plane (a,b,c)
  2586. */
  2587. normal: Vector3;
  2588. /**
  2589. * d component of the plane
  2590. */
  2591. d: number;
  2592. /**
  2593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2594. * @param a a component of the plane
  2595. * @param b b component of the plane
  2596. * @param c c component of the plane
  2597. * @param d d component of the plane
  2598. */
  2599. constructor(a: number, b: number, c: number, d: number);
  2600. /**
  2601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2602. */
  2603. asArray(): number[];
  2604. /**
  2605. * @returns a new plane copied from the current Plane.
  2606. */
  2607. clone(): Plane;
  2608. /**
  2609. * @returns the string "Plane".
  2610. */
  2611. getClassName(): string;
  2612. /**
  2613. * @returns the Plane hash code.
  2614. */
  2615. getHashCode(): number;
  2616. /**
  2617. * Normalize the current Plane in place.
  2618. * @returns the updated Plane.
  2619. */
  2620. normalize(): Plane;
  2621. /**
  2622. * Applies a transformation the plane and returns the result
  2623. * @param transformation the transformation matrix to be applied to the plane
  2624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2625. */
  2626. transform(transformation: DeepImmutable<Matrix>): Plane;
  2627. /**
  2628. * Compute the dot product between the point and the plane normal
  2629. * @param point point to calculate the dot product with
  2630. * @returns the dot product (float) of the point coordinates and the plane normal.
  2631. */
  2632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2633. /**
  2634. * Updates the current Plane from the plane defined by the three given points.
  2635. * @param point1 one of the points used to contruct the plane
  2636. * @param point2 one of the points used to contruct the plane
  2637. * @param point3 one of the points used to contruct the plane
  2638. * @returns the updated Plane.
  2639. */
  2640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2641. /**
  2642. * Checks if the plane is facing a given direction (meaning if the plane's normal is pointing in the opposite direction of the given vector).
  2643. * Note that for this function to work as expected you should make sure that:
  2644. * - direction and the plane normal are normalized
  2645. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2646. * @param direction the direction to check if the plane is facing
  2647. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2648. * @returns True if the plane is facing the given direction
  2649. */
  2650. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2651. /**
  2652. * Calculates the distance to a point
  2653. * @param point point to calculate distance to
  2654. * @returns the signed distance (float) from the given point to the Plane.
  2655. */
  2656. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2657. /**
  2658. * Creates a plane from an array
  2659. * @param array the array to create a plane from
  2660. * @returns a new Plane from the given array.
  2661. */
  2662. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2663. /**
  2664. * Creates a plane from three points
  2665. * @param point1 point used to create the plane
  2666. * @param point2 point used to create the plane
  2667. * @param point3 point used to create the plane
  2668. * @returns a new Plane defined by the three given points.
  2669. */
  2670. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2671. /**
  2672. * Creates a plane from an origin point and a normal
  2673. * @param origin origin of the plane to be constructed
  2674. * @param normal normal of the plane to be constructed
  2675. * @returns a new Plane the normal vector to this plane at the given origin point.
  2676. * Note : the vector "normal" is updated because normalized.
  2677. */
  2678. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2679. /**
  2680. * Calculates the distance from a plane and a point
  2681. * @param origin origin of the plane to be constructed
  2682. * @param normal normal of the plane to be constructed
  2683. * @param point point to calculate distance to
  2684. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2685. */
  2686. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2687. }
  2688. }
  2689. declare module BABYLON {
  2690. /** @hidden */
  2691. export class PerformanceConfigurator {
  2692. /** @hidden */
  2693. static MatrixUse64Bits: boolean;
  2694. /** @hidden */
  2695. static MatrixTrackPrecisionChange: boolean;
  2696. /** @hidden */
  2697. static MatrixCurrentType: any;
  2698. /** @hidden */
  2699. static MatrixTrackedMatrices: Array<any> | null;
  2700. /** @hidden */
  2701. static SetMatrixPrecision(use64bits: boolean): void;
  2702. }
  2703. }
  2704. declare module BABYLON {
  2705. /**
  2706. * Class representing a vector containing 2 coordinates
  2707. */
  2708. export class Vector2 {
  2709. /** defines the first coordinate */
  2710. x: number;
  2711. /** defines the second coordinate */
  2712. y: number;
  2713. /**
  2714. * Creates a new Vector2 from the given x and y coordinates
  2715. * @param x defines the first coordinate
  2716. * @param y defines the second coordinate
  2717. */
  2718. constructor(
  2719. /** defines the first coordinate */
  2720. x?: number,
  2721. /** defines the second coordinate */
  2722. y?: number);
  2723. /**
  2724. * Gets a string with the Vector2 coordinates
  2725. * @returns a string with the Vector2 coordinates
  2726. */
  2727. toString(): string;
  2728. /**
  2729. * Gets class name
  2730. * @returns the string "Vector2"
  2731. */
  2732. getClassName(): string;
  2733. /**
  2734. * Gets current vector hash code
  2735. * @returns the Vector2 hash code as a number
  2736. */
  2737. getHashCode(): number;
  2738. /**
  2739. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2740. * @param array defines the source array
  2741. * @param index defines the offset in source array
  2742. * @returns the current Vector2
  2743. */
  2744. toArray(array: FloatArray, index?: number): Vector2;
  2745. /**
  2746. * Update the current vector from an array
  2747. * @param array defines the destination array
  2748. * @param index defines the offset in the destination array
  2749. * @returns the current Vector3
  2750. */
  2751. fromArray(array: FloatArray, index?: number): Vector2;
  2752. /**
  2753. * Copy the current vector to an array
  2754. * @returns a new array with 2 elements: the Vector2 coordinates.
  2755. */
  2756. asArray(): number[];
  2757. /**
  2758. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2759. * @param source defines the source Vector2
  2760. * @returns the current updated Vector2
  2761. */
  2762. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2763. /**
  2764. * Sets the Vector2 coordinates with the given floats
  2765. * @param x defines the first coordinate
  2766. * @param y defines the second coordinate
  2767. * @returns the current updated Vector2
  2768. */
  2769. copyFromFloats(x: number, y: number): Vector2;
  2770. /**
  2771. * Sets the Vector2 coordinates with the given floats
  2772. * @param x defines the first coordinate
  2773. * @param y defines the second coordinate
  2774. * @returns the current updated Vector2
  2775. */
  2776. set(x: number, y: number): Vector2;
  2777. /**
  2778. * Add another vector with the current one
  2779. * @param otherVector defines the other vector
  2780. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2781. */
  2782. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2783. /**
  2784. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2785. * @param otherVector defines the other vector
  2786. * @param result defines the target vector
  2787. * @returns the unmodified current Vector2
  2788. */
  2789. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2790. /**
  2791. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2792. * @param otherVector defines the other vector
  2793. * @returns the current updated Vector2
  2794. */
  2795. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2796. /**
  2797. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2798. * @param otherVector defines the other vector
  2799. * @returns a new Vector2
  2800. */
  2801. addVector3(otherVector: Vector3): Vector2;
  2802. /**
  2803. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2804. * @param otherVector defines the other vector
  2805. * @returns a new Vector2
  2806. */
  2807. subtract(otherVector: Vector2): Vector2;
  2808. /**
  2809. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2810. * @param otherVector defines the other vector
  2811. * @param result defines the target vector
  2812. * @returns the unmodified current Vector2
  2813. */
  2814. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2815. /**
  2816. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2817. * @param otherVector defines the other vector
  2818. * @returns the current updated Vector2
  2819. */
  2820. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2821. /**
  2822. * Multiplies in place the current Vector2 coordinates by the given ones
  2823. * @param otherVector defines the other vector
  2824. * @returns the current updated Vector2
  2825. */
  2826. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2827. /**
  2828. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2829. * @param otherVector defines the other vector
  2830. * @returns a new Vector2
  2831. */
  2832. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2833. /**
  2834. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2835. * @param otherVector defines the other vector
  2836. * @param result defines the target vector
  2837. * @returns the unmodified current Vector2
  2838. */
  2839. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2840. /**
  2841. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2842. * @param x defines the first coordinate
  2843. * @param y defines the second coordinate
  2844. * @returns a new Vector2
  2845. */
  2846. multiplyByFloats(x: number, y: number): Vector2;
  2847. /**
  2848. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2849. * @param otherVector defines the other vector
  2850. * @returns a new Vector2
  2851. */
  2852. divide(otherVector: Vector2): Vector2;
  2853. /**
  2854. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2855. * @param otherVector defines the other vector
  2856. * @param result defines the target vector
  2857. * @returns the unmodified current Vector2
  2858. */
  2859. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2860. /**
  2861. * Divides the current Vector2 coordinates by the given ones
  2862. * @param otherVector defines the other vector
  2863. * @returns the current updated Vector2
  2864. */
  2865. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2866. /**
  2867. * Gets a new Vector2 with current Vector2 negated coordinates
  2868. * @returns a new Vector2
  2869. */
  2870. negate(): Vector2;
  2871. /**
  2872. * Negate this vector in place
  2873. * @returns this
  2874. */
  2875. negateInPlace(): Vector2;
  2876. /**
  2877. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2878. * @param result defines the Vector3 object where to store the result
  2879. * @returns the current Vector2
  2880. */
  2881. negateToRef(result: Vector2): Vector2;
  2882. /**
  2883. * Multiply the Vector2 coordinates by scale
  2884. * @param scale defines the scaling factor
  2885. * @returns the current updated Vector2
  2886. */
  2887. scaleInPlace(scale: number): Vector2;
  2888. /**
  2889. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2890. * @param scale defines the scaling factor
  2891. * @returns a new Vector2
  2892. */
  2893. scale(scale: number): Vector2;
  2894. /**
  2895. * Scale the current Vector2 values by a factor to a given Vector2
  2896. * @param scale defines the scale factor
  2897. * @param result defines the Vector2 object where to store the result
  2898. * @returns the unmodified current Vector2
  2899. */
  2900. scaleToRef(scale: number, result: Vector2): Vector2;
  2901. /**
  2902. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2903. * @param scale defines the scale factor
  2904. * @param result defines the Vector2 object where to store the result
  2905. * @returns the unmodified current Vector2
  2906. */
  2907. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2908. /**
  2909. * Gets a boolean if two vectors are equals
  2910. * @param otherVector defines the other vector
  2911. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2912. */
  2913. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2914. /**
  2915. * Gets a boolean if two vectors are equals (using an epsilon value)
  2916. * @param otherVector defines the other vector
  2917. * @param epsilon defines the minimal distance to consider equality
  2918. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2919. */
  2920. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2921. /**
  2922. * Gets a new Vector2 from current Vector2 floored values
  2923. * @returns a new Vector2
  2924. */
  2925. floor(): Vector2;
  2926. /**
  2927. * Gets a new Vector2 from current Vector2 floored values
  2928. * @returns a new Vector2
  2929. */
  2930. fract(): Vector2;
  2931. /**
  2932. * Gets the length of the vector
  2933. * @returns the vector length (float)
  2934. */
  2935. length(): number;
  2936. /**
  2937. * Gets the vector squared length
  2938. * @returns the vector squared length (float)
  2939. */
  2940. lengthSquared(): number;
  2941. /**
  2942. * Normalize the vector
  2943. * @returns the current updated Vector2
  2944. */
  2945. normalize(): Vector2;
  2946. /**
  2947. * Gets a new Vector2 copied from the Vector2
  2948. * @returns a new Vector2
  2949. */
  2950. clone(): Vector2;
  2951. /**
  2952. * Gets a new Vector2(0, 0)
  2953. * @returns a new Vector2
  2954. */
  2955. static Zero(): Vector2;
  2956. /**
  2957. * Gets a new Vector2(1, 1)
  2958. * @returns a new Vector2
  2959. */
  2960. static One(): Vector2;
  2961. /**
  2962. * Gets a new Vector2 set from the given index element of the given array
  2963. * @param array defines the data source
  2964. * @param offset defines the offset in the data source
  2965. * @returns a new Vector2
  2966. */
  2967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2968. /**
  2969. * Sets "result" from the given index element of the given array
  2970. * @param array defines the data source
  2971. * @param offset defines the offset in the data source
  2972. * @param result defines the target vector
  2973. */
  2974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2975. /**
  2976. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2977. * @param value1 defines 1st point of control
  2978. * @param value2 defines 2nd point of control
  2979. * @param value3 defines 3rd point of control
  2980. * @param value4 defines 4th point of control
  2981. * @param amount defines the interpolation factor
  2982. * @returns a new Vector2
  2983. */
  2984. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2985. /**
  2986. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2987. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2988. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2989. * @param value defines the value to clamp
  2990. * @param min defines the lower limit
  2991. * @param max defines the upper limit
  2992. * @returns a new Vector2
  2993. */
  2994. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2995. /**
  2996. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2997. * @param value1 defines the 1st control point
  2998. * @param tangent1 defines the outgoing tangent
  2999. * @param value2 defines the 2nd control point
  3000. * @param tangent2 defines the incoming tangent
  3001. * @param amount defines the interpolation factor
  3002. * @returns a new Vector2
  3003. */
  3004. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3005. /**
  3006. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3007. * @param start defines the start vector
  3008. * @param end defines the end vector
  3009. * @param amount defines the interpolation factor
  3010. * @returns a new Vector2
  3011. */
  3012. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3013. /**
  3014. * Gets the dot product of the vector "left" and the vector "right"
  3015. * @param left defines first vector
  3016. * @param right defines second vector
  3017. * @returns the dot product (float)
  3018. */
  3019. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3020. /**
  3021. * Returns a new Vector2 equal to the normalized given vector
  3022. * @param vector defines the vector to normalize
  3023. * @returns a new Vector2
  3024. */
  3025. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3026. /**
  3027. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3028. * @param left defines 1st vector
  3029. * @param right defines 2nd vector
  3030. * @returns a new Vector2
  3031. */
  3032. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3033. /**
  3034. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3035. * @param left defines 1st vector
  3036. * @param right defines 2nd vector
  3037. * @returns a new Vector2
  3038. */
  3039. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3040. /**
  3041. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3042. * @param vector defines the vector to transform
  3043. * @param transformation defines the matrix to apply
  3044. * @returns a new Vector2
  3045. */
  3046. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3047. /**
  3048. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3049. * @param vector defines the vector to transform
  3050. * @param transformation defines the matrix to apply
  3051. * @param result defines the target vector
  3052. */
  3053. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3054. /**
  3055. * Determines if a given vector is included in a triangle
  3056. * @param p defines the vector to test
  3057. * @param p0 defines 1st triangle point
  3058. * @param p1 defines 2nd triangle point
  3059. * @param p2 defines 3rd triangle point
  3060. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3061. */
  3062. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3063. /**
  3064. * Gets the distance between the vectors "value1" and "value2"
  3065. * @param value1 defines first vector
  3066. * @param value2 defines second vector
  3067. * @returns the distance between vectors
  3068. */
  3069. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3070. /**
  3071. * Returns the squared distance between the vectors "value1" and "value2"
  3072. * @param value1 defines first vector
  3073. * @param value2 defines second vector
  3074. * @returns the squared distance between vectors
  3075. */
  3076. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3077. /**
  3078. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3079. * @param value1 defines first vector
  3080. * @param value2 defines second vector
  3081. * @returns a new Vector2
  3082. */
  3083. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3084. /**
  3085. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3086. * @param value1 defines first vector
  3087. * @param value2 defines second vector
  3088. * @param ref defines third vector
  3089. * @returns ref
  3090. */
  3091. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3092. /**
  3093. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3094. * @param p defines the middle point
  3095. * @param segA defines one point of the segment
  3096. * @param segB defines the other point of the segment
  3097. * @returns the shortest distance
  3098. */
  3099. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3100. }
  3101. /**
  3102. * Class used to store (x,y,z) vector representation
  3103. * A Vector3 is the main object used in 3D geometry
  3104. * It can represent etiher the coordinates of a point the space, either a direction
  3105. * Reminder: js uses a left handed forward facing system
  3106. */
  3107. export class Vector3 {
  3108. private static _UpReadOnly;
  3109. private static _ZeroReadOnly;
  3110. /** @hidden */
  3111. _x: number;
  3112. /** @hidden */
  3113. _y: number;
  3114. /** @hidden */
  3115. _z: number;
  3116. /** @hidden */
  3117. _isDirty: boolean;
  3118. /** Gets or sets the x coordinate */
  3119. get x(): number;
  3120. set x(value: number);
  3121. /** Gets or sets the y coordinate */
  3122. get y(): number;
  3123. set y(value: number);
  3124. /** Gets or sets the z coordinate */
  3125. get z(): number;
  3126. set z(value: number);
  3127. /**
  3128. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3129. * @param x defines the first coordinates (on X axis)
  3130. * @param y defines the second coordinates (on Y axis)
  3131. * @param z defines the third coordinates (on Z axis)
  3132. */
  3133. constructor(x?: number, y?: number, z?: number);
  3134. /**
  3135. * Creates a string representation of the Vector3
  3136. * @returns a string with the Vector3 coordinates.
  3137. */
  3138. toString(): string;
  3139. /**
  3140. * Gets the class name
  3141. * @returns the string "Vector3"
  3142. */
  3143. getClassName(): string;
  3144. /**
  3145. * Creates the Vector3 hash code
  3146. * @returns a number which tends to be unique between Vector3 instances
  3147. */
  3148. getHashCode(): number;
  3149. /**
  3150. * Creates an array containing three elements : the coordinates of the Vector3
  3151. * @returns a new array of numbers
  3152. */
  3153. asArray(): number[];
  3154. /**
  3155. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3156. * @param array defines the destination array
  3157. * @param index defines the offset in the destination array
  3158. * @returns the current Vector3
  3159. */
  3160. toArray(array: FloatArray, index?: number): Vector3;
  3161. /**
  3162. * Update the current vector from an array
  3163. * @param array defines the destination array
  3164. * @param index defines the offset in the destination array
  3165. * @returns the current Vector3
  3166. */
  3167. fromArray(array: FloatArray, index?: number): Vector3;
  3168. /**
  3169. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3170. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3171. */
  3172. toQuaternion(): Quaternion;
  3173. /**
  3174. * Adds the given vector to the current Vector3
  3175. * @param otherVector defines the second operand
  3176. * @returns the current updated Vector3
  3177. */
  3178. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3179. /**
  3180. * Adds the given coordinates to the current Vector3
  3181. * @param x defines the x coordinate of the operand
  3182. * @param y defines the y coordinate of the operand
  3183. * @param z defines the z coordinate of the operand
  3184. * @returns the current updated Vector3
  3185. */
  3186. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3187. /**
  3188. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3189. * @param otherVector defines the second operand
  3190. * @returns the resulting Vector3
  3191. */
  3192. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3195. * @param otherVector defines the second operand
  3196. * @param result defines the Vector3 object where to store the result
  3197. * @returns the current Vector3
  3198. */
  3199. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3200. /**
  3201. * Subtract the given vector from the current Vector3
  3202. * @param otherVector defines the second operand
  3203. * @returns the current updated Vector3
  3204. */
  3205. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3208. * @param otherVector defines the second operand
  3209. * @returns the resulting Vector3
  3210. */
  3211. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3212. /**
  3213. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3214. * @param otherVector defines the second operand
  3215. * @param result defines the Vector3 object where to store the result
  3216. * @returns the current Vector3
  3217. */
  3218. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3219. /**
  3220. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3221. * @param x defines the x coordinate of the operand
  3222. * @param y defines the y coordinate of the operand
  3223. * @param z defines the z coordinate of the operand
  3224. * @returns the resulting Vector3
  3225. */
  3226. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3227. /**
  3228. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3229. * @param x defines the x coordinate of the operand
  3230. * @param y defines the y coordinate of the operand
  3231. * @param z defines the z coordinate of the operand
  3232. * @param result defines the Vector3 object where to store the result
  3233. * @returns the current Vector3
  3234. */
  3235. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3236. /**
  3237. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3238. * @returns a new Vector3
  3239. */
  3240. negate(): Vector3;
  3241. /**
  3242. * Negate this vector in place
  3243. * @returns this
  3244. */
  3245. negateInPlace(): Vector3;
  3246. /**
  3247. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3248. * @param result defines the Vector3 object where to store the result
  3249. * @returns the current Vector3
  3250. */
  3251. negateToRef(result: Vector3): Vector3;
  3252. /**
  3253. * Multiplies the Vector3 coordinates by the float "scale"
  3254. * @param scale defines the multiplier factor
  3255. * @returns the current updated Vector3
  3256. */
  3257. scaleInPlace(scale: number): Vector3;
  3258. /**
  3259. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3260. * @param scale defines the multiplier factor
  3261. * @returns a new Vector3
  3262. */
  3263. scale(scale: number): Vector3;
  3264. /**
  3265. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3266. * @param scale defines the multiplier factor
  3267. * @param result defines the Vector3 object where to store the result
  3268. * @returns the current Vector3
  3269. */
  3270. scaleToRef(scale: number, result: Vector3): Vector3;
  3271. /**
  3272. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3273. * @param scale defines the scale factor
  3274. * @param result defines the Vector3 object where to store the result
  3275. * @returns the unmodified current Vector3
  3276. */
  3277. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3278. /**
  3279. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3280. * @param origin defines the origin of the projection ray
  3281. * @param plane defines the plane to project to
  3282. * @returns the projected vector3
  3283. */
  3284. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3285. /**
  3286. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3287. * @param origin defines the origin of the projection ray
  3288. * @param plane defines the plane to project to
  3289. * @param result defines the Vector3 where to store the result
  3290. */
  3291. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3292. /**
  3293. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3294. * @param otherVector defines the second operand
  3295. * @returns true if both vectors are equals
  3296. */
  3297. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3298. /**
  3299. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3300. * @param otherVector defines the second operand
  3301. * @param epsilon defines the minimal distance to define values as equals
  3302. * @returns true if both vectors are distant less than epsilon
  3303. */
  3304. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3305. /**
  3306. * Returns true if the current Vector3 coordinates equals the given floats
  3307. * @param x defines the x coordinate of the operand
  3308. * @param y defines the y coordinate of the operand
  3309. * @param z defines the z coordinate of the operand
  3310. * @returns true if both vectors are equals
  3311. */
  3312. equalsToFloats(x: number, y: number, z: number): boolean;
  3313. /**
  3314. * Multiplies the current Vector3 coordinates by the given ones
  3315. * @param otherVector defines the second operand
  3316. * @returns the current updated Vector3
  3317. */
  3318. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3319. /**
  3320. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3321. * @param otherVector defines the second operand
  3322. * @returns the new Vector3
  3323. */
  3324. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3325. /**
  3326. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3327. * @param otherVector defines the second operand
  3328. * @param result defines the Vector3 object where to store the result
  3329. * @returns the current Vector3
  3330. */
  3331. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3332. /**
  3333. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3334. * @param x defines the x coordinate of the operand
  3335. * @param y defines the y coordinate of the operand
  3336. * @param z defines the z coordinate of the operand
  3337. * @returns the new Vector3
  3338. */
  3339. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3340. /**
  3341. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3342. * @param otherVector defines the second operand
  3343. * @returns the new Vector3
  3344. */
  3345. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3346. /**
  3347. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3348. * @param otherVector defines the second operand
  3349. * @param result defines the Vector3 object where to store the result
  3350. * @returns the current Vector3
  3351. */
  3352. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3353. /**
  3354. * Divides the current Vector3 coordinates by the given ones.
  3355. * @param otherVector defines the second operand
  3356. * @returns the current updated Vector3
  3357. */
  3358. divideInPlace(otherVector: Vector3): Vector3;
  3359. /**
  3360. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3361. * @param other defines the second operand
  3362. * @returns the current updated Vector3
  3363. */
  3364. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3365. /**
  3366. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3367. * @param other defines the second operand
  3368. * @returns the current updated Vector3
  3369. */
  3370. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3371. /**
  3372. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3373. * @param x defines the x coordinate of the operand
  3374. * @param y defines the y coordinate of the operand
  3375. * @param z defines the z coordinate of the operand
  3376. * @returns the current updated Vector3
  3377. */
  3378. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3379. /**
  3380. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3381. * @param x defines the x coordinate of the operand
  3382. * @param y defines the y coordinate of the operand
  3383. * @param z defines the z coordinate of the operand
  3384. * @returns the current updated Vector3
  3385. */
  3386. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3387. /**
  3388. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3389. * Check if is non uniform within a certain amount of decimal places to account for this
  3390. * @param epsilon the amount the values can differ
  3391. * @returns if the the vector is non uniform to a certain number of decimal places
  3392. */
  3393. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3394. /**
  3395. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3396. */
  3397. get isNonUniform(): boolean;
  3398. /**
  3399. * Gets a new Vector3 from current Vector3 floored values
  3400. * @returns a new Vector3
  3401. */
  3402. floor(): Vector3;
  3403. /**
  3404. * Gets a new Vector3 from current Vector3 floored values
  3405. * @returns a new Vector3
  3406. */
  3407. fract(): Vector3;
  3408. /**
  3409. * Gets the length of the Vector3
  3410. * @returns the length of the Vector3
  3411. */
  3412. length(): number;
  3413. /**
  3414. * Gets the squared length of the Vector3
  3415. * @returns squared length of the Vector3
  3416. */
  3417. lengthSquared(): number;
  3418. /**
  3419. * Normalize the current Vector3.
  3420. * Please note that this is an in place operation.
  3421. * @returns the current updated Vector3
  3422. */
  3423. normalize(): Vector3;
  3424. /**
  3425. * Reorders the x y z properties of the vector in place
  3426. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3427. * @returns the current updated vector
  3428. */
  3429. reorderInPlace(order: string): this;
  3430. /**
  3431. * Rotates the vector around 0,0,0 by a quaternion
  3432. * @param quaternion the rotation quaternion
  3433. * @param result vector to store the result
  3434. * @returns the resulting vector
  3435. */
  3436. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3437. /**
  3438. * Rotates a vector around a given point
  3439. * @param quaternion the rotation quaternion
  3440. * @param point the point to rotate around
  3441. * @param result vector to store the result
  3442. * @returns the resulting vector
  3443. */
  3444. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3445. /**
  3446. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3447. * The cross product is then orthogonal to both current and "other"
  3448. * @param other defines the right operand
  3449. * @returns the cross product
  3450. */
  3451. cross(other: Vector3): Vector3;
  3452. /**
  3453. * Normalize the current Vector3 with the given input length.
  3454. * Please note that this is an in place operation.
  3455. * @param len the length of the vector
  3456. * @returns the current updated Vector3
  3457. */
  3458. normalizeFromLength(len: number): Vector3;
  3459. /**
  3460. * Normalize the current Vector3 to a new vector
  3461. * @returns the new Vector3
  3462. */
  3463. normalizeToNew(): Vector3;
  3464. /**
  3465. * Normalize the current Vector3 to the reference
  3466. * @param reference define the Vector3 to update
  3467. * @returns the updated Vector3
  3468. */
  3469. normalizeToRef(reference: Vector3): Vector3;
  3470. /**
  3471. * Creates a new Vector3 copied from the current Vector3
  3472. * @returns the new Vector3
  3473. */
  3474. clone(): Vector3;
  3475. /**
  3476. * Copies the given vector coordinates to the current Vector3 ones
  3477. * @param source defines the source Vector3
  3478. * @returns the current updated Vector3
  3479. */
  3480. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3481. /**
  3482. * Copies the given floats to the current Vector3 coordinates
  3483. * @param x defines the x coordinate of the operand
  3484. * @param y defines the y coordinate of the operand
  3485. * @param z defines the z coordinate of the operand
  3486. * @returns the current updated Vector3
  3487. */
  3488. copyFromFloats(x: number, y: number, z: number): Vector3;
  3489. /**
  3490. * Copies the given floats to the current Vector3 coordinates
  3491. * @param x defines the x coordinate of the operand
  3492. * @param y defines the y coordinate of the operand
  3493. * @param z defines the z coordinate of the operand
  3494. * @returns the current updated Vector3
  3495. */
  3496. set(x: number, y: number, z: number): Vector3;
  3497. /**
  3498. * Copies the given float to the current Vector3 coordinates
  3499. * @param v defines the x, y and z coordinates of the operand
  3500. * @returns the current updated Vector3
  3501. */
  3502. setAll(v: number): Vector3;
  3503. /**
  3504. * Get the clip factor between two vectors
  3505. * @param vector0 defines the first operand
  3506. * @param vector1 defines the second operand
  3507. * @param axis defines the axis to use
  3508. * @param size defines the size along the axis
  3509. * @returns the clip factor
  3510. */
  3511. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3512. /**
  3513. * Get angle between two vectors
  3514. * @param vector0 angle between vector0 and vector1
  3515. * @param vector1 angle between vector0 and vector1
  3516. * @param normal direction of the normal
  3517. * @return the angle between vector0 and vector1
  3518. */
  3519. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3520. /**
  3521. * Returns a new Vector3 set from the index "offset" of the given array
  3522. * @param array defines the source array
  3523. * @param offset defines the offset in the source array
  3524. * @returns the new Vector3
  3525. */
  3526. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3527. /**
  3528. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3529. * @param array defines the source array
  3530. * @param offset defines the offset in the source array
  3531. * @returns the new Vector3
  3532. * @deprecated Please use FromArray instead.
  3533. */
  3534. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3535. /**
  3536. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3537. * @param array defines the source array
  3538. * @param offset defines the offset in the source array
  3539. * @param result defines the Vector3 where to store the result
  3540. */
  3541. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3542. /**
  3543. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3544. * @param array defines the source array
  3545. * @param offset defines the offset in the source array
  3546. * @param result defines the Vector3 where to store the result
  3547. * @deprecated Please use FromArrayToRef instead.
  3548. */
  3549. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3550. /**
  3551. * Sets the given vector "result" with the given floats.
  3552. * @param x defines the x coordinate of the source
  3553. * @param y defines the y coordinate of the source
  3554. * @param z defines the z coordinate of the source
  3555. * @param result defines the Vector3 where to store the result
  3556. */
  3557. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3558. /**
  3559. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3560. * @returns a new empty Vector3
  3561. */
  3562. static Zero(): Vector3;
  3563. /**
  3564. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3565. * @returns a new unit Vector3
  3566. */
  3567. static One(): Vector3;
  3568. /**
  3569. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3570. * @returns a new up Vector3
  3571. */
  3572. static Up(): Vector3;
  3573. /**
  3574. * Gets a up Vector3 that must not be updated
  3575. */
  3576. static get UpReadOnly(): DeepImmutable<Vector3>;
  3577. /**
  3578. * Gets a zero Vector3 that must not be updated
  3579. */
  3580. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3581. /**
  3582. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3583. * @returns a new down Vector3
  3584. */
  3585. static Down(): Vector3;
  3586. /**
  3587. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3588. * @param rightHandedSystem is the scene right-handed (negative z)
  3589. * @returns a new forward Vector3
  3590. */
  3591. static Forward(rightHandedSystem?: boolean): Vector3;
  3592. /**
  3593. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3594. * @param rightHandedSystem is the scene right-handed (negative-z)
  3595. * @returns a new forward Vector3
  3596. */
  3597. static Backward(rightHandedSystem?: boolean): Vector3;
  3598. /**
  3599. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3600. * @returns a new right Vector3
  3601. */
  3602. static Right(): Vector3;
  3603. /**
  3604. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3605. * @returns a new left Vector3
  3606. */
  3607. static Left(): Vector3;
  3608. /**
  3609. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3610. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3611. * @param vector defines the Vector3 to transform
  3612. * @param transformation defines the transformation matrix
  3613. * @returns the transformed Vector3
  3614. */
  3615. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3616. /**
  3617. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3618. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3619. * @param vector defines the Vector3 to transform
  3620. * @param transformation defines the transformation matrix
  3621. * @param result defines the Vector3 where to store the result
  3622. */
  3623. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3624. /**
  3625. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3626. * This method computes tranformed coordinates only, not transformed direction vectors
  3627. * @param x define the x coordinate of the source vector
  3628. * @param y define the y coordinate of the source vector
  3629. * @param z define the z coordinate of the source vector
  3630. * @param transformation defines the transformation matrix
  3631. * @param result defines the Vector3 where to store the result
  3632. */
  3633. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3634. /**
  3635. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3636. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3637. * @param vector defines the Vector3 to transform
  3638. * @param transformation defines the transformation matrix
  3639. * @returns the new Vector3
  3640. */
  3641. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3642. /**
  3643. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3644. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3645. * @param vector defines the Vector3 to transform
  3646. * @param transformation defines the transformation matrix
  3647. * @param result defines the Vector3 where to store the result
  3648. */
  3649. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3650. /**
  3651. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3652. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3653. * @param x define the x coordinate of the source vector
  3654. * @param y define the y coordinate of the source vector
  3655. * @param z define the z coordinate of the source vector
  3656. * @param transformation defines the transformation matrix
  3657. * @param result defines the Vector3 where to store the result
  3658. */
  3659. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3660. /**
  3661. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3662. * @param value1 defines the first control point
  3663. * @param value2 defines the second control point
  3664. * @param value3 defines the third control point
  3665. * @param value4 defines the fourth control point
  3666. * @param amount defines the amount on the spline to use
  3667. * @returns the new Vector3
  3668. */
  3669. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3670. /**
  3671. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3672. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3673. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3674. * @param value defines the current value
  3675. * @param min defines the lower range value
  3676. * @param max defines the upper range value
  3677. * @returns the new Vector3
  3678. */
  3679. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3680. /**
  3681. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3682. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3683. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3684. * @param value defines the current value
  3685. * @param min defines the lower range value
  3686. * @param max defines the upper range value
  3687. * @param result defines the Vector3 where to store the result
  3688. */
  3689. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3690. /**
  3691. * Checks if a given vector is inside a specific range
  3692. * @param v defines the vector to test
  3693. * @param min defines the minimum range
  3694. * @param max defines the maximum range
  3695. */
  3696. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3697. /**
  3698. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3699. * @param value1 defines the first control point
  3700. * @param tangent1 defines the first tangent vector
  3701. * @param value2 defines the second control point
  3702. * @param tangent2 defines the second tangent vector
  3703. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3704. * @returns the new Vector3
  3705. */
  3706. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3707. /**
  3708. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3709. * @param start defines the start value
  3710. * @param end defines the end value
  3711. * @param amount max defines amount between both (between 0 and 1)
  3712. * @returns the new Vector3
  3713. */
  3714. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3715. /**
  3716. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3717. * @param start defines the start value
  3718. * @param end defines the end value
  3719. * @param amount max defines amount between both (between 0 and 1)
  3720. * @param result defines the Vector3 where to store the result
  3721. */
  3722. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3723. /**
  3724. * Returns the dot product (float) between the vectors "left" and "right"
  3725. * @param left defines the left operand
  3726. * @param right defines the right operand
  3727. * @returns the dot product
  3728. */
  3729. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3730. /**
  3731. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3732. * The cross product is then orthogonal to both "left" and "right"
  3733. * @param left defines the left operand
  3734. * @param right defines the right operand
  3735. * @returns the cross product
  3736. */
  3737. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3738. /**
  3739. * Sets the given vector "result" with the cross product of "left" and "right"
  3740. * The cross product is then orthogonal to both "left" and "right"
  3741. * @param left defines the left operand
  3742. * @param right defines the right operand
  3743. * @param result defines the Vector3 where to store the result
  3744. */
  3745. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3746. /**
  3747. * Returns a new Vector3 as the normalization of the given vector
  3748. * @param vector defines the Vector3 to normalize
  3749. * @returns the new Vector3
  3750. */
  3751. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3752. /**
  3753. * Sets the given vector "result" with the normalization of the given first vector
  3754. * @param vector defines the Vector3 to normalize
  3755. * @param result defines the Vector3 where to store the result
  3756. */
  3757. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3758. /**
  3759. * Project a Vector3 onto screen space
  3760. * @param vector defines the Vector3 to project
  3761. * @param world defines the world matrix to use
  3762. * @param transform defines the transform (view x projection) matrix to use
  3763. * @param viewport defines the screen viewport to use
  3764. * @returns the new Vector3
  3765. */
  3766. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3767. /**
  3768. * Project a Vector3 onto screen space to reference
  3769. * @param vector defines the Vector3 to project
  3770. * @param world defines the world matrix to use
  3771. * @param transform defines the transform (view x projection) matrix to use
  3772. * @param viewport defines the screen viewport to use
  3773. * @param result the vector in which the screen space will be stored
  3774. * @returns the new Vector3
  3775. */
  3776. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3777. /** @hidden */
  3778. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3779. /**
  3780. * Unproject from screen space to object space
  3781. * @param source defines the screen space Vector3 to use
  3782. * @param viewportWidth defines the current width of the viewport
  3783. * @param viewportHeight defines the current height of the viewport
  3784. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3785. * @param transform defines the transform (view x projection) matrix to use
  3786. * @returns the new Vector3
  3787. */
  3788. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3789. /**
  3790. * Unproject from screen space to object space
  3791. * @param source defines the screen space Vector3 to use
  3792. * @param viewportWidth defines the current width of the viewport
  3793. * @param viewportHeight defines the current height of the viewport
  3794. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3795. * @param view defines the view matrix to use
  3796. * @param projection defines the projection matrix to use
  3797. * @returns the new Vector3
  3798. */
  3799. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3800. /**
  3801. * Unproject from screen space to object space
  3802. * @param source defines the screen space Vector3 to use
  3803. * @param viewportWidth defines the current width of the viewport
  3804. * @param viewportHeight defines the current height of the viewport
  3805. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3806. * @param view defines the view matrix to use
  3807. * @param projection defines the projection matrix to use
  3808. * @param result defines the Vector3 where to store the result
  3809. */
  3810. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3811. /**
  3812. * Unproject from screen space to object space
  3813. * @param sourceX defines the screen space x coordinate to use
  3814. * @param sourceY defines the screen space y coordinate to use
  3815. * @param sourceZ defines the screen space z coordinate to use
  3816. * @param viewportWidth defines the current width of the viewport
  3817. * @param viewportHeight defines the current height of the viewport
  3818. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3819. * @param view defines the view matrix to use
  3820. * @param projection defines the projection matrix to use
  3821. * @param result defines the Vector3 where to store the result
  3822. */
  3823. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3824. /**
  3825. * Gets the minimal coordinate values between two Vector3
  3826. * @param left defines the first operand
  3827. * @param right defines the second operand
  3828. * @returns the new Vector3
  3829. */
  3830. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3831. /**
  3832. * Gets the maximal coordinate values between two Vector3
  3833. * @param left defines the first operand
  3834. * @param right defines the second operand
  3835. * @returns the new Vector3
  3836. */
  3837. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3838. /**
  3839. * Returns the distance between the vectors "value1" and "value2"
  3840. * @param value1 defines the first operand
  3841. * @param value2 defines the second operand
  3842. * @returns the distance
  3843. */
  3844. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3845. /**
  3846. * Returns the squared distance between the vectors "value1" and "value2"
  3847. * @param value1 defines the first operand
  3848. * @param value2 defines the second operand
  3849. * @returns the squared distance
  3850. */
  3851. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3852. /**
  3853. * Returns a new Vector3 located at the center between "value1" and "value2"
  3854. * @param value1 defines the first operand
  3855. * @param value2 defines the second operand
  3856. * @returns the new Vector3
  3857. */
  3858. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3859. /**
  3860. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3861. * @param value1 defines first vector
  3862. * @param value2 defines second vector
  3863. * @param ref defines third vector
  3864. * @returns ref
  3865. */
  3866. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3867. /**
  3868. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3869. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3870. * to something in order to rotate it from its local system to the given target system
  3871. * Note: axis1, axis2 and axis3 are normalized during this operation
  3872. * @param axis1 defines the first axis
  3873. * @param axis2 defines the second axis
  3874. * @param axis3 defines the third axis
  3875. * @returns a new Vector3
  3876. */
  3877. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3878. /**
  3879. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3880. * @param axis1 defines the first axis
  3881. * @param axis2 defines the second axis
  3882. * @param axis3 defines the third axis
  3883. * @param ref defines the Vector3 where to store the result
  3884. */
  3885. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3886. }
  3887. /**
  3888. * Vector4 class created for EulerAngle class conversion to Quaternion
  3889. */
  3890. export class Vector4 {
  3891. /** x value of the vector */
  3892. x: number;
  3893. /** y value of the vector */
  3894. y: number;
  3895. /** z value of the vector */
  3896. z: number;
  3897. /** w value of the vector */
  3898. w: number;
  3899. /**
  3900. * Creates a Vector4 object from the given floats.
  3901. * @param x x value of the vector
  3902. * @param y y value of the vector
  3903. * @param z z value of the vector
  3904. * @param w w value of the vector
  3905. */
  3906. constructor(
  3907. /** x value of the vector */
  3908. x: number,
  3909. /** y value of the vector */
  3910. y: number,
  3911. /** z value of the vector */
  3912. z: number,
  3913. /** w value of the vector */
  3914. w: number);
  3915. /**
  3916. * Returns the string with the Vector4 coordinates.
  3917. * @returns a string containing all the vector values
  3918. */
  3919. toString(): string;
  3920. /**
  3921. * Returns the string "Vector4".
  3922. * @returns "Vector4"
  3923. */
  3924. getClassName(): string;
  3925. /**
  3926. * Returns the Vector4 hash code.
  3927. * @returns a unique hash code
  3928. */
  3929. getHashCode(): number;
  3930. /**
  3931. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3932. * @returns the resulting array
  3933. */
  3934. asArray(): number[];
  3935. /**
  3936. * Populates the given array from the given index with the Vector4 coordinates.
  3937. * @param array array to populate
  3938. * @param index index of the array to start at (default: 0)
  3939. * @returns the Vector4.
  3940. */
  3941. toArray(array: FloatArray, index?: number): Vector4;
  3942. /**
  3943. * Update the current vector from an array
  3944. * @param array defines the destination array
  3945. * @param index defines the offset in the destination array
  3946. * @returns the current Vector3
  3947. */
  3948. fromArray(array: FloatArray, index?: number): Vector4;
  3949. /**
  3950. * Adds the given vector to the current Vector4.
  3951. * @param otherVector the vector to add
  3952. * @returns the updated Vector4.
  3953. */
  3954. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3955. /**
  3956. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3957. * @param otherVector the vector to add
  3958. * @returns the resulting vector
  3959. */
  3960. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3961. /**
  3962. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3963. * @param otherVector the vector to add
  3964. * @param result the vector to store the result
  3965. * @returns the current Vector4.
  3966. */
  3967. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3968. /**
  3969. * Subtract in place the given vector from the current Vector4.
  3970. * @param otherVector the vector to subtract
  3971. * @returns the updated Vector4.
  3972. */
  3973. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3974. /**
  3975. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3976. * @param otherVector the vector to add
  3977. * @returns the new vector with the result
  3978. */
  3979. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3980. /**
  3981. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3982. * @param otherVector the vector to subtract
  3983. * @param result the vector to store the result
  3984. * @returns the current Vector4.
  3985. */
  3986. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3987. /**
  3988. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3989. */
  3990. /**
  3991. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3992. * @param x value to subtract
  3993. * @param y value to subtract
  3994. * @param z value to subtract
  3995. * @param w value to subtract
  3996. * @returns new vector containing the result
  3997. */
  3998. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3999. /**
  4000. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4001. * @param x value to subtract
  4002. * @param y value to subtract
  4003. * @param z value to subtract
  4004. * @param w value to subtract
  4005. * @param result the vector to store the result in
  4006. * @returns the current Vector4.
  4007. */
  4008. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4009. /**
  4010. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4011. * @returns a new vector with the negated values
  4012. */
  4013. negate(): Vector4;
  4014. /**
  4015. * Negate this vector in place
  4016. * @returns this
  4017. */
  4018. negateInPlace(): Vector4;
  4019. /**
  4020. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4021. * @param result defines the Vector3 object where to store the result
  4022. * @returns the current Vector4
  4023. */
  4024. negateToRef(result: Vector4): Vector4;
  4025. /**
  4026. * Multiplies the current Vector4 coordinates by scale (float).
  4027. * @param scale the number to scale with
  4028. * @returns the updated Vector4.
  4029. */
  4030. scaleInPlace(scale: number): Vector4;
  4031. /**
  4032. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4033. * @param scale the number to scale with
  4034. * @returns a new vector with the result
  4035. */
  4036. scale(scale: number): Vector4;
  4037. /**
  4038. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4039. * @param scale the number to scale with
  4040. * @param result a vector to store the result in
  4041. * @returns the current Vector4.
  4042. */
  4043. scaleToRef(scale: number, result: Vector4): Vector4;
  4044. /**
  4045. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4046. * @param scale defines the scale factor
  4047. * @param result defines the Vector4 object where to store the result
  4048. * @returns the unmodified current Vector4
  4049. */
  4050. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4051. /**
  4052. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4053. * @param otherVector the vector to compare against
  4054. * @returns true if they are equal
  4055. */
  4056. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4057. /**
  4058. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4059. * @param otherVector vector to compare against
  4060. * @param epsilon (Default: very small number)
  4061. * @returns true if they are equal
  4062. */
  4063. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4064. /**
  4065. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4066. * @param x x value to compare against
  4067. * @param y y value to compare against
  4068. * @param z z value to compare against
  4069. * @param w w value to compare against
  4070. * @returns true if equal
  4071. */
  4072. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4073. /**
  4074. * Multiplies in place the current Vector4 by the given one.
  4075. * @param otherVector vector to multiple with
  4076. * @returns the updated Vector4.
  4077. */
  4078. multiplyInPlace(otherVector: Vector4): Vector4;
  4079. /**
  4080. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4081. * @param otherVector vector to multiple with
  4082. * @returns resulting new vector
  4083. */
  4084. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4085. /**
  4086. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4087. * @param otherVector vector to multiple with
  4088. * @param result vector to store the result
  4089. * @returns the current Vector4.
  4090. */
  4091. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4092. /**
  4093. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4094. * @param x x value multiply with
  4095. * @param y y value multiply with
  4096. * @param z z value multiply with
  4097. * @param w w value multiply with
  4098. * @returns resulting new vector
  4099. */
  4100. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4101. /**
  4102. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4103. * @param otherVector vector to devide with
  4104. * @returns resulting new vector
  4105. */
  4106. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4107. /**
  4108. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4109. * @param otherVector vector to devide with
  4110. * @param result vector to store the result
  4111. * @returns the current Vector4.
  4112. */
  4113. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4114. /**
  4115. * Divides the current Vector3 coordinates by the given ones.
  4116. * @param otherVector vector to devide with
  4117. * @returns the updated Vector3.
  4118. */
  4119. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4120. /**
  4121. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4122. * @param other defines the second operand
  4123. * @returns the current updated Vector4
  4124. */
  4125. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4126. /**
  4127. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4128. * @param other defines the second operand
  4129. * @returns the current updated Vector4
  4130. */
  4131. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4132. /**
  4133. * Gets a new Vector4 from current Vector4 floored values
  4134. * @returns a new Vector4
  4135. */
  4136. floor(): Vector4;
  4137. /**
  4138. * Gets a new Vector4 from current Vector3 floored values
  4139. * @returns a new Vector4
  4140. */
  4141. fract(): Vector4;
  4142. /**
  4143. * Returns the Vector4 length (float).
  4144. * @returns the length
  4145. */
  4146. length(): number;
  4147. /**
  4148. * Returns the Vector4 squared length (float).
  4149. * @returns the length squared
  4150. */
  4151. lengthSquared(): number;
  4152. /**
  4153. * Normalizes in place the Vector4.
  4154. * @returns the updated Vector4.
  4155. */
  4156. normalize(): Vector4;
  4157. /**
  4158. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4159. * @returns this converted to a new vector3
  4160. */
  4161. toVector3(): Vector3;
  4162. /**
  4163. * Returns a new Vector4 copied from the current one.
  4164. * @returns the new cloned vector
  4165. */
  4166. clone(): Vector4;
  4167. /**
  4168. * Updates the current Vector4 with the given one coordinates.
  4169. * @param source the source vector to copy from
  4170. * @returns the updated Vector4.
  4171. */
  4172. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4173. /**
  4174. * Updates the current Vector4 coordinates with the given floats.
  4175. * @param x float to copy from
  4176. * @param y float to copy from
  4177. * @param z float to copy from
  4178. * @param w float to copy from
  4179. * @returns the updated Vector4.
  4180. */
  4181. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4182. /**
  4183. * Updates the current Vector4 coordinates with the given floats.
  4184. * @param x float to set from
  4185. * @param y float to set from
  4186. * @param z float to set from
  4187. * @param w float to set from
  4188. * @returns the updated Vector4.
  4189. */
  4190. set(x: number, y: number, z: number, w: number): Vector4;
  4191. /**
  4192. * Copies the given float to the current Vector3 coordinates
  4193. * @param v defines the x, y, z and w coordinates of the operand
  4194. * @returns the current updated Vector3
  4195. */
  4196. setAll(v: number): Vector4;
  4197. /**
  4198. * Returns a new Vector4 set from the starting index of the given array.
  4199. * @param array the array to pull values from
  4200. * @param offset the offset into the array to start at
  4201. * @returns the new vector
  4202. */
  4203. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4204. /**
  4205. * Updates the given vector "result" from the starting index of the given array.
  4206. * @param array the array to pull values from
  4207. * @param offset the offset into the array to start at
  4208. * @param result the vector to store the result in
  4209. */
  4210. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4211. /**
  4212. * Updates the given vector "result" from the starting index of the given Float32Array.
  4213. * @param array the array to pull values from
  4214. * @param offset the offset into the array to start at
  4215. * @param result the vector to store the result in
  4216. */
  4217. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4218. /**
  4219. * Updates the given vector "result" coordinates from the given floats.
  4220. * @param x float to set from
  4221. * @param y float to set from
  4222. * @param z float to set from
  4223. * @param w float to set from
  4224. * @param result the vector to the floats in
  4225. */
  4226. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4227. /**
  4228. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4229. * @returns the new vector
  4230. */
  4231. static Zero(): Vector4;
  4232. /**
  4233. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4234. * @returns the new vector
  4235. */
  4236. static One(): Vector4;
  4237. /**
  4238. * Returns a new normalized Vector4 from the given one.
  4239. * @param vector the vector to normalize
  4240. * @returns the vector
  4241. */
  4242. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4243. /**
  4244. * Updates the given vector "result" from the normalization of the given one.
  4245. * @param vector the vector to normalize
  4246. * @param result the vector to store the result in
  4247. */
  4248. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4249. /**
  4250. * Returns a vector with the minimum values from the left and right vectors
  4251. * @param left left vector to minimize
  4252. * @param right right vector to minimize
  4253. * @returns a new vector with the minimum of the left and right vector values
  4254. */
  4255. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4256. /**
  4257. * Returns a vector with the maximum values from the left and right vectors
  4258. * @param left left vector to maximize
  4259. * @param right right vector to maximize
  4260. * @returns a new vector with the maximum of the left and right vector values
  4261. */
  4262. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4263. /**
  4264. * Returns the distance (float) between the vectors "value1" and "value2".
  4265. * @param value1 value to calulate the distance between
  4266. * @param value2 value to calulate the distance between
  4267. * @return the distance between the two vectors
  4268. */
  4269. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4270. /**
  4271. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4272. * @param value1 value to calulate the distance between
  4273. * @param value2 value to calulate the distance between
  4274. * @return the distance between the two vectors squared
  4275. */
  4276. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4277. /**
  4278. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4279. * @param value1 value to calulate the center between
  4280. * @param value2 value to calulate the center between
  4281. * @return the center between the two vectors
  4282. */
  4283. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4284. /**
  4285. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4286. * @param value1 defines first vector
  4287. * @param value2 defines second vector
  4288. * @param ref defines third vector
  4289. * @returns ref
  4290. */
  4291. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4292. /**
  4293. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4294. * This methods computes transformed normalized direction vectors only.
  4295. * @param vector the vector to transform
  4296. * @param transformation the transformation matrix to apply
  4297. * @returns the new vector
  4298. */
  4299. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4300. /**
  4301. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4302. * This methods computes transformed normalized direction vectors only.
  4303. * @param vector the vector to transform
  4304. * @param transformation the transformation matrix to apply
  4305. * @param result the vector to store the result in
  4306. */
  4307. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4308. /**
  4309. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4310. * This methods computes transformed normalized direction vectors only.
  4311. * @param x value to transform
  4312. * @param y value to transform
  4313. * @param z value to transform
  4314. * @param w value to transform
  4315. * @param transformation the transformation matrix to apply
  4316. * @param result the vector to store the results in
  4317. */
  4318. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4319. /**
  4320. * Creates a new Vector4 from a Vector3
  4321. * @param source defines the source data
  4322. * @param w defines the 4th component (default is 0)
  4323. * @returns a new Vector4
  4324. */
  4325. static FromVector3(source: Vector3, w?: number): Vector4;
  4326. }
  4327. /**
  4328. * Class used to store quaternion data
  4329. * @see https://en.wikipedia.org/wiki/Quaternion
  4330. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4331. */
  4332. export class Quaternion {
  4333. /** @hidden */
  4334. _x: number;
  4335. /** @hidden */
  4336. _y: number;
  4337. /** @hidden */
  4338. _z: number;
  4339. /** @hidden */
  4340. _w: number;
  4341. /** @hidden */
  4342. _isDirty: boolean;
  4343. /** Gets or sets the x coordinate */
  4344. get x(): number;
  4345. set x(value: number);
  4346. /** Gets or sets the y coordinate */
  4347. get y(): number;
  4348. set y(value: number);
  4349. /** Gets or sets the z coordinate */
  4350. get z(): number;
  4351. set z(value: number);
  4352. /** Gets or sets the w coordinate */
  4353. get w(): number;
  4354. set w(value: number);
  4355. /**
  4356. * Creates a new Quaternion from the given floats
  4357. * @param x defines the first component (0 by default)
  4358. * @param y defines the second component (0 by default)
  4359. * @param z defines the third component (0 by default)
  4360. * @param w defines the fourth component (1.0 by default)
  4361. */
  4362. constructor(x?: number, y?: number, z?: number, w?: number);
  4363. /**
  4364. * Gets a string representation for the current quaternion
  4365. * @returns a string with the Quaternion coordinates
  4366. */
  4367. toString(): string;
  4368. /**
  4369. * Gets the class name of the quaternion
  4370. * @returns the string "Quaternion"
  4371. */
  4372. getClassName(): string;
  4373. /**
  4374. * Gets a hash code for this quaternion
  4375. * @returns the quaternion hash code
  4376. */
  4377. getHashCode(): number;
  4378. /**
  4379. * Copy the quaternion to an array
  4380. * @returns a new array populated with 4 elements from the quaternion coordinates
  4381. */
  4382. asArray(): number[];
  4383. /**
  4384. * Check if two quaternions are equals
  4385. * @param otherQuaternion defines the second operand
  4386. * @return true if the current quaternion and the given one coordinates are strictly equals
  4387. */
  4388. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4389. /**
  4390. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4391. * @param otherQuaternion defines the other quaternion
  4392. * @param epsilon defines the minimal distance to consider equality
  4393. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4394. */
  4395. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4396. /**
  4397. * Clone the current quaternion
  4398. * @returns a new quaternion copied from the current one
  4399. */
  4400. clone(): Quaternion;
  4401. /**
  4402. * Copy a quaternion to the current one
  4403. * @param other defines the other quaternion
  4404. * @returns the updated current quaternion
  4405. */
  4406. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4407. /**
  4408. * Updates the current quaternion with the given float coordinates
  4409. * @param x defines the x coordinate
  4410. * @param y defines the y coordinate
  4411. * @param z defines the z coordinate
  4412. * @param w defines the w coordinate
  4413. * @returns the updated current quaternion
  4414. */
  4415. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4416. /**
  4417. * Updates the current quaternion from the given float coordinates
  4418. * @param x defines the x coordinate
  4419. * @param y defines the y coordinate
  4420. * @param z defines the z coordinate
  4421. * @param w defines the w coordinate
  4422. * @returns the updated current quaternion
  4423. */
  4424. set(x: number, y: number, z: number, w: number): Quaternion;
  4425. /**
  4426. * Adds two quaternions
  4427. * @param other defines the second operand
  4428. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4429. */
  4430. add(other: DeepImmutable<Quaternion>): Quaternion;
  4431. /**
  4432. * Add a quaternion to the current one
  4433. * @param other defines the quaternion to add
  4434. * @returns the current quaternion
  4435. */
  4436. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4437. /**
  4438. * Subtract two quaternions
  4439. * @param other defines the second operand
  4440. * @returns a new quaternion as the subtraction result of the given one from the current one
  4441. */
  4442. subtract(other: Quaternion): Quaternion;
  4443. /**
  4444. * Multiplies the current quaternion by a scale factor
  4445. * @param value defines the scale factor
  4446. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4447. */
  4448. scale(value: number): Quaternion;
  4449. /**
  4450. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4451. * @param scale defines the scale factor
  4452. * @param result defines the Quaternion object where to store the result
  4453. * @returns the unmodified current quaternion
  4454. */
  4455. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4456. /**
  4457. * Multiplies in place the current quaternion by a scale factor
  4458. * @param value defines the scale factor
  4459. * @returns the current modified quaternion
  4460. */
  4461. scaleInPlace(value: number): Quaternion;
  4462. /**
  4463. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4464. * @param scale defines the scale factor
  4465. * @param result defines the Quaternion object where to store the result
  4466. * @returns the unmodified current quaternion
  4467. */
  4468. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4469. /**
  4470. * Multiplies two quaternions
  4471. * @param q1 defines the second operand
  4472. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4473. */
  4474. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4475. /**
  4476. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4477. * @param q1 defines the second operand
  4478. * @param result defines the target quaternion
  4479. * @returns the current quaternion
  4480. */
  4481. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4482. /**
  4483. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4484. * @param q1 defines the second operand
  4485. * @returns the currentupdated quaternion
  4486. */
  4487. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4488. /**
  4489. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4490. * @param ref defines the target quaternion
  4491. * @returns the current quaternion
  4492. */
  4493. conjugateToRef(ref: Quaternion): Quaternion;
  4494. /**
  4495. * Conjugates in place (1-q) the current quaternion
  4496. * @returns the current updated quaternion
  4497. */
  4498. conjugateInPlace(): Quaternion;
  4499. /**
  4500. * Conjugates in place (1-q) the current quaternion
  4501. * @returns a new quaternion
  4502. */
  4503. conjugate(): Quaternion;
  4504. /**
  4505. * Gets length of current quaternion
  4506. * @returns the quaternion length (float)
  4507. */
  4508. length(): number;
  4509. /**
  4510. * Normalize in place the current quaternion
  4511. * @returns the current updated quaternion
  4512. */
  4513. normalize(): Quaternion;
  4514. /**
  4515. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4516. * @param order is a reserved parameter and is ignored for now
  4517. * @returns a new Vector3 containing the Euler angles
  4518. */
  4519. toEulerAngles(order?: string): Vector3;
  4520. /**
  4521. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4522. * @param result defines the vector which will be filled with the Euler angles
  4523. * @returns the current unchanged quaternion
  4524. */
  4525. toEulerAnglesToRef(result: Vector3): Quaternion;
  4526. /**
  4527. * Updates the given rotation matrix with the current quaternion values
  4528. * @param result defines the target matrix
  4529. * @returns the current unchanged quaternion
  4530. */
  4531. toRotationMatrix(result: Matrix): Quaternion;
  4532. /**
  4533. * Updates the current quaternion from the given rotation matrix values
  4534. * @param matrix defines the source matrix
  4535. * @returns the current updated quaternion
  4536. */
  4537. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4538. /**
  4539. * Creates a new quaternion from a rotation matrix
  4540. * @param matrix defines the source matrix
  4541. * @returns a new quaternion created from the given rotation matrix values
  4542. */
  4543. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4544. /**
  4545. * Updates the given quaternion with the given rotation matrix values
  4546. * @param matrix defines the source matrix
  4547. * @param result defines the target quaternion
  4548. */
  4549. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4550. /**
  4551. * Returns the dot product (float) between the quaternions "left" and "right"
  4552. * @param left defines the left operand
  4553. * @param right defines the right operand
  4554. * @returns the dot product
  4555. */
  4556. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4557. /**
  4558. * Checks if the two quaternions are close to each other
  4559. * @param quat0 defines the first quaternion to check
  4560. * @param quat1 defines the second quaternion to check
  4561. * @returns true if the two quaternions are close to each other
  4562. */
  4563. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4564. /**
  4565. * Creates an empty quaternion
  4566. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4567. */
  4568. static Zero(): Quaternion;
  4569. /**
  4570. * Inverse a given quaternion
  4571. * @param q defines the source quaternion
  4572. * @returns a new quaternion as the inverted current quaternion
  4573. */
  4574. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4575. /**
  4576. * Inverse a given quaternion
  4577. * @param q defines the source quaternion
  4578. * @param result the quaternion the result will be stored in
  4579. * @returns the result quaternion
  4580. */
  4581. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4582. /**
  4583. * Creates an identity quaternion
  4584. * @returns the identity quaternion
  4585. */
  4586. static Identity(): Quaternion;
  4587. /**
  4588. * Gets a boolean indicating if the given quaternion is identity
  4589. * @param quaternion defines the quaternion to check
  4590. * @returns true if the quaternion is identity
  4591. */
  4592. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4593. /**
  4594. * Creates a quaternion from a rotation around an axis
  4595. * @param axis defines the axis to use
  4596. * @param angle defines the angle to use
  4597. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4598. */
  4599. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4600. /**
  4601. * Creates a rotation around an axis and stores it into the given quaternion
  4602. * @param axis defines the axis to use
  4603. * @param angle defines the angle to use
  4604. * @param result defines the target quaternion
  4605. * @returns the target quaternion
  4606. */
  4607. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4608. /**
  4609. * Creates a new quaternion from data stored into an array
  4610. * @param array defines the data source
  4611. * @param offset defines the offset in the source array where the data starts
  4612. * @returns a new quaternion
  4613. */
  4614. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4615. /**
  4616. * Updates the given quaternion "result" from the starting index of the given array.
  4617. * @param array the array to pull values from
  4618. * @param offset the offset into the array to start at
  4619. * @param result the quaternion to store the result in
  4620. */
  4621. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4622. /**
  4623. * Create a quaternion from Euler rotation angles
  4624. * @param x Pitch
  4625. * @param y Yaw
  4626. * @param z Roll
  4627. * @returns the new Quaternion
  4628. */
  4629. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4630. /**
  4631. * Updates a quaternion from Euler rotation angles
  4632. * @param x Pitch
  4633. * @param y Yaw
  4634. * @param z Roll
  4635. * @param result the quaternion to store the result
  4636. * @returns the updated quaternion
  4637. */
  4638. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4639. /**
  4640. * Create a quaternion from Euler rotation vector
  4641. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4642. * @returns the new Quaternion
  4643. */
  4644. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4645. /**
  4646. * Updates a quaternion from Euler rotation vector
  4647. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4648. * @param result the quaternion to store the result
  4649. * @returns the updated quaternion
  4650. */
  4651. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4652. /**
  4653. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4654. * @param yaw defines the rotation around Y axis
  4655. * @param pitch defines the rotation around X axis
  4656. * @param roll defines the rotation around Z axis
  4657. * @returns the new quaternion
  4658. */
  4659. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4660. /**
  4661. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4662. * @param yaw defines the rotation around Y axis
  4663. * @param pitch defines the rotation around X axis
  4664. * @param roll defines the rotation around Z axis
  4665. * @param result defines the target quaternion
  4666. */
  4667. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4668. /**
  4669. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4670. * @param alpha defines the rotation around first axis
  4671. * @param beta defines the rotation around second axis
  4672. * @param gamma defines the rotation around third axis
  4673. * @returns the new quaternion
  4674. */
  4675. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4676. /**
  4677. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4678. * @param alpha defines the rotation around first axis
  4679. * @param beta defines the rotation around second axis
  4680. * @param gamma defines the rotation around third axis
  4681. * @param result defines the target quaternion
  4682. */
  4683. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4684. /**
  4685. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4686. * @param axis1 defines the first axis
  4687. * @param axis2 defines the second axis
  4688. * @param axis3 defines the third axis
  4689. * @returns the new quaternion
  4690. */
  4691. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4692. /**
  4693. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4694. * @param axis1 defines the first axis
  4695. * @param axis2 defines the second axis
  4696. * @param axis3 defines the third axis
  4697. * @param ref defines the target quaternion
  4698. */
  4699. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4700. /**
  4701. * Interpolates between two quaternions
  4702. * @param left defines first quaternion
  4703. * @param right defines second quaternion
  4704. * @param amount defines the gradient to use
  4705. * @returns the new interpolated quaternion
  4706. */
  4707. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4708. /**
  4709. * Interpolates between two quaternions and stores it into a target quaternion
  4710. * @param left defines first quaternion
  4711. * @param right defines second quaternion
  4712. * @param amount defines the gradient to use
  4713. * @param result defines the target quaternion
  4714. */
  4715. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4716. /**
  4717. * Interpolate between two quaternions using Hermite interpolation
  4718. * @param value1 defines first quaternion
  4719. * @param tangent1 defines the incoming tangent
  4720. * @param value2 defines second quaternion
  4721. * @param tangent2 defines the outgoing tangent
  4722. * @param amount defines the target quaternion
  4723. * @returns the new interpolated quaternion
  4724. */
  4725. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4726. }
  4727. /**
  4728. * Class used to store matrix data (4x4)
  4729. */
  4730. export class Matrix {
  4731. /**
  4732. * Gets the precision of matrix computations
  4733. */
  4734. static get Use64Bits(): boolean;
  4735. private static _updateFlagSeed;
  4736. private static _identityReadOnly;
  4737. private _isIdentity;
  4738. private _isIdentityDirty;
  4739. private _isIdentity3x2;
  4740. private _isIdentity3x2Dirty;
  4741. /**
  4742. * Gets the update flag of the matrix which is an unique number for the matrix.
  4743. * It will be incremented every time the matrix data change.
  4744. * You can use it to speed the comparison between two versions of the same matrix.
  4745. */
  4746. updateFlag: number;
  4747. private readonly _m;
  4748. /**
  4749. * Gets the internal data of the matrix
  4750. */
  4751. get m(): DeepImmutable<Float32Array | Array<number>>;
  4752. /** @hidden */
  4753. _markAsUpdated(): void;
  4754. /** @hidden */
  4755. private _updateIdentityStatus;
  4756. /**
  4757. * Creates an empty matrix (filled with zeros)
  4758. */
  4759. constructor();
  4760. /**
  4761. * Check if the current matrix is identity
  4762. * @returns true is the matrix is the identity matrix
  4763. */
  4764. isIdentity(): boolean;
  4765. /**
  4766. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4767. * @returns true is the matrix is the identity matrix
  4768. */
  4769. isIdentityAs3x2(): boolean;
  4770. /**
  4771. * Gets the determinant of the matrix
  4772. * @returns the matrix determinant
  4773. */
  4774. determinant(): number;
  4775. /**
  4776. * Returns the matrix as a Float32Array or Array<number>
  4777. * @returns the matrix underlying array
  4778. */
  4779. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4780. /**
  4781. * Returns the matrix as a Float32Array or Array<number>
  4782. * @returns the matrix underlying array.
  4783. */
  4784. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4785. /**
  4786. * Inverts the current matrix in place
  4787. * @returns the current inverted matrix
  4788. */
  4789. invert(): Matrix;
  4790. /**
  4791. * Sets all the matrix elements to zero
  4792. * @returns the current matrix
  4793. */
  4794. reset(): Matrix;
  4795. /**
  4796. * Adds the current matrix with a second one
  4797. * @param other defines the matrix to add
  4798. * @returns a new matrix as the addition of the current matrix and the given one
  4799. */
  4800. add(other: DeepImmutable<Matrix>): Matrix;
  4801. /**
  4802. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4803. * @param other defines the matrix to add
  4804. * @param result defines the target matrix
  4805. * @returns the current matrix
  4806. */
  4807. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4808. /**
  4809. * Adds in place the given matrix to the current matrix
  4810. * @param other defines the second operand
  4811. * @returns the current updated matrix
  4812. */
  4813. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4814. /**
  4815. * Sets the given matrix to the current inverted Matrix
  4816. * @param other defines the target matrix
  4817. * @returns the unmodified current matrix
  4818. */
  4819. invertToRef(other: Matrix): Matrix;
  4820. /**
  4821. * add a value at the specified position in the current Matrix
  4822. * @param index the index of the value within the matrix. between 0 and 15.
  4823. * @param value the value to be added
  4824. * @returns the current updated matrix
  4825. */
  4826. addAtIndex(index: number, value: number): Matrix;
  4827. /**
  4828. * mutiply the specified position in the current Matrix by a value
  4829. * @param index the index of the value within the matrix. between 0 and 15.
  4830. * @param value the value to be added
  4831. * @returns the current updated matrix
  4832. */
  4833. multiplyAtIndex(index: number, value: number): Matrix;
  4834. /**
  4835. * Inserts the translation vector (using 3 floats) in the current matrix
  4836. * @param x defines the 1st component of the translation
  4837. * @param y defines the 2nd component of the translation
  4838. * @param z defines the 3rd component of the translation
  4839. * @returns the current updated matrix
  4840. */
  4841. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4842. /**
  4843. * Adds the translation vector (using 3 floats) in the current matrix
  4844. * @param x defines the 1st component of the translation
  4845. * @param y defines the 2nd component of the translation
  4846. * @param z defines the 3rd component of the translation
  4847. * @returns the current updated matrix
  4848. */
  4849. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4850. /**
  4851. * Inserts the translation vector in the current matrix
  4852. * @param vector3 defines the translation to insert
  4853. * @returns the current updated matrix
  4854. */
  4855. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4856. /**
  4857. * Gets the translation value of the current matrix
  4858. * @returns a new Vector3 as the extracted translation from the matrix
  4859. */
  4860. getTranslation(): Vector3;
  4861. /**
  4862. * Fill a Vector3 with the extracted translation from the matrix
  4863. * @param result defines the Vector3 where to store the translation
  4864. * @returns the current matrix
  4865. */
  4866. getTranslationToRef(result: Vector3): Matrix;
  4867. /**
  4868. * Remove rotation and scaling part from the matrix
  4869. * @returns the updated matrix
  4870. */
  4871. removeRotationAndScaling(): Matrix;
  4872. /**
  4873. * Multiply two matrices
  4874. * @param other defines the second operand
  4875. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4876. */
  4877. multiply(other: DeepImmutable<Matrix>): Matrix;
  4878. /**
  4879. * Copy the current matrix from the given one
  4880. * @param other defines the source matrix
  4881. * @returns the current updated matrix
  4882. */
  4883. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4884. /**
  4885. * Populates the given array from the starting index with the current matrix values
  4886. * @param array defines the target array
  4887. * @param offset defines the offset in the target array where to start storing values
  4888. * @returns the current matrix
  4889. */
  4890. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4891. /**
  4892. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4893. * @param other defines the second operand
  4894. * @param result defines the matrix where to store the multiplication
  4895. * @returns the current matrix
  4896. */
  4897. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4898. /**
  4899. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4900. * @param other defines the second operand
  4901. * @param result defines the array where to store the multiplication
  4902. * @param offset defines the offset in the target array where to start storing values
  4903. * @returns the current matrix
  4904. */
  4905. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4906. /**
  4907. * Check equality between this matrix and a second one
  4908. * @param value defines the second matrix to compare
  4909. * @returns true is the current matrix and the given one values are strictly equal
  4910. */
  4911. equals(value: DeepImmutable<Matrix>): boolean;
  4912. /**
  4913. * Clone the current matrix
  4914. * @returns a new matrix from the current matrix
  4915. */
  4916. clone(): Matrix;
  4917. /**
  4918. * Returns the name of the current matrix class
  4919. * @returns the string "Matrix"
  4920. */
  4921. getClassName(): string;
  4922. /**
  4923. * Gets the hash code of the current matrix
  4924. * @returns the hash code
  4925. */
  4926. getHashCode(): number;
  4927. /**
  4928. * Decomposes the current Matrix into a translation, rotation and scaling components
  4929. * @param scale defines the scale vector3 given as a reference to update
  4930. * @param rotation defines the rotation quaternion given as a reference to update
  4931. * @param translation defines the translation vector3 given as a reference to update
  4932. * @returns true if operation was successful
  4933. */
  4934. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4935. /**
  4936. * Gets specific row of the matrix
  4937. * @param index defines the number of the row to get
  4938. * @returns the index-th row of the current matrix as a new Vector4
  4939. */
  4940. getRow(index: number): Nullable<Vector4>;
  4941. /**
  4942. * Sets the index-th row of the current matrix to the vector4 values
  4943. * @param index defines the number of the row to set
  4944. * @param row defines the target vector4
  4945. * @returns the updated current matrix
  4946. */
  4947. setRow(index: number, row: Vector4): Matrix;
  4948. /**
  4949. * Compute the transpose of the matrix
  4950. * @returns the new transposed matrix
  4951. */
  4952. transpose(): Matrix;
  4953. /**
  4954. * Compute the transpose of the matrix and store it in a given matrix
  4955. * @param result defines the target matrix
  4956. * @returns the current matrix
  4957. */
  4958. transposeToRef(result: Matrix): Matrix;
  4959. /**
  4960. * Sets the index-th row of the current matrix with the given 4 x float values
  4961. * @param index defines the row index
  4962. * @param x defines the x component to set
  4963. * @param y defines the y component to set
  4964. * @param z defines the z component to set
  4965. * @param w defines the w component to set
  4966. * @returns the updated current matrix
  4967. */
  4968. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4969. /**
  4970. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4971. * @param scale defines the scale factor
  4972. * @returns a new matrix
  4973. */
  4974. scale(scale: number): Matrix;
  4975. /**
  4976. * Scale the current matrix values by a factor to a given result matrix
  4977. * @param scale defines the scale factor
  4978. * @param result defines the matrix to store the result
  4979. * @returns the current matrix
  4980. */
  4981. scaleToRef(scale: number, result: Matrix): Matrix;
  4982. /**
  4983. * Scale the current matrix values by a factor and add the result to a given matrix
  4984. * @param scale defines the scale factor
  4985. * @param result defines the Matrix to store the result
  4986. * @returns the current matrix
  4987. */
  4988. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4989. /**
  4990. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4991. * @param ref matrix to store the result
  4992. */
  4993. toNormalMatrix(ref: Matrix): void;
  4994. /**
  4995. * Gets only rotation part of the current matrix
  4996. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4997. */
  4998. getRotationMatrix(): Matrix;
  4999. /**
  5000. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5001. * @param result defines the target matrix to store data to
  5002. * @returns the current matrix
  5003. */
  5004. getRotationMatrixToRef(result: Matrix): Matrix;
  5005. /**
  5006. * Toggles model matrix from being right handed to left handed in place and vice versa
  5007. */
  5008. toggleModelMatrixHandInPlace(): void;
  5009. /**
  5010. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5011. */
  5012. toggleProjectionMatrixHandInPlace(): void;
  5013. /**
  5014. * Creates a matrix from an array
  5015. * @param array defines the source array
  5016. * @param offset defines an offset in the source array
  5017. * @returns a new Matrix set from the starting index of the given array
  5018. */
  5019. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5020. /**
  5021. * Copy the content of an array into a given matrix
  5022. * @param array defines the source array
  5023. * @param offset defines an offset in the source array
  5024. * @param result defines the target matrix
  5025. */
  5026. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5027. /**
  5028. * Stores an array into a matrix after having multiplied each component by a given factor
  5029. * @param array defines the source array
  5030. * @param offset defines the offset in the source array
  5031. * @param scale defines the scaling factor
  5032. * @param result defines the target matrix
  5033. */
  5034. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5035. /**
  5036. * Gets an identity matrix that must not be updated
  5037. */
  5038. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5039. /**
  5040. * Stores a list of values (16) inside a given matrix
  5041. * @param initialM11 defines 1st value of 1st row
  5042. * @param initialM12 defines 2nd value of 1st row
  5043. * @param initialM13 defines 3rd value of 1st row
  5044. * @param initialM14 defines 4th value of 1st row
  5045. * @param initialM21 defines 1st value of 2nd row
  5046. * @param initialM22 defines 2nd value of 2nd row
  5047. * @param initialM23 defines 3rd value of 2nd row
  5048. * @param initialM24 defines 4th value of 2nd row
  5049. * @param initialM31 defines 1st value of 3rd row
  5050. * @param initialM32 defines 2nd value of 3rd row
  5051. * @param initialM33 defines 3rd value of 3rd row
  5052. * @param initialM34 defines 4th value of 3rd row
  5053. * @param initialM41 defines 1st value of 4th row
  5054. * @param initialM42 defines 2nd value of 4th row
  5055. * @param initialM43 defines 3rd value of 4th row
  5056. * @param initialM44 defines 4th value of 4th row
  5057. * @param result defines the target matrix
  5058. */
  5059. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  5060. /**
  5061. * Creates new matrix from a list of values (16)
  5062. * @param initialM11 defines 1st value of 1st row
  5063. * @param initialM12 defines 2nd value of 1st row
  5064. * @param initialM13 defines 3rd value of 1st row
  5065. * @param initialM14 defines 4th value of 1st row
  5066. * @param initialM21 defines 1st value of 2nd row
  5067. * @param initialM22 defines 2nd value of 2nd row
  5068. * @param initialM23 defines 3rd value of 2nd row
  5069. * @param initialM24 defines 4th value of 2nd row
  5070. * @param initialM31 defines 1st value of 3rd row
  5071. * @param initialM32 defines 2nd value of 3rd row
  5072. * @param initialM33 defines 3rd value of 3rd row
  5073. * @param initialM34 defines 4th value of 3rd row
  5074. * @param initialM41 defines 1st value of 4th row
  5075. * @param initialM42 defines 2nd value of 4th row
  5076. * @param initialM43 defines 3rd value of 4th row
  5077. * @param initialM44 defines 4th value of 4th row
  5078. * @returns the new matrix
  5079. */
  5080. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  5081. /**
  5082. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5083. * @param scale defines the scale vector3
  5084. * @param rotation defines the rotation quaternion
  5085. * @param translation defines the translation vector3
  5086. * @returns a new matrix
  5087. */
  5088. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5089. /**
  5090. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5091. * @param scale defines the scale vector3
  5092. * @param rotation defines the rotation quaternion
  5093. * @param translation defines the translation vector3
  5094. * @param result defines the target matrix
  5095. */
  5096. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5097. /**
  5098. * Creates a new identity matrix
  5099. * @returns a new identity matrix
  5100. */
  5101. static Identity(): Matrix;
  5102. /**
  5103. * Creates a new identity matrix and stores the result in a given matrix
  5104. * @param result defines the target matrix
  5105. */
  5106. static IdentityToRef(result: Matrix): void;
  5107. /**
  5108. * Creates a new zero matrix
  5109. * @returns a new zero matrix
  5110. */
  5111. static Zero(): Matrix;
  5112. /**
  5113. * Creates a new rotation matrix for "angle" radians around the X axis
  5114. * @param angle defines the angle (in radians) to use
  5115. * @return the new matrix
  5116. */
  5117. static RotationX(angle: number): Matrix;
  5118. /**
  5119. * Creates a new matrix as the invert of a given matrix
  5120. * @param source defines the source matrix
  5121. * @returns the new matrix
  5122. */
  5123. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5124. /**
  5125. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5126. * @param angle defines the angle (in radians) to use
  5127. * @param result defines the target matrix
  5128. */
  5129. static RotationXToRef(angle: number, result: Matrix): void;
  5130. /**
  5131. * Creates a new rotation matrix for "angle" radians around the Y axis
  5132. * @param angle defines the angle (in radians) to use
  5133. * @return the new matrix
  5134. */
  5135. static RotationY(angle: number): Matrix;
  5136. /**
  5137. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5138. * @param angle defines the angle (in radians) to use
  5139. * @param result defines the target matrix
  5140. */
  5141. static RotationYToRef(angle: number, result: Matrix): void;
  5142. /**
  5143. * Creates a new rotation matrix for "angle" radians around the Z axis
  5144. * @param angle defines the angle (in radians) to use
  5145. * @return the new matrix
  5146. */
  5147. static RotationZ(angle: number): Matrix;
  5148. /**
  5149. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5150. * @param angle defines the angle (in radians) to use
  5151. * @param result defines the target matrix
  5152. */
  5153. static RotationZToRef(angle: number, result: Matrix): void;
  5154. /**
  5155. * Creates a new rotation matrix for "angle" radians around the given axis
  5156. * @param axis defines the axis to use
  5157. * @param angle defines the angle (in radians) to use
  5158. * @return the new matrix
  5159. */
  5160. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5161. /**
  5162. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5163. * @param axis defines the axis to use
  5164. * @param angle defines the angle (in radians) to use
  5165. * @param result defines the target matrix
  5166. */
  5167. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5168. /**
  5169. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5170. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5171. * @param from defines the vector to align
  5172. * @param to defines the vector to align to
  5173. * @param result defines the target matrix
  5174. */
  5175. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5176. /**
  5177. * Creates a rotation matrix
  5178. * @param yaw defines the yaw angle in radians (Y axis)
  5179. * @param pitch defines the pitch angle in radians (X axis)
  5180. * @param roll defines the roll angle in radians (Z axis)
  5181. * @returns the new rotation matrix
  5182. */
  5183. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5184. /**
  5185. * Creates a rotation matrix and stores it in a given matrix
  5186. * @param yaw defines the yaw angle in radians (Y axis)
  5187. * @param pitch defines the pitch angle in radians (X axis)
  5188. * @param roll defines the roll angle in radians (Z axis)
  5189. * @param result defines the target matrix
  5190. */
  5191. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5192. /**
  5193. * Creates a scaling matrix
  5194. * @param x defines the scale factor on X axis
  5195. * @param y defines the scale factor on Y axis
  5196. * @param z defines the scale factor on Z axis
  5197. * @returns the new matrix
  5198. */
  5199. static Scaling(x: number, y: number, z: number): Matrix;
  5200. /**
  5201. * Creates a scaling matrix and stores it in a given matrix
  5202. * @param x defines the scale factor on X axis
  5203. * @param y defines the scale factor on Y axis
  5204. * @param z defines the scale factor on Z axis
  5205. * @param result defines the target matrix
  5206. */
  5207. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5208. /**
  5209. * Creates a translation matrix
  5210. * @param x defines the translation on X axis
  5211. * @param y defines the translation on Y axis
  5212. * @param z defines the translationon Z axis
  5213. * @returns the new matrix
  5214. */
  5215. static Translation(x: number, y: number, z: number): Matrix;
  5216. /**
  5217. * Creates a translation matrix and stores it in a given matrix
  5218. * @param x defines the translation on X axis
  5219. * @param y defines the translation on Y axis
  5220. * @param z defines the translationon Z axis
  5221. * @param result defines the target matrix
  5222. */
  5223. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5224. /**
  5225. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5226. * @param startValue defines the start value
  5227. * @param endValue defines the end value
  5228. * @param gradient defines the gradient factor
  5229. * @returns the new matrix
  5230. */
  5231. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5232. /**
  5233. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5234. * @param startValue defines the start value
  5235. * @param endValue defines the end value
  5236. * @param gradient defines the gradient factor
  5237. * @param result defines the Matrix object where to store data
  5238. */
  5239. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5240. /**
  5241. * Builds a new matrix whose values are computed by:
  5242. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5243. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5244. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5245. * @param startValue defines the first matrix
  5246. * @param endValue defines the second matrix
  5247. * @param gradient defines the gradient between the two matrices
  5248. * @returns the new matrix
  5249. */
  5250. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5251. /**
  5252. * Update a matrix to values which are computed by:
  5253. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5254. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5255. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5256. * @param startValue defines the first matrix
  5257. * @param endValue defines the second matrix
  5258. * @param gradient defines the gradient between the two matrices
  5259. * @param result defines the target matrix
  5260. */
  5261. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5262. /**
  5263. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5264. * This function works in left handed mode
  5265. * @param eye defines the final position of the entity
  5266. * @param target defines where the entity should look at
  5267. * @param up defines the up vector for the entity
  5268. * @returns the new matrix
  5269. */
  5270. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5271. /**
  5272. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5273. * This function works in left handed mode
  5274. * @param eye defines the final position of the entity
  5275. * @param target defines where the entity should look at
  5276. * @param up defines the up vector for the entity
  5277. * @param result defines the target matrix
  5278. */
  5279. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5280. /**
  5281. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  5282. * This function works in right handed mode
  5283. * @param eye defines the final position of the entity
  5284. * @param target defines where the entity should look at
  5285. * @param up defines the up vector for the entity
  5286. * @returns the new matrix
  5287. */
  5288. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5289. /**
  5290. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  5291. * This function works in right handed mode
  5292. * @param eye defines the final position of the entity
  5293. * @param target defines where the entity should look at
  5294. * @param up defines the up vector for the entity
  5295. * @param result defines the target matrix
  5296. */
  5297. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5298. /**
  5299. * Create a left-handed orthographic projection matrix
  5300. * @param width defines the viewport width
  5301. * @param height defines the viewport height
  5302. * @param znear defines the near clip plane
  5303. * @param zfar defines the far clip plane
  5304. * @returns a new matrix as a left-handed orthographic projection matrix
  5305. */
  5306. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5307. /**
  5308. * Store a left-handed orthographic projection to a given matrix
  5309. * @param width defines the viewport width
  5310. * @param height defines the viewport height
  5311. * @param znear defines the near clip plane
  5312. * @param zfar defines the far clip plane
  5313. * @param result defines the target matrix
  5314. */
  5315. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5316. /**
  5317. * Create a left-handed orthographic projection matrix
  5318. * @param left defines the viewport left coordinate
  5319. * @param right defines the viewport right coordinate
  5320. * @param bottom defines the viewport bottom coordinate
  5321. * @param top defines the viewport top coordinate
  5322. * @param znear defines the near clip plane
  5323. * @param zfar defines the far clip plane
  5324. * @returns a new matrix as a left-handed orthographic projection matrix
  5325. */
  5326. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5327. /**
  5328. * Stores a left-handed orthographic projection into a given matrix
  5329. * @param left defines the viewport left coordinate
  5330. * @param right defines the viewport right coordinate
  5331. * @param bottom defines the viewport bottom coordinate
  5332. * @param top defines the viewport top coordinate
  5333. * @param znear defines the near clip plane
  5334. * @param zfar defines the far clip plane
  5335. * @param result defines the target matrix
  5336. */
  5337. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5338. /**
  5339. * Creates a right-handed orthographic projection matrix
  5340. * @param left defines the viewport left coordinate
  5341. * @param right defines the viewport right coordinate
  5342. * @param bottom defines the viewport bottom coordinate
  5343. * @param top defines the viewport top coordinate
  5344. * @param znear defines the near clip plane
  5345. * @param zfar defines the far clip plane
  5346. * @returns a new matrix as a right-handed orthographic projection matrix
  5347. */
  5348. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5349. /**
  5350. * Stores a right-handed orthographic projection into a given matrix
  5351. * @param left defines the viewport left coordinate
  5352. * @param right defines the viewport right coordinate
  5353. * @param bottom defines the viewport bottom coordinate
  5354. * @param top defines the viewport top coordinate
  5355. * @param znear defines the near clip plane
  5356. * @param zfar defines the far clip plane
  5357. * @param result defines the target matrix
  5358. */
  5359. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5360. /**
  5361. * Creates a left-handed perspective projection matrix
  5362. * @param width defines the viewport width
  5363. * @param height defines the viewport height
  5364. * @param znear defines the near clip plane
  5365. * @param zfar defines the far clip plane
  5366. * @returns a new matrix as a left-handed perspective projection matrix
  5367. */
  5368. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5369. /**
  5370. * Creates a left-handed perspective projection matrix
  5371. * @param fov defines the horizontal field of view
  5372. * @param aspect defines the aspect ratio
  5373. * @param znear defines the near clip plane
  5374. * @param zfar defines the far clip plane
  5375. * @returns a new matrix as a left-handed perspective projection matrix
  5376. */
  5377. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5378. /**
  5379. * Stores a left-handed perspective projection into a given matrix
  5380. * @param fov defines the horizontal field of view
  5381. * @param aspect defines the aspect ratio
  5382. * @param znear defines the near clip plane
  5383. * @param zfar defines the far clip plane
  5384. * @param result defines the target matrix
  5385. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5386. */
  5387. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5388. /**
  5389. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5390. * @param fov defines the horizontal field of view
  5391. * @param aspect defines the aspect ratio
  5392. * @param znear defines the near clip plane
  5393. * @param zfar not used as infinity is used as far clip
  5394. * @param result defines the target matrix
  5395. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5396. */
  5397. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5398. /**
  5399. * Creates a right-handed perspective projection matrix
  5400. * @param fov defines the horizontal field of view
  5401. * @param aspect defines the aspect ratio
  5402. * @param znear defines the near clip plane
  5403. * @param zfar defines the far clip plane
  5404. * @returns a new matrix as a right-handed perspective projection matrix
  5405. */
  5406. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5407. /**
  5408. * Stores a right-handed perspective projection into a given matrix
  5409. * @param fov defines the horizontal field of view
  5410. * @param aspect defines the aspect ratio
  5411. * @param znear defines the near clip plane
  5412. * @param zfar defines the far clip plane
  5413. * @param result defines the target matrix
  5414. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5415. */
  5416. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5417. /**
  5418. * Stores a right-handed perspective projection into a given matrix
  5419. * @param fov defines the horizontal field of view
  5420. * @param aspect defines the aspect ratio
  5421. * @param znear defines the near clip plane
  5422. * @param zfar not used as infinity is used as far clip
  5423. * @param result defines the target matrix
  5424. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5425. */
  5426. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5427. /**
  5428. * Stores a perspective projection for WebVR info a given matrix
  5429. * @param fov defines the field of view
  5430. * @param znear defines the near clip plane
  5431. * @param zfar defines the far clip plane
  5432. * @param result defines the target matrix
  5433. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5434. */
  5435. static PerspectiveFovWebVRToRef(fov: {
  5436. upDegrees: number;
  5437. downDegrees: number;
  5438. leftDegrees: number;
  5439. rightDegrees: number;
  5440. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5441. /**
  5442. * Computes a complete transformation matrix
  5443. * @param viewport defines the viewport to use
  5444. * @param world defines the world matrix
  5445. * @param view defines the view matrix
  5446. * @param projection defines the projection matrix
  5447. * @param zmin defines the near clip plane
  5448. * @param zmax defines the far clip plane
  5449. * @returns the transformation matrix
  5450. */
  5451. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5452. /**
  5453. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5454. * @param matrix defines the matrix to use
  5455. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5456. */
  5457. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5458. /**
  5459. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5460. * @param matrix defines the matrix to use
  5461. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5462. */
  5463. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5464. /**
  5465. * Compute the transpose of a given matrix
  5466. * @param matrix defines the matrix to transpose
  5467. * @returns the new matrix
  5468. */
  5469. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5470. /**
  5471. * Compute the transpose of a matrix and store it in a target matrix
  5472. * @param matrix defines the matrix to transpose
  5473. * @param result defines the target matrix
  5474. */
  5475. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5476. /**
  5477. * Computes a reflection matrix from a plane
  5478. * @param plane defines the reflection plane
  5479. * @returns a new matrix
  5480. */
  5481. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5482. /**
  5483. * Computes a reflection matrix from a plane
  5484. * @param plane defines the reflection plane
  5485. * @param result defines the target matrix
  5486. */
  5487. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5488. /**
  5489. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5490. * @param xaxis defines the value of the 1st axis
  5491. * @param yaxis defines the value of the 2nd axis
  5492. * @param zaxis defines the value of the 3rd axis
  5493. * @param result defines the target matrix
  5494. */
  5495. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5496. /**
  5497. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5498. * @param quat defines the quaternion to use
  5499. * @param result defines the target matrix
  5500. */
  5501. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5502. }
  5503. /**
  5504. * @hidden
  5505. */
  5506. export class TmpVectors {
  5507. static Vector2: Vector2[];
  5508. static Vector3: Vector3[];
  5509. static Vector4: Vector4[];
  5510. static Quaternion: Quaternion[];
  5511. static Matrix: Matrix[];
  5512. }
  5513. }
  5514. declare module BABYLON {
  5515. /**
  5516. * Defines potential orientation for back face culling
  5517. */
  5518. export enum Orientation {
  5519. /**
  5520. * Clockwise
  5521. */
  5522. CW = 0,
  5523. /** Counter clockwise */
  5524. CCW = 1
  5525. }
  5526. /** Class used to represent a Bezier curve */
  5527. export class BezierCurve {
  5528. /**
  5529. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5530. * @param t defines the time
  5531. * @param x1 defines the left coordinate on X axis
  5532. * @param y1 defines the left coordinate on Y axis
  5533. * @param x2 defines the right coordinate on X axis
  5534. * @param y2 defines the right coordinate on Y axis
  5535. * @returns the interpolated value
  5536. */
  5537. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5538. }
  5539. /**
  5540. * Defines angle representation
  5541. */
  5542. export class Angle {
  5543. private _radians;
  5544. /**
  5545. * Creates an Angle object of "radians" radians (float).
  5546. * @param radians the angle in radians
  5547. */
  5548. constructor(radians: number);
  5549. /**
  5550. * Get value in degrees
  5551. * @returns the Angle value in degrees (float)
  5552. */
  5553. degrees(): number;
  5554. /**
  5555. * Get value in radians
  5556. * @returns the Angle value in radians (float)
  5557. */
  5558. radians(): number;
  5559. /**
  5560. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5561. * @param a defines first point as the origin
  5562. * @param b defines point
  5563. * @returns a new Angle
  5564. */
  5565. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5566. /**
  5567. * Gets a new Angle object from the given float in radians
  5568. * @param radians defines the angle value in radians
  5569. * @returns a new Angle
  5570. */
  5571. static FromRadians(radians: number): Angle;
  5572. /**
  5573. * Gets a new Angle object from the given float in degrees
  5574. * @param degrees defines the angle value in degrees
  5575. * @returns a new Angle
  5576. */
  5577. static FromDegrees(degrees: number): Angle;
  5578. }
  5579. /**
  5580. * This represents an arc in a 2d space.
  5581. */
  5582. export class Arc2 {
  5583. /** Defines the start point of the arc */
  5584. startPoint: Vector2;
  5585. /** Defines the mid point of the arc */
  5586. midPoint: Vector2;
  5587. /** Defines the end point of the arc */
  5588. endPoint: Vector2;
  5589. /**
  5590. * Defines the center point of the arc.
  5591. */
  5592. centerPoint: Vector2;
  5593. /**
  5594. * Defines the radius of the arc.
  5595. */
  5596. radius: number;
  5597. /**
  5598. * Defines the angle of the arc (from mid point to end point).
  5599. */
  5600. angle: Angle;
  5601. /**
  5602. * Defines the start angle of the arc (from start point to middle point).
  5603. */
  5604. startAngle: Angle;
  5605. /**
  5606. * Defines the orientation of the arc (clock wise/counter clock wise).
  5607. */
  5608. orientation: Orientation;
  5609. /**
  5610. * Creates an Arc object from the three given points : start, middle and end.
  5611. * @param startPoint Defines the start point of the arc
  5612. * @param midPoint Defines the midlle point of the arc
  5613. * @param endPoint Defines the end point of the arc
  5614. */
  5615. constructor(
  5616. /** Defines the start point of the arc */
  5617. startPoint: Vector2,
  5618. /** Defines the mid point of the arc */
  5619. midPoint: Vector2,
  5620. /** Defines the end point of the arc */
  5621. endPoint: Vector2);
  5622. }
  5623. /**
  5624. * Represents a 2D path made up of multiple 2D points
  5625. */
  5626. export class Path2 {
  5627. private _points;
  5628. private _length;
  5629. /**
  5630. * If the path start and end point are the same
  5631. */
  5632. closed: boolean;
  5633. /**
  5634. * Creates a Path2 object from the starting 2D coordinates x and y.
  5635. * @param x the starting points x value
  5636. * @param y the starting points y value
  5637. */
  5638. constructor(x: number, y: number);
  5639. /**
  5640. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5641. * @param x the added points x value
  5642. * @param y the added points y value
  5643. * @returns the updated Path2.
  5644. */
  5645. addLineTo(x: number, y: number): Path2;
  5646. /**
  5647. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  5648. * @param midX middle point x value
  5649. * @param midY middle point y value
  5650. * @param endX end point x value
  5651. * @param endY end point y value
  5652. * @param numberOfSegments (default: 36)
  5653. * @returns the updated Path2.
  5654. */
  5655. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5656. /**
  5657. * Closes the Path2.
  5658. * @returns the Path2.
  5659. */
  5660. close(): Path2;
  5661. /**
  5662. * Gets the sum of the distance between each sequential point in the path
  5663. * @returns the Path2 total length (float).
  5664. */
  5665. length(): number;
  5666. /**
  5667. * Gets the points which construct the path
  5668. * @returns the Path2 internal array of points.
  5669. */
  5670. getPoints(): Vector2[];
  5671. /**
  5672. * Retreives the point at the distance aways from the starting point
  5673. * @param normalizedLengthPosition the length along the path to retreive the point from
  5674. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5675. */
  5676. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5677. /**
  5678. * Creates a new path starting from an x and y position
  5679. * @param x starting x value
  5680. * @param y starting y value
  5681. * @returns a new Path2 starting at the coordinates (x, y).
  5682. */
  5683. static StartingAt(x: number, y: number): Path2;
  5684. }
  5685. /**
  5686. * Represents a 3D path made up of multiple 3D points
  5687. */
  5688. export class Path3D {
  5689. /**
  5690. * an array of Vector3, the curve axis of the Path3D
  5691. */
  5692. path: Vector3[];
  5693. private _curve;
  5694. private _distances;
  5695. private _tangents;
  5696. private _normals;
  5697. private _binormals;
  5698. private _raw;
  5699. private _alignTangentsWithPath;
  5700. private readonly _pointAtData;
  5701. /**
  5702. * new Path3D(path, normal, raw)
  5703. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5704. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5705. * @param path an array of Vector3, the curve axis of the Path3D
  5706. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5707. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5708. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5709. */
  5710. constructor(
  5711. /**
  5712. * an array of Vector3, the curve axis of the Path3D
  5713. */
  5714. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5715. /**
  5716. * Returns the Path3D array of successive Vector3 designing its curve.
  5717. * @returns the Path3D array of successive Vector3 designing its curve.
  5718. */
  5719. getCurve(): Vector3[];
  5720. /**
  5721. * Returns the Path3D array of successive Vector3 designing its curve.
  5722. * @returns the Path3D array of successive Vector3 designing its curve.
  5723. */
  5724. getPoints(): Vector3[];
  5725. /**
  5726. * @returns the computed length (float) of the path.
  5727. */
  5728. length(): number;
  5729. /**
  5730. * Returns an array populated with tangent vectors on each Path3D curve point.
  5731. * @returns an array populated with tangent vectors on each Path3D curve point.
  5732. */
  5733. getTangents(): Vector3[];
  5734. /**
  5735. * Returns an array populated with normal vectors on each Path3D curve point.
  5736. * @returns an array populated with normal vectors on each Path3D curve point.
  5737. */
  5738. getNormals(): Vector3[];
  5739. /**
  5740. * Returns an array populated with binormal vectors on each Path3D curve point.
  5741. * @returns an array populated with binormal vectors on each Path3D curve point.
  5742. */
  5743. getBinormals(): Vector3[];
  5744. /**
  5745. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5746. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5747. */
  5748. getDistances(): number[];
  5749. /**
  5750. * Returns an interpolated point along this path
  5751. * @param position the position of the point along this path, from 0.0 to 1.0
  5752. * @returns a new Vector3 as the point
  5753. */
  5754. getPointAt(position: number): Vector3;
  5755. /**
  5756. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5757. * @param position the position of the point along this path, from 0.0 to 1.0
  5758. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5759. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5760. */
  5761. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5762. /**
  5763. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5764. * @param position the position of the point along this path, from 0.0 to 1.0
  5765. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5766. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5767. */
  5768. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5769. /**
  5770. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5771. * @param position the position of the point along this path, from 0.0 to 1.0
  5772. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5773. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5774. */
  5775. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5776. /**
  5777. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5778. * @param position the position of the point along this path, from 0.0 to 1.0
  5779. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5780. */
  5781. getDistanceAt(position: number): number;
  5782. /**
  5783. * Returns the array index of the previous point of an interpolated point along this path
  5784. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5785. * @returns the array index
  5786. */
  5787. getPreviousPointIndexAt(position: number): number;
  5788. /**
  5789. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5790. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5791. * @returns the sub position
  5792. */
  5793. getSubPositionAt(position: number): number;
  5794. /**
  5795. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5796. * @param target the vector of which to get the closest position to
  5797. * @returns the position of the closest virtual point on this path to the target vector
  5798. */
  5799. getClosestPositionTo(target: Vector3): number;
  5800. /**
  5801. * Returns a sub path (slice) of this path
  5802. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5803. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5804. * @returns a sub path (slice) of this path
  5805. */
  5806. slice(start?: number, end?: number): Path3D;
  5807. /**
  5808. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5809. * @param path path which all values are copied into the curves points
  5810. * @param firstNormal which should be projected onto the curve
  5811. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5812. * @returns the same object updated.
  5813. */
  5814. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5815. private _compute;
  5816. private _getFirstNonNullVector;
  5817. private _getLastNonNullVector;
  5818. private _normalVector;
  5819. /**
  5820. * Updates the point at data for an interpolated point along this curve
  5821. * @param position the position of the point along this curve, from 0.0 to 1.0
  5822. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5823. * @returns the (updated) point at data
  5824. */
  5825. private _updatePointAtData;
  5826. /**
  5827. * Updates the point at data from the specified parameters
  5828. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5829. * @param point the interpolated point
  5830. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5831. */
  5832. private _setPointAtData;
  5833. /**
  5834. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5835. */
  5836. private _updateInterpolationMatrix;
  5837. }
  5838. /**
  5839. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5840. * A Curve3 is designed from a series of successive Vector3.
  5841. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5842. */
  5843. export class Curve3 {
  5844. private _points;
  5845. private _length;
  5846. /**
  5847. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5848. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5849. * @param v1 (Vector3) the control point
  5850. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5851. * @param nbPoints (integer) the wanted number of points in the curve
  5852. * @returns the created Curve3
  5853. */
  5854. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5855. /**
  5856. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5857. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5858. * @param v1 (Vector3) the first control point
  5859. * @param v2 (Vector3) the second control point
  5860. * @param v3 (Vector3) the end point of the Cubic Bezier
  5861. * @param nbPoints (integer) the wanted number of points in the curve
  5862. * @returns the created Curve3
  5863. */
  5864. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5865. /**
  5866. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5867. * @param p1 (Vector3) the origin point of the Hermite Spline
  5868. * @param t1 (Vector3) the tangent vector at the origin point
  5869. * @param p2 (Vector3) the end point of the Hermite Spline
  5870. * @param t2 (Vector3) the tangent vector at the end point
  5871. * @param nbPoints (integer) the wanted number of points in the curve
  5872. * @returns the created Curve3
  5873. */
  5874. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5875. /**
  5876. * Returns a Curve3 object along a CatmullRom Spline curve :
  5877. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5878. * @param nbPoints (integer) the wanted number of points between each curve control points
  5879. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5880. * @returns the created Curve3
  5881. */
  5882. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5883. /**
  5884. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5885. * A Curve3 is designed from a series of successive Vector3.
  5886. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5887. * @param points points which make up the curve
  5888. */
  5889. constructor(points: Vector3[]);
  5890. /**
  5891. * @returns the Curve3 stored array of successive Vector3
  5892. */
  5893. getPoints(): Vector3[];
  5894. /**
  5895. * @returns the computed length (float) of the curve.
  5896. */
  5897. length(): number;
  5898. /**
  5899. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5900. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5901. * curveA and curveB keep unchanged.
  5902. * @param curve the curve to continue from this curve
  5903. * @returns the newly constructed curve
  5904. */
  5905. continue(curve: DeepImmutable<Curve3>): Curve3;
  5906. private _computeLength;
  5907. }
  5908. }
  5909. declare module BABYLON {
  5910. /**
  5911. * This represents the main contract an easing function should follow.
  5912. * Easing functions are used throughout the animation system.
  5913. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5914. */
  5915. export interface IEasingFunction {
  5916. /**
  5917. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5918. * of the easing function.
  5919. * The link below provides some of the most common examples of easing functions.
  5920. * @see https://easings.net/
  5921. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5922. * @returns the corresponding value on the curve defined by the easing function
  5923. */
  5924. ease(gradient: number): number;
  5925. }
  5926. /**
  5927. * Base class used for every default easing function.
  5928. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5929. */
  5930. export class EasingFunction implements IEasingFunction {
  5931. /**
  5932. * Interpolation follows the mathematical formula associated with the easing function.
  5933. */
  5934. static readonly EASINGMODE_EASEIN: number;
  5935. /**
  5936. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5937. */
  5938. static readonly EASINGMODE_EASEOUT: number;
  5939. /**
  5940. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5941. */
  5942. static readonly EASINGMODE_EASEINOUT: number;
  5943. private _easingMode;
  5944. /**
  5945. * Sets the easing mode of the current function.
  5946. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5947. */
  5948. setEasingMode(easingMode: number): void;
  5949. /**
  5950. * Gets the current easing mode.
  5951. * @returns the easing mode
  5952. */
  5953. getEasingMode(): number;
  5954. /**
  5955. * @hidden
  5956. */
  5957. easeInCore(gradient: number): number;
  5958. /**
  5959. * Given an input gradient between 0 and 1, this returns the corresponding value
  5960. * of the easing function.
  5961. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5962. * @returns the corresponding value on the curve defined by the easing function
  5963. */
  5964. ease(gradient: number): number;
  5965. }
  5966. /**
  5967. * Easing function with a circle shape (see link below).
  5968. * @see https://easings.net/#easeInCirc
  5969. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5970. */
  5971. export class CircleEase extends EasingFunction implements IEasingFunction {
  5972. /** @hidden */
  5973. easeInCore(gradient: number): number;
  5974. }
  5975. /**
  5976. * Easing function with a ease back shape (see link below).
  5977. * @see https://easings.net/#easeInBack
  5978. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5979. */
  5980. export class BackEase extends EasingFunction implements IEasingFunction {
  5981. /** Defines the amplitude of the function */
  5982. amplitude: number;
  5983. /**
  5984. * Instantiates a back ease easing
  5985. * @see https://easings.net/#easeInBack
  5986. * @param amplitude Defines the amplitude of the function
  5987. */
  5988. constructor(
  5989. /** Defines the amplitude of the function */
  5990. amplitude?: number);
  5991. /** @hidden */
  5992. easeInCore(gradient: number): number;
  5993. }
  5994. /**
  5995. * Easing function with a bouncing shape (see link below).
  5996. * @see https://easings.net/#easeInBounce
  5997. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5998. */
  5999. export class BounceEase extends EasingFunction implements IEasingFunction {
  6000. /** Defines the number of bounces */
  6001. bounces: number;
  6002. /** Defines the amplitude of the bounce */
  6003. bounciness: number;
  6004. /**
  6005. * Instantiates a bounce easing
  6006. * @see https://easings.net/#easeInBounce
  6007. * @param bounces Defines the number of bounces
  6008. * @param bounciness Defines the amplitude of the bounce
  6009. */
  6010. constructor(
  6011. /** Defines the number of bounces */
  6012. bounces?: number,
  6013. /** Defines the amplitude of the bounce */
  6014. bounciness?: number);
  6015. /** @hidden */
  6016. easeInCore(gradient: number): number;
  6017. }
  6018. /**
  6019. * Easing function with a power of 3 shape (see link below).
  6020. * @see https://easings.net/#easeInCubic
  6021. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6022. */
  6023. export class CubicEase extends EasingFunction implements IEasingFunction {
  6024. /** @hidden */
  6025. easeInCore(gradient: number): number;
  6026. }
  6027. /**
  6028. * Easing function with an elastic shape (see link below).
  6029. * @see https://easings.net/#easeInElastic
  6030. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6031. */
  6032. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6033. /** Defines the number of oscillations*/
  6034. oscillations: number;
  6035. /** Defines the amplitude of the oscillations*/
  6036. springiness: number;
  6037. /**
  6038. * Instantiates an elastic easing function
  6039. * @see https://easings.net/#easeInElastic
  6040. * @param oscillations Defines the number of oscillations
  6041. * @param springiness Defines the amplitude of the oscillations
  6042. */
  6043. constructor(
  6044. /** Defines the number of oscillations*/
  6045. oscillations?: number,
  6046. /** Defines the amplitude of the oscillations*/
  6047. springiness?: number);
  6048. /** @hidden */
  6049. easeInCore(gradient: number): number;
  6050. }
  6051. /**
  6052. * Easing function with an exponential shape (see link below).
  6053. * @see https://easings.net/#easeInExpo
  6054. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6055. */
  6056. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6057. /** Defines the exponent of the function */
  6058. exponent: number;
  6059. /**
  6060. * Instantiates an exponential easing function
  6061. * @see https://easings.net/#easeInExpo
  6062. * @param exponent Defines the exponent of the function
  6063. */
  6064. constructor(
  6065. /** Defines the exponent of the function */
  6066. exponent?: number);
  6067. /** @hidden */
  6068. easeInCore(gradient: number): number;
  6069. }
  6070. /**
  6071. * Easing function with a power shape (see link below).
  6072. * @see https://easings.net/#easeInQuad
  6073. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6074. */
  6075. export class PowerEase extends EasingFunction implements IEasingFunction {
  6076. /** Defines the power of the function */
  6077. power: number;
  6078. /**
  6079. * Instantiates an power base easing function
  6080. * @see https://easings.net/#easeInQuad
  6081. * @param power Defines the power of the function
  6082. */
  6083. constructor(
  6084. /** Defines the power of the function */
  6085. power?: number);
  6086. /** @hidden */
  6087. easeInCore(gradient: number): number;
  6088. }
  6089. /**
  6090. * Easing function with a power of 2 shape (see link below).
  6091. * @see https://easings.net/#easeInQuad
  6092. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6093. */
  6094. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6095. /** @hidden */
  6096. easeInCore(gradient: number): number;
  6097. }
  6098. /**
  6099. * Easing function with a power of 4 shape (see link below).
  6100. * @see https://easings.net/#easeInQuart
  6101. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6102. */
  6103. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6104. /** @hidden */
  6105. easeInCore(gradient: number): number;
  6106. }
  6107. /**
  6108. * Easing function with a power of 5 shape (see link below).
  6109. * @see https://easings.net/#easeInQuint
  6110. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6111. */
  6112. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6113. /** @hidden */
  6114. easeInCore(gradient: number): number;
  6115. }
  6116. /**
  6117. * Easing function with a sin shape (see link below).
  6118. * @see https://easings.net/#easeInSine
  6119. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6120. */
  6121. export class SineEase extends EasingFunction implements IEasingFunction {
  6122. /** @hidden */
  6123. easeInCore(gradient: number): number;
  6124. }
  6125. /**
  6126. * Easing function with a bezier shape (see link below).
  6127. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6128. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6129. */
  6130. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6131. /** Defines the x component of the start tangent in the bezier curve */
  6132. x1: number;
  6133. /** Defines the y component of the start tangent in the bezier curve */
  6134. y1: number;
  6135. /** Defines the x component of the end tangent in the bezier curve */
  6136. x2: number;
  6137. /** Defines the y component of the end tangent in the bezier curve */
  6138. y2: number;
  6139. /**
  6140. * Instantiates a bezier function
  6141. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6142. * @param x1 Defines the x component of the start tangent in the bezier curve
  6143. * @param y1 Defines the y component of the start tangent in the bezier curve
  6144. * @param x2 Defines the x component of the end tangent in the bezier curve
  6145. * @param y2 Defines the y component of the end tangent in the bezier curve
  6146. */
  6147. constructor(
  6148. /** Defines the x component of the start tangent in the bezier curve */
  6149. x1?: number,
  6150. /** Defines the y component of the start tangent in the bezier curve */
  6151. y1?: number,
  6152. /** Defines the x component of the end tangent in the bezier curve */
  6153. x2?: number,
  6154. /** Defines the y component of the end tangent in the bezier curve */
  6155. y2?: number);
  6156. /** @hidden */
  6157. easeInCore(gradient: number): number;
  6158. }
  6159. }
  6160. declare module BABYLON {
  6161. /**
  6162. * Class used to hold a RBG color
  6163. */
  6164. export class Color3 {
  6165. /**
  6166. * Defines the red component (between 0 and 1, default is 0)
  6167. */
  6168. r: number;
  6169. /**
  6170. * Defines the green component (between 0 and 1, default is 0)
  6171. */
  6172. g: number;
  6173. /**
  6174. * Defines the blue component (between 0 and 1, default is 0)
  6175. */
  6176. b: number;
  6177. /**
  6178. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6179. * @param r defines the red component (between 0 and 1, default is 0)
  6180. * @param g defines the green component (between 0 and 1, default is 0)
  6181. * @param b defines the blue component (between 0 and 1, default is 0)
  6182. */
  6183. constructor(
  6184. /**
  6185. * Defines the red component (between 0 and 1, default is 0)
  6186. */
  6187. r?: number,
  6188. /**
  6189. * Defines the green component (between 0 and 1, default is 0)
  6190. */
  6191. g?: number,
  6192. /**
  6193. * Defines the blue component (between 0 and 1, default is 0)
  6194. */
  6195. b?: number);
  6196. /**
  6197. * Creates a string with the Color3 current values
  6198. * @returns the string representation of the Color3 object
  6199. */
  6200. toString(): string;
  6201. /**
  6202. * Returns the string "Color3"
  6203. * @returns "Color3"
  6204. */
  6205. getClassName(): string;
  6206. /**
  6207. * Compute the Color3 hash code
  6208. * @returns an unique number that can be used to hash Color3 objects
  6209. */
  6210. getHashCode(): number;
  6211. /**
  6212. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6213. * @param array defines the array where to store the r,g,b components
  6214. * @param index defines an optional index in the target array to define where to start storing values
  6215. * @returns the current Color3 object
  6216. */
  6217. toArray(array: FloatArray, index?: number): Color3;
  6218. /**
  6219. * Update the current color with values stored in an array from the starting index of the given array
  6220. * @param array defines the source array
  6221. * @param offset defines an offset in the source array
  6222. * @returns the current Color3 object
  6223. */
  6224. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6225. /**
  6226. * Returns a new Color4 object from the current Color3 and the given alpha
  6227. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6228. * @returns a new Color4 object
  6229. */
  6230. toColor4(alpha?: number): Color4;
  6231. /**
  6232. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6233. * @returns the new array
  6234. */
  6235. asArray(): number[];
  6236. /**
  6237. * Returns the luminance value
  6238. * @returns a float value
  6239. */
  6240. toLuminance(): number;
  6241. /**
  6242. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6243. * @param otherColor defines the second operand
  6244. * @returns the new Color3 object
  6245. */
  6246. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6247. /**
  6248. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6249. * @param otherColor defines the second operand
  6250. * @param result defines the Color3 object where to store the result
  6251. * @returns the current Color3
  6252. */
  6253. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6254. /**
  6255. * Determines equality between Color3 objects
  6256. * @param otherColor defines the second operand
  6257. * @returns true if the rgb values are equal to the given ones
  6258. */
  6259. equals(otherColor: DeepImmutable<Color3>): boolean;
  6260. /**
  6261. * Determines equality between the current Color3 object and a set of r,b,g values
  6262. * @param r defines the red component to check
  6263. * @param g defines the green component to check
  6264. * @param b defines the blue component to check
  6265. * @returns true if the rgb values are equal to the given ones
  6266. */
  6267. equalsFloats(r: number, g: number, b: number): boolean;
  6268. /**
  6269. * Multiplies in place each rgb value by scale
  6270. * @param scale defines the scaling factor
  6271. * @returns the updated Color3
  6272. */
  6273. scale(scale: number): Color3;
  6274. /**
  6275. * Multiplies the rgb values by scale and stores the result into "result"
  6276. * @param scale defines the scaling factor
  6277. * @param result defines the Color3 object where to store the result
  6278. * @returns the unmodified current Color3
  6279. */
  6280. scaleToRef(scale: number, result: Color3): Color3;
  6281. /**
  6282. * Scale the current Color3 values by a factor and add the result to a given Color3
  6283. * @param scale defines the scale factor
  6284. * @param result defines color to store the result into
  6285. * @returns the unmodified current Color3
  6286. */
  6287. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6288. /**
  6289. * Clamps the rgb values by the min and max values and stores the result into "result"
  6290. * @param min defines minimum clamping value (default is 0)
  6291. * @param max defines maximum clamping value (default is 1)
  6292. * @param result defines color to store the result into
  6293. * @returns the original Color3
  6294. */
  6295. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6296. /**
  6297. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6298. * @param otherColor defines the second operand
  6299. * @returns the new Color3
  6300. */
  6301. add(otherColor: DeepImmutable<Color3>): Color3;
  6302. /**
  6303. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6304. * @param otherColor defines the second operand
  6305. * @param result defines Color3 object to store the result into
  6306. * @returns the unmodified current Color3
  6307. */
  6308. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6309. /**
  6310. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6311. * @param otherColor defines the second operand
  6312. * @returns the new Color3
  6313. */
  6314. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6315. /**
  6316. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6317. * @param otherColor defines the second operand
  6318. * @param result defines Color3 object to store the result into
  6319. * @returns the unmodified current Color3
  6320. */
  6321. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6322. /**
  6323. * Copy the current object
  6324. * @returns a new Color3 copied the current one
  6325. */
  6326. clone(): Color3;
  6327. /**
  6328. * Copies the rgb values from the source in the current Color3
  6329. * @param source defines the source Color3 object
  6330. * @returns the updated Color3 object
  6331. */
  6332. copyFrom(source: DeepImmutable<Color3>): Color3;
  6333. /**
  6334. * Updates the Color3 rgb values from the given floats
  6335. * @param r defines the red component to read from
  6336. * @param g defines the green component to read from
  6337. * @param b defines the blue component to read from
  6338. * @returns the current Color3 object
  6339. */
  6340. copyFromFloats(r: number, g: number, b: number): Color3;
  6341. /**
  6342. * Updates the Color3 rgb values from the given floats
  6343. * @param r defines the red component to read from
  6344. * @param g defines the green component to read from
  6345. * @param b defines the blue component to read from
  6346. * @returns the current Color3 object
  6347. */
  6348. set(r: number, g: number, b: number): Color3;
  6349. /**
  6350. * Compute the Color3 hexadecimal code as a string
  6351. * @returns a string containing the hexadecimal representation of the Color3 object
  6352. */
  6353. toHexString(): string;
  6354. /**
  6355. * Computes a new Color3 converted from the current one to linear space
  6356. * @returns a new Color3 object
  6357. */
  6358. toLinearSpace(): Color3;
  6359. /**
  6360. * Converts current color in rgb space to HSV values
  6361. * @returns a new color3 representing the HSV values
  6362. */
  6363. toHSV(): Color3;
  6364. /**
  6365. * Converts current color in rgb space to HSV values
  6366. * @param result defines the Color3 where to store the HSV values
  6367. */
  6368. toHSVToRef(result: Color3): void;
  6369. /**
  6370. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6371. * @param convertedColor defines the Color3 object where to store the linear space version
  6372. * @returns the unmodified Color3
  6373. */
  6374. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6375. /**
  6376. * Computes a new Color3 converted from the current one to gamma space
  6377. * @returns a new Color3 object
  6378. */
  6379. toGammaSpace(): Color3;
  6380. /**
  6381. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6382. * @param convertedColor defines the Color3 object where to store the gamma space version
  6383. * @returns the unmodified Color3
  6384. */
  6385. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6386. private static _BlackReadOnly;
  6387. /**
  6388. * Convert Hue, saturation and value to a Color3 (RGB)
  6389. * @param hue defines the hue
  6390. * @param saturation defines the saturation
  6391. * @param value defines the value
  6392. * @param result defines the Color3 where to store the RGB values
  6393. */
  6394. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6395. /**
  6396. * Creates a new Color3 from the string containing valid hexadecimal values
  6397. * @param hex defines a string containing valid hexadecimal values
  6398. * @returns a new Color3 object
  6399. */
  6400. static FromHexString(hex: string): Color3;
  6401. /**
  6402. * Creates a new Color3 from the starting index of the given array
  6403. * @param array defines the source array
  6404. * @param offset defines an offset in the source array
  6405. * @returns a new Color3 object
  6406. */
  6407. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6408. /**
  6409. * Creates a new Color3 from the starting index element of the given array
  6410. * @param array defines the source array to read from
  6411. * @param offset defines the offset in the source array
  6412. * @param result defines the target Color3 object
  6413. */
  6414. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6415. /**
  6416. * Creates a new Color3 from integer values (< 256)
  6417. * @param r defines the red component to read from (value between 0 and 255)
  6418. * @param g defines the green component to read from (value between 0 and 255)
  6419. * @param b defines the blue component to read from (value between 0 and 255)
  6420. * @returns a new Color3 object
  6421. */
  6422. static FromInts(r: number, g: number, b: number): Color3;
  6423. /**
  6424. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6425. * @param start defines the start Color3 value
  6426. * @param end defines the end Color3 value
  6427. * @param amount defines the gradient value between start and end
  6428. * @returns a new Color3 object
  6429. */
  6430. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6431. /**
  6432. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6433. * @param left defines the start value
  6434. * @param right defines the end value
  6435. * @param amount defines the gradient factor
  6436. * @param result defines the Color3 object where to store the result
  6437. */
  6438. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6439. /**
  6440. * Returns a Color3 value containing a red color
  6441. * @returns a new Color3 object
  6442. */
  6443. static Red(): Color3;
  6444. /**
  6445. * Returns a Color3 value containing a green color
  6446. * @returns a new Color3 object
  6447. */
  6448. static Green(): Color3;
  6449. /**
  6450. * Returns a Color3 value containing a blue color
  6451. * @returns a new Color3 object
  6452. */
  6453. static Blue(): Color3;
  6454. /**
  6455. * Returns a Color3 value containing a black color
  6456. * @returns a new Color3 object
  6457. */
  6458. static Black(): Color3;
  6459. /**
  6460. * Gets a Color3 value containing a black color that must not be updated
  6461. */
  6462. static get BlackReadOnly(): DeepImmutable<Color3>;
  6463. /**
  6464. * Returns a Color3 value containing a white color
  6465. * @returns a new Color3 object
  6466. */
  6467. static White(): Color3;
  6468. /**
  6469. * Returns a Color3 value containing a purple color
  6470. * @returns a new Color3 object
  6471. */
  6472. static Purple(): Color3;
  6473. /**
  6474. * Returns a Color3 value containing a magenta color
  6475. * @returns a new Color3 object
  6476. */
  6477. static Magenta(): Color3;
  6478. /**
  6479. * Returns a Color3 value containing a yellow color
  6480. * @returns a new Color3 object
  6481. */
  6482. static Yellow(): Color3;
  6483. /**
  6484. * Returns a Color3 value containing a gray color
  6485. * @returns a new Color3 object
  6486. */
  6487. static Gray(): Color3;
  6488. /**
  6489. * Returns a Color3 value containing a teal color
  6490. * @returns a new Color3 object
  6491. */
  6492. static Teal(): Color3;
  6493. /**
  6494. * Returns a Color3 value containing a random color
  6495. * @returns a new Color3 object
  6496. */
  6497. static Random(): Color3;
  6498. }
  6499. /**
  6500. * Class used to hold a RBGA color
  6501. */
  6502. export class Color4 {
  6503. /**
  6504. * Defines the red component (between 0 and 1, default is 0)
  6505. */
  6506. r: number;
  6507. /**
  6508. * Defines the green component (between 0 and 1, default is 0)
  6509. */
  6510. g: number;
  6511. /**
  6512. * Defines the blue component (between 0 and 1, default is 0)
  6513. */
  6514. b: number;
  6515. /**
  6516. * Defines the alpha component (between 0 and 1, default is 1)
  6517. */
  6518. a: number;
  6519. /**
  6520. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6521. * @param r defines the red component (between 0 and 1, default is 0)
  6522. * @param g defines the green component (between 0 and 1, default is 0)
  6523. * @param b defines the blue component (between 0 and 1, default is 0)
  6524. * @param a defines the alpha component (between 0 and 1, default is 1)
  6525. */
  6526. constructor(
  6527. /**
  6528. * Defines the red component (between 0 and 1, default is 0)
  6529. */
  6530. r?: number,
  6531. /**
  6532. * Defines the green component (between 0 and 1, default is 0)
  6533. */
  6534. g?: number,
  6535. /**
  6536. * Defines the blue component (between 0 and 1, default is 0)
  6537. */
  6538. b?: number,
  6539. /**
  6540. * Defines the alpha component (between 0 and 1, default is 1)
  6541. */
  6542. a?: number);
  6543. /**
  6544. * Adds in place the given Color4 values to the current Color4 object
  6545. * @param right defines the second operand
  6546. * @returns the current updated Color4 object
  6547. */
  6548. addInPlace(right: DeepImmutable<Color4>): Color4;
  6549. /**
  6550. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6551. * @returns the new array
  6552. */
  6553. asArray(): number[];
  6554. /**
  6555. * Stores from the starting index in the given array the Color4 successive values
  6556. * @param array defines the array where to store the r,g,b components
  6557. * @param index defines an optional index in the target array to define where to start storing values
  6558. * @returns the current Color4 object
  6559. */
  6560. toArray(array: number[], index?: number): Color4;
  6561. /**
  6562. * Update the current color with values stored in an array from the starting index of the given array
  6563. * @param array defines the source array
  6564. * @param offset defines an offset in the source array
  6565. * @returns the current Color4 object
  6566. */
  6567. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6568. /**
  6569. * Determines equality between Color4 objects
  6570. * @param otherColor defines the second operand
  6571. * @returns true if the rgba values are equal to the given ones
  6572. */
  6573. equals(otherColor: DeepImmutable<Color4>): boolean;
  6574. /**
  6575. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6576. * @param right defines the second operand
  6577. * @returns a new Color4 object
  6578. */
  6579. add(right: DeepImmutable<Color4>): Color4;
  6580. /**
  6581. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6582. * @param right defines the second operand
  6583. * @returns a new Color4 object
  6584. */
  6585. subtract(right: DeepImmutable<Color4>): Color4;
  6586. /**
  6587. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6588. * @param right defines the second operand
  6589. * @param result defines the Color4 object where to store the result
  6590. * @returns the current Color4 object
  6591. */
  6592. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6593. /**
  6594. * Creates a new Color4 with the current Color4 values multiplied by scale
  6595. * @param scale defines the scaling factor to apply
  6596. * @returns a new Color4 object
  6597. */
  6598. scale(scale: number): Color4;
  6599. /**
  6600. * Multiplies the current Color4 values by scale and stores the result in "result"
  6601. * @param scale defines the scaling factor to apply
  6602. * @param result defines the Color4 object where to store the result
  6603. * @returns the current unmodified Color4
  6604. */
  6605. scaleToRef(scale: number, result: Color4): Color4;
  6606. /**
  6607. * Scale the current Color4 values by a factor and add the result to a given Color4
  6608. * @param scale defines the scale factor
  6609. * @param result defines the Color4 object where to store the result
  6610. * @returns the unmodified current Color4
  6611. */
  6612. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6613. /**
  6614. * Clamps the rgb values by the min and max values and stores the result into "result"
  6615. * @param min defines minimum clamping value (default is 0)
  6616. * @param max defines maximum clamping value (default is 1)
  6617. * @param result defines color to store the result into.
  6618. * @returns the cuurent Color4
  6619. */
  6620. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6621. /**
  6622. * Multipy an Color4 value by another and return a new Color4 object
  6623. * @param color defines the Color4 value to multiply by
  6624. * @returns a new Color4 object
  6625. */
  6626. multiply(color: Color4): Color4;
  6627. /**
  6628. * Multipy a Color4 value by another and push the result in a reference value
  6629. * @param color defines the Color4 value to multiply by
  6630. * @param result defines the Color4 to fill the result in
  6631. * @returns the result Color4
  6632. */
  6633. multiplyToRef(color: Color4, result: Color4): Color4;
  6634. /**
  6635. * Creates a string with the Color4 current values
  6636. * @returns the string representation of the Color4 object
  6637. */
  6638. toString(): string;
  6639. /**
  6640. * Returns the string "Color4"
  6641. * @returns "Color4"
  6642. */
  6643. getClassName(): string;
  6644. /**
  6645. * Compute the Color4 hash code
  6646. * @returns an unique number that can be used to hash Color4 objects
  6647. */
  6648. getHashCode(): number;
  6649. /**
  6650. * Creates a new Color4 copied from the current one
  6651. * @returns a new Color4 object
  6652. */
  6653. clone(): Color4;
  6654. /**
  6655. * Copies the given Color4 values into the current one
  6656. * @param source defines the source Color4 object
  6657. * @returns the current updated Color4 object
  6658. */
  6659. copyFrom(source: Color4): Color4;
  6660. /**
  6661. * Copies the given float values into the current one
  6662. * @param r defines the red component to read from
  6663. * @param g defines the green component to read from
  6664. * @param b defines the blue component to read from
  6665. * @param a defines the alpha component to read from
  6666. * @returns the current updated Color4 object
  6667. */
  6668. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6669. /**
  6670. * Copies the given float values into the current one
  6671. * @param r defines the red component to read from
  6672. * @param g defines the green component to read from
  6673. * @param b defines the blue component to read from
  6674. * @param a defines the alpha component to read from
  6675. * @returns the current updated Color4 object
  6676. */
  6677. set(r: number, g: number, b: number, a: number): Color4;
  6678. /**
  6679. * Compute the Color4 hexadecimal code as a string
  6680. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6681. * @returns a string containing the hexadecimal representation of the Color4 object
  6682. */
  6683. toHexString(returnAsColor3?: boolean): string;
  6684. /**
  6685. * Computes a new Color4 converted from the current one to linear space
  6686. * @returns a new Color4 object
  6687. */
  6688. toLinearSpace(): Color4;
  6689. /**
  6690. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6691. * @param convertedColor defines the Color4 object where to store the linear space version
  6692. * @returns the unmodified Color4
  6693. */
  6694. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6695. /**
  6696. * Computes a new Color4 converted from the current one to gamma space
  6697. * @returns a new Color4 object
  6698. */
  6699. toGammaSpace(): Color4;
  6700. /**
  6701. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6702. * @param convertedColor defines the Color4 object where to store the gamma space version
  6703. * @returns the unmodified Color4
  6704. */
  6705. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6706. /**
  6707. * Creates a new Color4 from the string containing valid hexadecimal values
  6708. * @param hex defines a string containing valid hexadecimal values
  6709. * @returns a new Color4 object
  6710. */
  6711. static FromHexString(hex: string): Color4;
  6712. /**
  6713. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6714. * @param left defines the start value
  6715. * @param right defines the end value
  6716. * @param amount defines the gradient factor
  6717. * @returns a new Color4 object
  6718. */
  6719. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6720. /**
  6721. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6722. * @param left defines the start value
  6723. * @param right defines the end value
  6724. * @param amount defines the gradient factor
  6725. * @param result defines the Color4 object where to store data
  6726. */
  6727. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6728. /**
  6729. * Creates a new Color4 from a Color3 and an alpha value
  6730. * @param color3 defines the source Color3 to read from
  6731. * @param alpha defines the alpha component (1.0 by default)
  6732. * @returns a new Color4 object
  6733. */
  6734. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6735. /**
  6736. * Creates a new Color4 from the starting index element of the given array
  6737. * @param array defines the source array to read from
  6738. * @param offset defines the offset in the source array
  6739. * @returns a new Color4 object
  6740. */
  6741. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6742. /**
  6743. * Creates a new Color4 from the starting index element of the given array
  6744. * @param array defines the source array to read from
  6745. * @param offset defines the offset in the source array
  6746. * @param result defines the target Color4 object
  6747. */
  6748. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6749. /**
  6750. * Creates a new Color3 from integer values (< 256)
  6751. * @param r defines the red component to read from (value between 0 and 255)
  6752. * @param g defines the green component to read from (value between 0 and 255)
  6753. * @param b defines the blue component to read from (value between 0 and 255)
  6754. * @param a defines the alpha component to read from (value between 0 and 255)
  6755. * @returns a new Color3 object
  6756. */
  6757. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6758. /**
  6759. * Check the content of a given array and convert it to an array containing RGBA data
  6760. * If the original array was already containing count * 4 values then it is returned directly
  6761. * @param colors defines the array to check
  6762. * @param count defines the number of RGBA data to expect
  6763. * @returns an array containing count * 4 values (RGBA)
  6764. */
  6765. static CheckColors4(colors: number[], count: number): number[];
  6766. }
  6767. /**
  6768. * @hidden
  6769. */
  6770. export class TmpColors {
  6771. static Color3: Color3[];
  6772. static Color4: Color4[];
  6773. }
  6774. }
  6775. declare module BABYLON {
  6776. /**
  6777. * Defines an interface which represents an animation key frame
  6778. */
  6779. export interface IAnimationKey {
  6780. /**
  6781. * Frame of the key frame
  6782. */
  6783. frame: number;
  6784. /**
  6785. * Value at the specifies key frame
  6786. */
  6787. value: any;
  6788. /**
  6789. * The input tangent for the cubic hermite spline
  6790. */
  6791. inTangent?: any;
  6792. /**
  6793. * The output tangent for the cubic hermite spline
  6794. */
  6795. outTangent?: any;
  6796. /**
  6797. * The animation interpolation type
  6798. */
  6799. interpolation?: AnimationKeyInterpolation;
  6800. }
  6801. /**
  6802. * Enum for the animation key frame interpolation type
  6803. */
  6804. export enum AnimationKeyInterpolation {
  6805. /**
  6806. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6807. */
  6808. STEP = 1
  6809. }
  6810. }
  6811. declare module BABYLON {
  6812. /**
  6813. * Represents the range of an animation
  6814. */
  6815. export class AnimationRange {
  6816. /**The name of the animation range**/
  6817. name: string;
  6818. /**The starting frame of the animation */
  6819. from: number;
  6820. /**The ending frame of the animation*/
  6821. to: number;
  6822. /**
  6823. * Initializes the range of an animation
  6824. * @param name The name of the animation range
  6825. * @param from The starting frame of the animation
  6826. * @param to The ending frame of the animation
  6827. */
  6828. constructor(
  6829. /**The name of the animation range**/
  6830. name: string,
  6831. /**The starting frame of the animation */
  6832. from: number,
  6833. /**The ending frame of the animation*/
  6834. to: number);
  6835. /**
  6836. * Makes a copy of the animation range
  6837. * @returns A copy of the animation range
  6838. */
  6839. clone(): AnimationRange;
  6840. }
  6841. }
  6842. declare module BABYLON {
  6843. /**
  6844. * Composed of a frame, and an action function
  6845. */
  6846. export class AnimationEvent {
  6847. /** The frame for which the event is triggered **/
  6848. frame: number;
  6849. /** The event to perform when triggered **/
  6850. action: (currentFrame: number) => void;
  6851. /** Specifies if the event should be triggered only once**/
  6852. onlyOnce?: boolean | undefined;
  6853. /**
  6854. * Specifies if the animation event is done
  6855. */
  6856. isDone: boolean;
  6857. /**
  6858. * Initializes the animation event
  6859. * @param frame The frame for which the event is triggered
  6860. * @param action The event to perform when triggered
  6861. * @param onlyOnce Specifies if the event should be triggered only once
  6862. */
  6863. constructor(
  6864. /** The frame for which the event is triggered **/
  6865. frame: number,
  6866. /** The event to perform when triggered **/
  6867. action: (currentFrame: number) => void,
  6868. /** Specifies if the event should be triggered only once**/
  6869. onlyOnce?: boolean | undefined);
  6870. /** @hidden */
  6871. _clone(): AnimationEvent;
  6872. }
  6873. }
  6874. declare module BABYLON {
  6875. /**
  6876. * Interface used to define a behavior
  6877. */
  6878. export interface Behavior<T> {
  6879. /** gets or sets behavior's name */
  6880. name: string;
  6881. /**
  6882. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6883. */
  6884. init(): void;
  6885. /**
  6886. * Called when the behavior is attached to a target
  6887. * @param target defines the target where the behavior is attached to
  6888. */
  6889. attach(target: T): void;
  6890. /**
  6891. * Called when the behavior is detached from its target
  6892. */
  6893. detach(): void;
  6894. }
  6895. /**
  6896. * Interface implemented by classes supporting behaviors
  6897. */
  6898. export interface IBehaviorAware<T> {
  6899. /**
  6900. * Attach a behavior
  6901. * @param behavior defines the behavior to attach
  6902. * @returns the current host
  6903. */
  6904. addBehavior(behavior: Behavior<T>): T;
  6905. /**
  6906. * Remove a behavior from the current object
  6907. * @param behavior defines the behavior to detach
  6908. * @returns the current host
  6909. */
  6910. removeBehavior(behavior: Behavior<T>): T;
  6911. /**
  6912. * Gets a behavior using its name to search
  6913. * @param name defines the name to search
  6914. * @returns the behavior or null if not found
  6915. */
  6916. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6917. }
  6918. }
  6919. declare module BABYLON {
  6920. /**
  6921. * Class used to store data that will be store in GPU memory
  6922. */
  6923. export class Buffer {
  6924. private _engine;
  6925. private _buffer;
  6926. /** @hidden */
  6927. _data: Nullable<DataArray>;
  6928. private _updatable;
  6929. private _instanced;
  6930. private _divisor;
  6931. private _isAlreadyOwned;
  6932. /**
  6933. * Gets the byte stride.
  6934. */
  6935. readonly byteStride: number;
  6936. /**
  6937. * Constructor
  6938. * @param engine the engine
  6939. * @param data the data to use for this buffer
  6940. * @param updatable whether the data is updatable
  6941. * @param stride the stride (optional)
  6942. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6943. * @param instanced whether the buffer is instanced (optional)
  6944. * @param useBytes set to true if the stride in in bytes (optional)
  6945. * @param divisor sets an optional divisor for instances (1 by default)
  6946. */
  6947. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6948. /**
  6949. * Create a new VertexBuffer based on the current buffer
  6950. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6951. * @param offset defines offset in the buffer (0 by default)
  6952. * @param size defines the size in floats of attributes (position is 3 for instance)
  6953. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6954. * @param instanced defines if the vertex buffer contains indexed data
  6955. * @param useBytes defines if the offset and stride are in bytes *
  6956. * @param divisor sets an optional divisor for instances (1 by default)
  6957. * @returns the new vertex buffer
  6958. */
  6959. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6960. /**
  6961. * Gets a boolean indicating if the Buffer is updatable?
  6962. * @returns true if the buffer is updatable
  6963. */
  6964. isUpdatable(): boolean;
  6965. /**
  6966. * Gets current buffer's data
  6967. * @returns a DataArray or null
  6968. */
  6969. getData(): Nullable<DataArray>;
  6970. /**
  6971. * Gets underlying native buffer
  6972. * @returns underlying native buffer
  6973. */
  6974. getBuffer(): Nullable<DataBuffer>;
  6975. /**
  6976. * Gets the stride in float32 units (i.e. byte stride / 4).
  6977. * May not be an integer if the byte stride is not divisible by 4.
  6978. * @returns the stride in float32 units
  6979. * @deprecated Please use byteStride instead.
  6980. */
  6981. getStrideSize(): number;
  6982. /**
  6983. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6984. * @param data defines the data to store
  6985. */
  6986. create(data?: Nullable<DataArray>): void;
  6987. /** @hidden */
  6988. _rebuild(): void;
  6989. /**
  6990. * Update current buffer data
  6991. * @param data defines the data to store
  6992. */
  6993. update(data: DataArray): void;
  6994. /**
  6995. * Updates the data directly.
  6996. * @param data the new data
  6997. * @param offset the new offset
  6998. * @param vertexCount the vertex count (optional)
  6999. * @param useBytes set to true if the offset is in bytes
  7000. */
  7001. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7002. /** @hidden */
  7003. _increaseReferences(): void;
  7004. /**
  7005. * Release all resources
  7006. */
  7007. dispose(): void;
  7008. }
  7009. /**
  7010. * Specialized buffer used to store vertex data
  7011. */
  7012. export class VertexBuffer {
  7013. /** @hidden */
  7014. _buffer: Buffer;
  7015. private _kind;
  7016. private _size;
  7017. private _ownsBuffer;
  7018. private _instanced;
  7019. private _instanceDivisor;
  7020. /**
  7021. * The byte type.
  7022. */
  7023. static readonly BYTE: number;
  7024. /**
  7025. * The unsigned byte type.
  7026. */
  7027. static readonly UNSIGNED_BYTE: number;
  7028. /**
  7029. * The short type.
  7030. */
  7031. static readonly SHORT: number;
  7032. /**
  7033. * The unsigned short type.
  7034. */
  7035. static readonly UNSIGNED_SHORT: number;
  7036. /**
  7037. * The integer type.
  7038. */
  7039. static readonly INT: number;
  7040. /**
  7041. * The unsigned integer type.
  7042. */
  7043. static readonly UNSIGNED_INT: number;
  7044. /**
  7045. * The float type.
  7046. */
  7047. static readonly FLOAT: number;
  7048. /**
  7049. * Gets or sets the instance divisor when in instanced mode
  7050. */
  7051. get instanceDivisor(): number;
  7052. set instanceDivisor(value: number);
  7053. /**
  7054. * Gets the byte stride.
  7055. */
  7056. readonly byteStride: number;
  7057. /**
  7058. * Gets the byte offset.
  7059. */
  7060. readonly byteOffset: number;
  7061. /**
  7062. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7063. */
  7064. readonly normalized: boolean;
  7065. /**
  7066. * Gets the data type of each component in the array.
  7067. */
  7068. readonly type: number;
  7069. /**
  7070. * Constructor
  7071. * @param engine the engine
  7072. * @param data the data to use for this vertex buffer
  7073. * @param kind the vertex buffer kind
  7074. * @param updatable whether the data is updatable
  7075. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7076. * @param stride the stride (optional)
  7077. * @param instanced whether the buffer is instanced (optional)
  7078. * @param offset the offset of the data (optional)
  7079. * @param size the number of components (optional)
  7080. * @param type the type of the component (optional)
  7081. * @param normalized whether the data contains normalized data (optional)
  7082. * @param useBytes set to true if stride and offset are in bytes (optional)
  7083. * @param divisor defines the instance divisor to use (1 by default)
  7084. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7085. */
  7086. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number, takeBufferOwnership?: boolean);
  7087. /** @hidden */
  7088. _rebuild(): void;
  7089. /**
  7090. * Returns the kind of the VertexBuffer (string)
  7091. * @returns a string
  7092. */
  7093. getKind(): string;
  7094. /**
  7095. * Gets a boolean indicating if the VertexBuffer is updatable?
  7096. * @returns true if the buffer is updatable
  7097. */
  7098. isUpdatable(): boolean;
  7099. /**
  7100. * Gets current buffer's data
  7101. * @returns a DataArray or null
  7102. */
  7103. getData(): Nullable<DataArray>;
  7104. /**
  7105. * Gets underlying native buffer
  7106. * @returns underlying native buffer
  7107. */
  7108. getBuffer(): Nullable<DataBuffer>;
  7109. /**
  7110. * Gets the stride in float32 units (i.e. byte stride / 4).
  7111. * May not be an integer if the byte stride is not divisible by 4.
  7112. * @returns the stride in float32 units
  7113. * @deprecated Please use byteStride instead.
  7114. */
  7115. getStrideSize(): number;
  7116. /**
  7117. * Returns the offset as a multiple of the type byte length.
  7118. * @returns the offset in bytes
  7119. * @deprecated Please use byteOffset instead.
  7120. */
  7121. getOffset(): number;
  7122. /**
  7123. * Returns the number of components per vertex attribute (integer)
  7124. * @returns the size in float
  7125. */
  7126. getSize(): number;
  7127. /**
  7128. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7129. * @returns true if this buffer is instanced
  7130. */
  7131. getIsInstanced(): boolean;
  7132. /**
  7133. * Returns the instancing divisor, zero for non-instanced (integer).
  7134. * @returns a number
  7135. */
  7136. getInstanceDivisor(): number;
  7137. /**
  7138. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7139. * @param data defines the data to store
  7140. */
  7141. create(data?: DataArray): void;
  7142. /**
  7143. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7144. * This function will create a new buffer if the current one is not updatable
  7145. * @param data defines the data to store
  7146. */
  7147. update(data: DataArray): void;
  7148. /**
  7149. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7150. * Returns the directly updated WebGLBuffer.
  7151. * @param data the new data
  7152. * @param offset the new offset
  7153. * @param useBytes set to true if the offset is in bytes
  7154. */
  7155. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7156. /**
  7157. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7158. */
  7159. dispose(): void;
  7160. /**
  7161. * Enumerates each value of this vertex buffer as numbers.
  7162. * @param count the number of values to enumerate
  7163. * @param callback the callback function called for each value
  7164. */
  7165. forEach(count: number, callback: (value: number, index: number) => void): void;
  7166. /**
  7167. * Positions
  7168. */
  7169. static readonly PositionKind: string;
  7170. /**
  7171. * Normals
  7172. */
  7173. static readonly NormalKind: string;
  7174. /**
  7175. * Tangents
  7176. */
  7177. static readonly TangentKind: string;
  7178. /**
  7179. * Texture coordinates
  7180. */
  7181. static readonly UVKind: string;
  7182. /**
  7183. * Texture coordinates 2
  7184. */
  7185. static readonly UV2Kind: string;
  7186. /**
  7187. * Texture coordinates 3
  7188. */
  7189. static readonly UV3Kind: string;
  7190. /**
  7191. * Texture coordinates 4
  7192. */
  7193. static readonly UV4Kind: string;
  7194. /**
  7195. * Texture coordinates 5
  7196. */
  7197. static readonly UV5Kind: string;
  7198. /**
  7199. * Texture coordinates 6
  7200. */
  7201. static readonly UV6Kind: string;
  7202. /**
  7203. * Colors
  7204. */
  7205. static readonly ColorKind: string;
  7206. /**
  7207. * Matrix indices (for bones)
  7208. */
  7209. static readonly MatricesIndicesKind: string;
  7210. /**
  7211. * Matrix weights (for bones)
  7212. */
  7213. static readonly MatricesWeightsKind: string;
  7214. /**
  7215. * Additional matrix indices (for bones)
  7216. */
  7217. static readonly MatricesIndicesExtraKind: string;
  7218. /**
  7219. * Additional matrix weights (for bones)
  7220. */
  7221. static readonly MatricesWeightsExtraKind: string;
  7222. /**
  7223. * Deduces the stride given a kind.
  7224. * @param kind The kind string to deduce
  7225. * @returns The deduced stride
  7226. */
  7227. static DeduceStride(kind: string): number;
  7228. /**
  7229. * Gets the byte length of the given type.
  7230. * @param type the type
  7231. * @returns the number of bytes
  7232. */
  7233. static GetTypeByteLength(type: number): number;
  7234. /**
  7235. * Enumerates each value of the given parameters as numbers.
  7236. * @param data the data to enumerate
  7237. * @param byteOffset the byte offset of the data
  7238. * @param byteStride the byte stride of the data
  7239. * @param componentCount the number of components per element
  7240. * @param componentType the type of the component
  7241. * @param count the number of values to enumerate
  7242. * @param normalized whether the data is normalized
  7243. * @param callback the callback function called for each value
  7244. */
  7245. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7246. private static _GetFloatValue;
  7247. }
  7248. }
  7249. declare module BABYLON {
  7250. /**
  7251. * @hidden
  7252. */
  7253. export class IntersectionInfo {
  7254. bu: Nullable<number>;
  7255. bv: Nullable<number>;
  7256. distance: number;
  7257. faceId: number;
  7258. subMeshId: number;
  7259. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7260. }
  7261. }
  7262. declare module BABYLON {
  7263. /**
  7264. * Class used to store bounding sphere information
  7265. */
  7266. export class BoundingSphere {
  7267. /**
  7268. * Gets the center of the bounding sphere in local space
  7269. */
  7270. readonly center: Vector3;
  7271. /**
  7272. * Radius of the bounding sphere in local space
  7273. */
  7274. radius: number;
  7275. /**
  7276. * Gets the center of the bounding sphere in world space
  7277. */
  7278. readonly centerWorld: Vector3;
  7279. /**
  7280. * Radius of the bounding sphere in world space
  7281. */
  7282. radiusWorld: number;
  7283. /**
  7284. * Gets the minimum vector in local space
  7285. */
  7286. readonly minimum: Vector3;
  7287. /**
  7288. * Gets the maximum vector in local space
  7289. */
  7290. readonly maximum: Vector3;
  7291. private _worldMatrix;
  7292. private static readonly TmpVector3;
  7293. /**
  7294. * Creates a new bounding sphere
  7295. * @param min defines the minimum vector (in local space)
  7296. * @param max defines the maximum vector (in local space)
  7297. * @param worldMatrix defines the new world matrix
  7298. */
  7299. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7300. /**
  7301. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7302. * @param min defines the new minimum vector (in local space)
  7303. * @param max defines the new maximum vector (in local space)
  7304. * @param worldMatrix defines the new world matrix
  7305. */
  7306. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7307. /**
  7308. * Scale the current bounding sphere by applying a scale factor
  7309. * @param factor defines the scale factor to apply
  7310. * @returns the current bounding box
  7311. */
  7312. scale(factor: number): BoundingSphere;
  7313. /**
  7314. * Gets the world matrix of the bounding box
  7315. * @returns a matrix
  7316. */
  7317. getWorldMatrix(): DeepImmutable<Matrix>;
  7318. /** @hidden */
  7319. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7320. /**
  7321. * Tests if the bounding sphere is intersecting the frustum planes
  7322. * @param frustumPlanes defines the frustum planes to test
  7323. * @returns true if there is an intersection
  7324. */
  7325. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7326. /**
  7327. * Tests if the bounding sphere center is in between the frustum planes.
  7328. * Used for optimistic fast inclusion.
  7329. * @param frustumPlanes defines the frustum planes to test
  7330. * @returns true if the sphere center is in between the frustum planes
  7331. */
  7332. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7333. /**
  7334. * Tests if a point is inside the bounding sphere
  7335. * @param point defines the point to test
  7336. * @returns true if the point is inside the bounding sphere
  7337. */
  7338. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7339. /**
  7340. * Checks if two sphere intersct
  7341. * @param sphere0 sphere 0
  7342. * @param sphere1 sphere 1
  7343. * @returns true if the speres intersect
  7344. */
  7345. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7346. }
  7347. }
  7348. declare module BABYLON {
  7349. /**
  7350. * Class used to store bounding box information
  7351. */
  7352. export class BoundingBox implements ICullable {
  7353. /**
  7354. * Gets the 8 vectors representing the bounding box in local space
  7355. */
  7356. readonly vectors: Vector3[];
  7357. /**
  7358. * Gets the center of the bounding box in local space
  7359. */
  7360. readonly center: Vector3;
  7361. /**
  7362. * Gets the center of the bounding box in world space
  7363. */
  7364. readonly centerWorld: Vector3;
  7365. /**
  7366. * Gets the extend size in local space
  7367. */
  7368. readonly extendSize: Vector3;
  7369. /**
  7370. * Gets the extend size in world space
  7371. */
  7372. readonly extendSizeWorld: Vector3;
  7373. /**
  7374. * Gets the OBB (object bounding box) directions
  7375. */
  7376. readonly directions: Vector3[];
  7377. /**
  7378. * Gets the 8 vectors representing the bounding box in world space
  7379. */
  7380. readonly vectorsWorld: Vector3[];
  7381. /**
  7382. * Gets the minimum vector in world space
  7383. */
  7384. readonly minimumWorld: Vector3;
  7385. /**
  7386. * Gets the maximum vector in world space
  7387. */
  7388. readonly maximumWorld: Vector3;
  7389. /**
  7390. * Gets the minimum vector in local space
  7391. */
  7392. readonly minimum: Vector3;
  7393. /**
  7394. * Gets the maximum vector in local space
  7395. */
  7396. readonly maximum: Vector3;
  7397. private _worldMatrix;
  7398. private static readonly TmpVector3;
  7399. /**
  7400. * @hidden
  7401. */
  7402. _tag: number;
  7403. /**
  7404. * Creates a new bounding box
  7405. * @param min defines the minimum vector (in local space)
  7406. * @param max defines the maximum vector (in local space)
  7407. * @param worldMatrix defines the new world matrix
  7408. */
  7409. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7410. /**
  7411. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7412. * @param min defines the new minimum vector (in local space)
  7413. * @param max defines the new maximum vector (in local space)
  7414. * @param worldMatrix defines the new world matrix
  7415. */
  7416. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7417. /**
  7418. * Scale the current bounding box by applying a scale factor
  7419. * @param factor defines the scale factor to apply
  7420. * @returns the current bounding box
  7421. */
  7422. scale(factor: number): BoundingBox;
  7423. /**
  7424. * Gets the world matrix of the bounding box
  7425. * @returns a matrix
  7426. */
  7427. getWorldMatrix(): DeepImmutable<Matrix>;
  7428. /** @hidden */
  7429. _update(world: DeepImmutable<Matrix>): void;
  7430. /**
  7431. * Tests if the bounding box is intersecting the frustum planes
  7432. * @param frustumPlanes defines the frustum planes to test
  7433. * @returns true if there is an intersection
  7434. */
  7435. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7436. /**
  7437. * Tests if the bounding box is entirely inside the frustum planes
  7438. * @param frustumPlanes defines the frustum planes to test
  7439. * @returns true if there is an inclusion
  7440. */
  7441. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7442. /**
  7443. * Tests if a point is inside the bounding box
  7444. * @param point defines the point to test
  7445. * @returns true if the point is inside the bounding box
  7446. */
  7447. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7448. /**
  7449. * Tests if the bounding box intersects with a bounding sphere
  7450. * @param sphere defines the sphere to test
  7451. * @returns true if there is an intersection
  7452. */
  7453. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7454. /**
  7455. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7456. * @param min defines the min vector to use
  7457. * @param max defines the max vector to use
  7458. * @returns true if there is an intersection
  7459. */
  7460. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7461. /**
  7462. * Tests if two bounding boxes are intersections
  7463. * @param box0 defines the first box to test
  7464. * @param box1 defines the second box to test
  7465. * @returns true if there is an intersection
  7466. */
  7467. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7468. /**
  7469. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7470. * @param minPoint defines the minimum vector of the bounding box
  7471. * @param maxPoint defines the maximum vector of the bounding box
  7472. * @param sphereCenter defines the sphere center
  7473. * @param sphereRadius defines the sphere radius
  7474. * @returns true if there is an intersection
  7475. */
  7476. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7477. /**
  7478. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7479. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7480. * @param frustumPlanes defines the frustum planes to test
  7481. * @return true if there is an inclusion
  7482. */
  7483. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7484. /**
  7485. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7486. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7487. * @param frustumPlanes defines the frustum planes to test
  7488. * @return true if there is an intersection
  7489. */
  7490. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7491. }
  7492. }
  7493. declare module BABYLON {
  7494. /** @hidden */
  7495. export class Collider {
  7496. /** Define if a collision was found */
  7497. collisionFound: boolean;
  7498. /**
  7499. * Define last intersection point in local space
  7500. */
  7501. intersectionPoint: Vector3;
  7502. /**
  7503. * Define last collided mesh
  7504. */
  7505. collidedMesh: Nullable<AbstractMesh>;
  7506. private _collisionPoint;
  7507. private _planeIntersectionPoint;
  7508. private _tempVector;
  7509. private _tempVector2;
  7510. private _tempVector3;
  7511. private _tempVector4;
  7512. private _edge;
  7513. private _baseToVertex;
  7514. private _destinationPoint;
  7515. private _slidePlaneNormal;
  7516. private _displacementVector;
  7517. /** @hidden */
  7518. _radius: Vector3;
  7519. /** @hidden */
  7520. _retry: number;
  7521. private _velocity;
  7522. private _basePoint;
  7523. private _epsilon;
  7524. /** @hidden */
  7525. _velocityWorldLength: number;
  7526. /** @hidden */
  7527. _basePointWorld: Vector3;
  7528. private _velocityWorld;
  7529. private _normalizedVelocity;
  7530. /** @hidden */
  7531. _initialVelocity: Vector3;
  7532. /** @hidden */
  7533. _initialPosition: Vector3;
  7534. private _nearestDistance;
  7535. private _collisionMask;
  7536. get collisionMask(): number;
  7537. set collisionMask(mask: number);
  7538. /**
  7539. * Gets the plane normal used to compute the sliding response (in local space)
  7540. */
  7541. get slidePlaneNormal(): Vector3;
  7542. /** @hidden */
  7543. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7544. /** @hidden */
  7545. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7546. /** @hidden */
  7547. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7548. /** @hidden */
  7549. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7550. /** @hidden */
  7551. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7552. /** @hidden */
  7553. _getResponse(pos: Vector3, vel: Vector3): void;
  7554. }
  7555. }
  7556. declare module BABYLON {
  7557. /**
  7558. * Interface for cullable objects
  7559. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7560. */
  7561. export interface ICullable {
  7562. /**
  7563. * Checks if the object or part of the object is in the frustum
  7564. * @param frustumPlanes Camera near/planes
  7565. * @returns true if the object is in frustum otherwise false
  7566. */
  7567. isInFrustum(frustumPlanes: Plane[]): boolean;
  7568. /**
  7569. * Checks if a cullable object (mesh...) is in the camera frustum
  7570. * Unlike isInFrustum this cheks the full bounding box
  7571. * @param frustumPlanes Camera near/planes
  7572. * @returns true if the object is in frustum otherwise false
  7573. */
  7574. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7575. }
  7576. /**
  7577. * Info for a bounding data of a mesh
  7578. */
  7579. export class BoundingInfo implements ICullable {
  7580. /**
  7581. * Bounding box for the mesh
  7582. */
  7583. readonly boundingBox: BoundingBox;
  7584. /**
  7585. * Bounding sphere for the mesh
  7586. */
  7587. readonly boundingSphere: BoundingSphere;
  7588. private _isLocked;
  7589. private static readonly TmpVector3;
  7590. /**
  7591. * Constructs bounding info
  7592. * @param minimum min vector of the bounding box/sphere
  7593. * @param maximum max vector of the bounding box/sphere
  7594. * @param worldMatrix defines the new world matrix
  7595. */
  7596. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7597. /**
  7598. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7599. * @param min defines the new minimum vector (in local space)
  7600. * @param max defines the new maximum vector (in local space)
  7601. * @param worldMatrix defines the new world matrix
  7602. */
  7603. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7604. /**
  7605. * min vector of the bounding box/sphere
  7606. */
  7607. get minimum(): Vector3;
  7608. /**
  7609. * max vector of the bounding box/sphere
  7610. */
  7611. get maximum(): Vector3;
  7612. /**
  7613. * If the info is locked and won't be updated to avoid perf overhead
  7614. */
  7615. get isLocked(): boolean;
  7616. set isLocked(value: boolean);
  7617. /**
  7618. * Updates the bounding sphere and box
  7619. * @param world world matrix to be used to update
  7620. */
  7621. update(world: DeepImmutable<Matrix>): void;
  7622. /**
  7623. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7624. * @param center New center of the bounding info
  7625. * @param extend New extend of the bounding info
  7626. * @returns the current bounding info
  7627. */
  7628. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7629. /**
  7630. * Scale the current bounding info by applying a scale factor
  7631. * @param factor defines the scale factor to apply
  7632. * @returns the current bounding info
  7633. */
  7634. scale(factor: number): BoundingInfo;
  7635. /**
  7636. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7637. * @param frustumPlanes defines the frustum to test
  7638. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7639. * @returns true if the bounding info is in the frustum planes
  7640. */
  7641. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7642. /**
  7643. * Gets the world distance between the min and max points of the bounding box
  7644. */
  7645. get diagonalLength(): number;
  7646. /**
  7647. * Checks if a cullable object (mesh...) is in the camera frustum
  7648. * Unlike isInFrustum this cheks the full bounding box
  7649. * @param frustumPlanes Camera near/planes
  7650. * @returns true if the object is in frustum otherwise false
  7651. */
  7652. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7653. /** @hidden */
  7654. _checkCollision(collider: Collider): boolean;
  7655. /**
  7656. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7657. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7658. * @param point the point to check intersection with
  7659. * @returns if the point intersects
  7660. */
  7661. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7662. /**
  7663. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7664. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7665. * @param boundingInfo the bounding info to check intersection with
  7666. * @param precise if the intersection should be done using OBB
  7667. * @returns if the bounding info intersects
  7668. */
  7669. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7670. }
  7671. }
  7672. declare module BABYLON {
  7673. /**
  7674. * Extracts minimum and maximum values from a list of indexed positions
  7675. * @param positions defines the positions to use
  7676. * @param indices defines the indices to the positions
  7677. * @param indexStart defines the start index
  7678. * @param indexCount defines the end index
  7679. * @param bias defines bias value to add to the result
  7680. * @return minimum and maximum values
  7681. */
  7682. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7683. minimum: Vector3;
  7684. maximum: Vector3;
  7685. };
  7686. /**
  7687. * Extracts minimum and maximum values from a list of positions
  7688. * @param positions defines the positions to use
  7689. * @param start defines the start index in the positions array
  7690. * @param count defines the number of positions to handle
  7691. * @param bias defines bias value to add to the result
  7692. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7693. * @return minimum and maximum values
  7694. */
  7695. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7696. minimum: Vector3;
  7697. maximum: Vector3;
  7698. };
  7699. }
  7700. declare module BABYLON {
  7701. /**
  7702. * Class used to manipulate GUIDs
  7703. */
  7704. export class GUID {
  7705. /**
  7706. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7707. * Be aware Math.random() could cause collisions, but:
  7708. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  7709. * @returns a pseudo random id
  7710. */
  7711. static RandomId(): string;
  7712. }
  7713. }
  7714. declare module BABYLON {
  7715. /**
  7716. * Base class of all the textures in babylon.
  7717. * It groups all the common properties the materials, post process, lights... might need
  7718. * in order to make a correct use of the texture.
  7719. */
  7720. export class BaseTexture extends ThinTexture implements IAnimatable {
  7721. /**
  7722. * Default anisotropic filtering level for the application.
  7723. * It is set to 4 as a good tradeoff between perf and quality.
  7724. */
  7725. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7726. /**
  7727. * Gets or sets the unique id of the texture
  7728. */
  7729. uniqueId: number;
  7730. /**
  7731. * Define the name of the texture.
  7732. */
  7733. name: string;
  7734. /**
  7735. * Gets or sets an object used to store user defined information.
  7736. */
  7737. metadata: any;
  7738. /**
  7739. * For internal use only. Please do not use.
  7740. */
  7741. reservedDataStore: any;
  7742. private _hasAlpha;
  7743. /**
  7744. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7745. */
  7746. get hasAlpha(): boolean;
  7747. set hasAlpha(value: boolean);
  7748. /**
  7749. * Defines if the alpha value should be determined via the rgb values.
  7750. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7751. */
  7752. getAlphaFromRGB: boolean;
  7753. /**
  7754. * Intensity or strength of the texture.
  7755. * It is commonly used by materials to fine tune the intensity of the texture
  7756. */
  7757. level: number;
  7758. /**
  7759. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7760. * This is part of the texture as textures usually maps to one uv set.
  7761. */
  7762. coordinatesIndex: number;
  7763. protected _coordinatesMode: number;
  7764. /**
  7765. * How a texture is mapped.
  7766. *
  7767. * | Value | Type | Description |
  7768. * | ----- | ----------------------------------- | ----------- |
  7769. * | 0 | EXPLICIT_MODE | |
  7770. * | 1 | SPHERICAL_MODE | |
  7771. * | 2 | PLANAR_MODE | |
  7772. * | 3 | CUBIC_MODE | |
  7773. * | 4 | PROJECTION_MODE | |
  7774. * | 5 | SKYBOX_MODE | |
  7775. * | 6 | INVCUBIC_MODE | |
  7776. * | 7 | EQUIRECTANGULAR_MODE | |
  7777. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7778. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7779. */
  7780. set coordinatesMode(value: number);
  7781. get coordinatesMode(): number;
  7782. /**
  7783. * | Value | Type | Description |
  7784. * | ----- | ------------------ | ----------- |
  7785. * | 0 | CLAMP_ADDRESSMODE | |
  7786. * | 1 | WRAP_ADDRESSMODE | |
  7787. * | 2 | MIRROR_ADDRESSMODE | |
  7788. */
  7789. get wrapU(): number;
  7790. set wrapU(value: number);
  7791. /**
  7792. * | Value | Type | Description |
  7793. * | ----- | ------------------ | ----------- |
  7794. * | 0 | CLAMP_ADDRESSMODE | |
  7795. * | 1 | WRAP_ADDRESSMODE | |
  7796. * | 2 | MIRROR_ADDRESSMODE | |
  7797. */
  7798. get wrapV(): number;
  7799. set wrapV(value: number);
  7800. /**
  7801. * | Value | Type | Description |
  7802. * | ----- | ------------------ | ----------- |
  7803. * | 0 | CLAMP_ADDRESSMODE | |
  7804. * | 1 | WRAP_ADDRESSMODE | |
  7805. * | 2 | MIRROR_ADDRESSMODE | |
  7806. */
  7807. wrapR: number;
  7808. /**
  7809. * With compliant hardware and browser (supporting anisotropic filtering)
  7810. * this defines the level of anisotropic filtering in the texture.
  7811. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7812. */
  7813. anisotropicFilteringLevel: number;
  7814. private _isCube;
  7815. /**
  7816. * Define if the texture is a cube texture or if false a 2d texture.
  7817. */
  7818. get isCube(): boolean;
  7819. set isCube(value: boolean);
  7820. /**
  7821. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7822. */
  7823. get is3D(): boolean;
  7824. set is3D(value: boolean);
  7825. /**
  7826. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7827. */
  7828. get is2DArray(): boolean;
  7829. set is2DArray(value: boolean);
  7830. private _gammaSpace;
  7831. /**
  7832. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7833. * HDR texture are usually stored in linear space.
  7834. * This only impacts the PBR and Background materials
  7835. */
  7836. get gammaSpace(): boolean;
  7837. set gammaSpace(gamma: boolean);
  7838. /**
  7839. * Gets or sets whether or not the texture contains RGBD data.
  7840. */
  7841. get isRGBD(): boolean;
  7842. set isRGBD(value: boolean);
  7843. /**
  7844. * Is Z inverted in the texture (useful in a cube texture).
  7845. */
  7846. invertZ: boolean;
  7847. /**
  7848. * Are mip maps generated for this texture or not.
  7849. */
  7850. get noMipmap(): boolean;
  7851. /**
  7852. * @hidden
  7853. */
  7854. lodLevelInAlpha: boolean;
  7855. /**
  7856. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7857. */
  7858. get lodGenerationOffset(): number;
  7859. set lodGenerationOffset(value: number);
  7860. /**
  7861. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7862. */
  7863. get lodGenerationScale(): number;
  7864. set lodGenerationScale(value: number);
  7865. /**
  7866. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7867. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7868. * average roughness values.
  7869. */
  7870. get linearSpecularLOD(): boolean;
  7871. set linearSpecularLOD(value: boolean);
  7872. /**
  7873. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7874. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7875. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7876. */
  7877. get irradianceTexture(): Nullable<BaseTexture>;
  7878. set irradianceTexture(value: Nullable<BaseTexture>);
  7879. /**
  7880. * Define if the texture is a render target.
  7881. */
  7882. isRenderTarget: boolean;
  7883. /**
  7884. * Define the unique id of the texture in the scene.
  7885. */
  7886. get uid(): string;
  7887. /** @hidden */
  7888. _prefiltered: boolean;
  7889. /**
  7890. * Return a string representation of the texture.
  7891. * @returns the texture as a string
  7892. */
  7893. toString(): string;
  7894. /**
  7895. * Get the class name of the texture.
  7896. * @returns "BaseTexture"
  7897. */
  7898. getClassName(): string;
  7899. /**
  7900. * Define the list of animation attached to the texture.
  7901. */
  7902. animations: Animation[];
  7903. /**
  7904. * An event triggered when the texture is disposed.
  7905. */
  7906. onDisposeObservable: Observable<BaseTexture>;
  7907. private _onDisposeObserver;
  7908. /**
  7909. * Callback triggered when the texture has been disposed.
  7910. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7911. */
  7912. set onDispose(callback: () => void);
  7913. protected _scene: Nullable<Scene>;
  7914. /** @hidden */
  7915. _texture: Nullable<InternalTexture>;
  7916. private _uid;
  7917. /**
  7918. * Define if the texture is preventinga material to render or not.
  7919. * If not and the texture is not ready, the engine will use a default black texture instead.
  7920. */
  7921. get isBlocking(): boolean;
  7922. /**
  7923. * Instantiates a new BaseTexture.
  7924. * Base class of all the textures in babylon.
  7925. * It groups all the common properties the materials, post process, lights... might need
  7926. * in order to make a correct use of the texture.
  7927. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7928. */
  7929. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7930. /**
  7931. * Get the scene the texture belongs to.
  7932. * @returns the scene or null if undefined
  7933. */
  7934. getScene(): Nullable<Scene>;
  7935. /** @hidden */
  7936. protected _getEngine(): Nullable<ThinEngine>;
  7937. /**
  7938. * Checks if the texture has the same transform matrix than another texture
  7939. * @param texture texture to check against
  7940. * @returns true if the transforms are the same, else false
  7941. */
  7942. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7943. /**
  7944. * Get the texture transform matrix used to offset tile the texture for istance.
  7945. * @returns the transformation matrix
  7946. */
  7947. getTextureMatrix(): Matrix;
  7948. /**
  7949. * Get the texture reflection matrix used to rotate/transform the reflection.
  7950. * @returns the reflection matrix
  7951. */
  7952. getReflectionTextureMatrix(): Matrix;
  7953. /**
  7954. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7955. * @returns true if ready or not blocking
  7956. */
  7957. isReadyOrNotBlocking(): boolean;
  7958. /**
  7959. * Scales the texture if is `canRescale()`
  7960. * @param ratio the resize factor we want to use to rescale
  7961. */
  7962. scale(ratio: number): void;
  7963. /**
  7964. * Get if the texture can rescale.
  7965. */
  7966. get canRescale(): boolean;
  7967. /** @hidden */
  7968. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7969. /** @hidden */
  7970. _rebuild(): void;
  7971. /**
  7972. * Clones the texture.
  7973. * @returns the cloned texture
  7974. */
  7975. clone(): Nullable<BaseTexture>;
  7976. /**
  7977. * Get the texture underlying type (INT, FLOAT...)
  7978. */
  7979. get textureType(): number;
  7980. /**
  7981. * Get the texture underlying format (RGB, RGBA...)
  7982. */
  7983. get textureFormat(): number;
  7984. /**
  7985. * Indicates that textures need to be re-calculated for all materials
  7986. */
  7987. protected _markAllSubMeshesAsTexturesDirty(): void;
  7988. /**
  7989. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7990. * This will returns an RGBA array buffer containing either in values (0-255) or
  7991. * float values (0-1) depending of the underlying buffer type.
  7992. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7993. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7994. * @param buffer defines a user defined buffer to fill with data (can be null)
  7995. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  7996. * @returns The Array buffer promise containing the pixels data.
  7997. */
  7998. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  7999. /** @hidden */
  8000. get _lodTextureHigh(): Nullable<BaseTexture>;
  8001. /** @hidden */
  8002. get _lodTextureMid(): Nullable<BaseTexture>;
  8003. /** @hidden */
  8004. get _lodTextureLow(): Nullable<BaseTexture>;
  8005. /**
  8006. * Dispose the texture and release its associated resources.
  8007. */
  8008. dispose(): void;
  8009. /**
  8010. * Serialize the texture into a JSON representation that can be parsed later on.
  8011. * @returns the JSON representation of the texture
  8012. */
  8013. serialize(): any;
  8014. /**
  8015. * Helper function to be called back once a list of texture contains only ready textures.
  8016. * @param textures Define the list of textures to wait for
  8017. * @param callback Define the callback triggered once the entire list will be ready
  8018. */
  8019. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8020. private static _isScene;
  8021. }
  8022. }
  8023. declare module BABYLON {
  8024. /** @hidden */
  8025. export class WebGLDataBuffer extends DataBuffer {
  8026. private _buffer;
  8027. constructor(resource: WebGLBuffer);
  8028. get underlyingResource(): any;
  8029. }
  8030. }
  8031. declare module BABYLON {
  8032. /** @hidden */
  8033. export class WebGLPipelineContext implements IPipelineContext {
  8034. private _valueCache;
  8035. private _uniforms;
  8036. engine: ThinEngine;
  8037. program: Nullable<WebGLProgram>;
  8038. context?: WebGLRenderingContext;
  8039. vertexShader?: WebGLShader;
  8040. fragmentShader?: WebGLShader;
  8041. isParallelCompiled: boolean;
  8042. onCompiled?: () => void;
  8043. transformFeedback?: WebGLTransformFeedback | null;
  8044. vertexCompilationError: Nullable<string>;
  8045. fragmentCompilationError: Nullable<string>;
  8046. programLinkError: Nullable<string>;
  8047. programValidationError: Nullable<string>;
  8048. get isAsync(): boolean;
  8049. get isReady(): boolean;
  8050. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8051. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8052. [key: string]: number;
  8053. }, uniformsNames: string[], uniforms: {
  8054. [key: string]: Nullable<WebGLUniformLocation>;
  8055. }, samplerList: string[], samplers: {
  8056. [key: string]: number;
  8057. }, attributesNames: string[], attributes: number[]): void;
  8058. /**
  8059. * Release all associated resources.
  8060. **/
  8061. dispose(): void;
  8062. /** @hidden */
  8063. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8064. /** @hidden */
  8065. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8066. /** @hidden */
  8067. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8068. /** @hidden */
  8069. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8070. /**
  8071. * Sets an interger value on a uniform variable.
  8072. * @param uniformName Name of the variable.
  8073. * @param value Value to be set.
  8074. */
  8075. setInt(uniformName: string, value: number): void;
  8076. /**
  8077. * Sets a int2 on a uniform variable.
  8078. * @param uniformName Name of the variable.
  8079. * @param x First int in int2.
  8080. * @param y Second int in int2.
  8081. */
  8082. setInt2(uniformName: string, x: number, y: number): void;
  8083. /**
  8084. * Sets a int3 on a uniform variable.
  8085. * @param uniformName Name of the variable.
  8086. * @param x First int in int3.
  8087. * @param y Second int in int3.
  8088. * @param y Third int in int3.
  8089. */
  8090. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8091. /**
  8092. * Sets a int4 on a uniform variable.
  8093. * @param uniformName Name of the variable.
  8094. * @param x First int in int4.
  8095. * @param y Second int in int4.
  8096. * @param y Third int in int4.
  8097. * @param w Fourth int in int4.
  8098. */
  8099. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8100. /**
  8101. * Sets an int array on a uniform variable.
  8102. * @param uniformName Name of the variable.
  8103. * @param array array to be set.
  8104. */
  8105. setIntArray(uniformName: string, array: Int32Array): void;
  8106. /**
  8107. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  8108. * @param uniformName Name of the variable.
  8109. * @param array array to be set.
  8110. */
  8111. setIntArray2(uniformName: string, array: Int32Array): void;
  8112. /**
  8113. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  8114. * @param uniformName Name of the variable.
  8115. * @param array array to be set.
  8116. */
  8117. setIntArray3(uniformName: string, array: Int32Array): void;
  8118. /**
  8119. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  8120. * @param uniformName Name of the variable.
  8121. * @param array array to be set.
  8122. */
  8123. setIntArray4(uniformName: string, array: Int32Array): void;
  8124. /**
  8125. * Sets an array on a uniform variable.
  8126. * @param uniformName Name of the variable.
  8127. * @param array array to be set.
  8128. */
  8129. setArray(uniformName: string, array: number[]): void;
  8130. /**
  8131. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  8132. * @param uniformName Name of the variable.
  8133. * @param array array to be set.
  8134. */
  8135. setArray2(uniformName: string, array: number[]): void;
  8136. /**
  8137. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  8138. * @param uniformName Name of the variable.
  8139. * @param array array to be set.
  8140. * @returns this effect.
  8141. */
  8142. setArray3(uniformName: string, array: number[]): void;
  8143. /**
  8144. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  8145. * @param uniformName Name of the variable.
  8146. * @param array array to be set.
  8147. */
  8148. setArray4(uniformName: string, array: number[]): void;
  8149. /**
  8150. * Sets matrices on a uniform variable.
  8151. * @param uniformName Name of the variable.
  8152. * @param matrices matrices to be set.
  8153. */
  8154. setMatrices(uniformName: string, matrices: Float32Array): void;
  8155. /**
  8156. * Sets matrix on a uniform variable.
  8157. * @param uniformName Name of the variable.
  8158. * @param matrix matrix to be set.
  8159. */
  8160. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8161. /**
  8162. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  8163. * @param uniformName Name of the variable.
  8164. * @param matrix matrix to be set.
  8165. */
  8166. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8167. /**
  8168. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8169. * @param uniformName Name of the variable.
  8170. * @param matrix matrix to be set.
  8171. */
  8172. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8173. /**
  8174. * Sets a float on a uniform variable.
  8175. * @param uniformName Name of the variable.
  8176. * @param value value to be set.
  8177. * @returns this effect.
  8178. */
  8179. setFloat(uniformName: string, value: number): void;
  8180. /**
  8181. * Sets a Vector2 on a uniform variable.
  8182. * @param uniformName Name of the variable.
  8183. * @param vector2 vector2 to be set.
  8184. */
  8185. setVector2(uniformName: string, vector2: IVector2Like): void;
  8186. /**
  8187. * Sets a float2 on a uniform variable.
  8188. * @param uniformName Name of the variable.
  8189. * @param x First float in float2.
  8190. * @param y Second float in float2.
  8191. */
  8192. setFloat2(uniformName: string, x: number, y: number): void;
  8193. /**
  8194. * Sets a Vector3 on a uniform variable.
  8195. * @param uniformName Name of the variable.
  8196. * @param vector3 Value to be set.
  8197. */
  8198. setVector3(uniformName: string, vector3: IVector3Like): void;
  8199. /**
  8200. * Sets a float3 on a uniform variable.
  8201. * @param uniformName Name of the variable.
  8202. * @param x First float in float3.
  8203. * @param y Second float in float3.
  8204. * @param z Third float in float3.
  8205. */
  8206. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8207. /**
  8208. * Sets a Vector4 on a uniform variable.
  8209. * @param uniformName Name of the variable.
  8210. * @param vector4 Value to be set.
  8211. */
  8212. setVector4(uniformName: string, vector4: IVector4Like): void;
  8213. /**
  8214. * Sets a float4 on a uniform variable.
  8215. * @param uniformName Name of the variable.
  8216. * @param x First float in float4.
  8217. * @param y Second float in float4.
  8218. * @param z Third float in float4.
  8219. * @param w Fourth float in float4.
  8220. * @returns this effect.
  8221. */
  8222. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8223. /**
  8224. * Sets a Color3 on a uniform variable.
  8225. * @param uniformName Name of the variable.
  8226. * @param color3 Value to be set.
  8227. */
  8228. setColor3(uniformName: string, color3: IColor3Like): void;
  8229. /**
  8230. * Sets a Color4 on a uniform variable.
  8231. * @param uniformName Name of the variable.
  8232. * @param color3 Value to be set.
  8233. * @param alpha Alpha value to be set.
  8234. */
  8235. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8236. /**
  8237. * Sets a Color4 on a uniform variable
  8238. * @param uniformName defines the name of the variable
  8239. * @param color4 defines the value to be set
  8240. */
  8241. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8242. _getVertexShaderCode(): string | null;
  8243. _getFragmentShaderCode(): string | null;
  8244. }
  8245. }
  8246. declare module BABYLON {
  8247. interface ThinEngine {
  8248. /**
  8249. * Create an uniform buffer
  8250. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8251. * @param elements defines the content of the uniform buffer
  8252. * @returns the webGL uniform buffer
  8253. */
  8254. createUniformBuffer(elements: FloatArray): DataBuffer;
  8255. /**
  8256. * Create a dynamic uniform buffer
  8257. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8258. * @param elements defines the content of the uniform buffer
  8259. * @returns the webGL uniform buffer
  8260. */
  8261. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8262. /**
  8263. * Update an existing uniform buffer
  8264. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8265. * @param uniformBuffer defines the target uniform buffer
  8266. * @param elements defines the content to update
  8267. * @param offset defines the offset in the uniform buffer where update should start
  8268. * @param count defines the size of the data to update
  8269. */
  8270. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8271. /**
  8272. * Bind an uniform buffer to the current webGL context
  8273. * @param buffer defines the buffer to bind
  8274. */
  8275. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8276. /**
  8277. * Bind a buffer to the current webGL context at a given location
  8278. * @param buffer defines the buffer to bind
  8279. * @param location defines the index where to bind the buffer
  8280. * @param name Name of the uniform variable to bind
  8281. */
  8282. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8283. /**
  8284. * Bind a specific block at a given index in a specific shader program
  8285. * @param pipelineContext defines the pipeline context to use
  8286. * @param blockName defines the block name
  8287. * @param index defines the index where to bind the block
  8288. */
  8289. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8290. }
  8291. }
  8292. declare module BABYLON {
  8293. /**
  8294. * Uniform buffer objects.
  8295. *
  8296. * Handles blocks of uniform on the GPU.
  8297. *
  8298. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8299. *
  8300. * For more information, please refer to :
  8301. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8302. */
  8303. export class UniformBuffer {
  8304. /** @hidden */
  8305. static _updatedUbosInFrame: {
  8306. [name: string]: number;
  8307. };
  8308. private _engine;
  8309. private _buffer;
  8310. private _buffers;
  8311. private _bufferIndex;
  8312. private _createBufferOnWrite;
  8313. private _data;
  8314. private _bufferData;
  8315. private _dynamic?;
  8316. private _uniformLocations;
  8317. private _uniformSizes;
  8318. private _uniformArraySizes;
  8319. private _uniformLocationPointer;
  8320. private _needSync;
  8321. private _noUBO;
  8322. private _currentEffect;
  8323. private _currentEffectName;
  8324. private _name;
  8325. private _currentFrameId;
  8326. /** @hidden */
  8327. _alreadyBound: boolean;
  8328. private static _MAX_UNIFORM_SIZE;
  8329. private static _tempBuffer;
  8330. private static _tempBufferInt32View;
  8331. /**
  8332. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8333. * This is dynamic to allow compat with webgl 1 and 2.
  8334. * You will need to pass the name of the uniform as well as the value.
  8335. */
  8336. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8337. /**
  8338. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8339. * This is dynamic to allow compat with webgl 1 and 2.
  8340. * You will need to pass the name of the uniform as well as the value.
  8341. */
  8342. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8343. /**
  8344. * Lambda to Update a single float in a uniform buffer.
  8345. * This is dynamic to allow compat with webgl 1 and 2.
  8346. * You will need to pass the name of the uniform as well as the value.
  8347. */
  8348. updateFloat: (name: string, x: number) => void;
  8349. /**
  8350. * Lambda to Update a vec2 of float in a uniform buffer.
  8351. * This is dynamic to allow compat with webgl 1 and 2.
  8352. * You will need to pass the name of the uniform as well as the value.
  8353. */
  8354. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8355. /**
  8356. * Lambda to Update a vec3 of float in a uniform buffer.
  8357. * This is dynamic to allow compat with webgl 1 and 2.
  8358. * You will need to pass the name of the uniform as well as the value.
  8359. */
  8360. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8361. /**
  8362. * Lambda to Update a vec4 of float in a uniform buffer.
  8363. * This is dynamic to allow compat with webgl 1 and 2.
  8364. * You will need to pass the name of the uniform as well as the value.
  8365. */
  8366. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8367. /**
  8368. * Lambda to Update an array of float in a uniform buffer.
  8369. * This is dynamic to allow compat with webgl 1 and 2.
  8370. * You will need to pass the name of the uniform as well as the value.
  8371. */
  8372. updateFloatArray: (name: string, array: Float32Array) => void;
  8373. /**
  8374. * Lambda to Update an array of number in a uniform buffer.
  8375. * This is dynamic to allow compat with webgl 1 and 2.
  8376. * You will need to pass the name of the uniform as well as the value.
  8377. */
  8378. updateArray: (name: string, array: number[]) => void;
  8379. /**
  8380. * Lambda to Update an array of number in a uniform buffer.
  8381. * This is dynamic to allow compat with webgl 1 and 2.
  8382. * You will need to pass the name of the uniform as well as the value.
  8383. */
  8384. updateIntArray: (name: string, array: Int32Array) => void;
  8385. /**
  8386. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8387. * This is dynamic to allow compat with webgl 1 and 2.
  8388. * You will need to pass the name of the uniform as well as the value.
  8389. */
  8390. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8391. /**
  8392. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8393. * This is dynamic to allow compat with webgl 1 and 2.
  8394. * You will need to pass the name of the uniform as well as the value.
  8395. */
  8396. updateMatrices: (name: string, mat: Float32Array) => void;
  8397. /**
  8398. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8399. * This is dynamic to allow compat with webgl 1 and 2.
  8400. * You will need to pass the name of the uniform as well as the value.
  8401. */
  8402. updateVector3: (name: string, vector: Vector3) => void;
  8403. /**
  8404. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8405. * This is dynamic to allow compat with webgl 1 and 2.
  8406. * You will need to pass the name of the uniform as well as the value.
  8407. */
  8408. updateVector4: (name: string, vector: Vector4) => void;
  8409. /**
  8410. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  8411. * This is dynamic to allow compat with webgl 1 and 2.
  8412. * You will need to pass the name of the uniform as well as the value.
  8413. */
  8414. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8415. /**
  8416. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  8417. * This is dynamic to allow compat with webgl 1 and 2.
  8418. * You will need to pass the name of the uniform as well as the value.
  8419. */
  8420. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8421. /**
  8422. * Lambda to Update a int a uniform buffer.
  8423. * This is dynamic to allow compat with webgl 1 and 2.
  8424. * You will need to pass the name of the uniform as well as the value.
  8425. */
  8426. updateInt: (name: string, x: number, suffix?: string) => void;
  8427. /**
  8428. * Lambda to Update a vec2 of int in a uniform buffer.
  8429. * This is dynamic to allow compat with webgl 1 and 2.
  8430. * You will need to pass the name of the uniform as well as the value.
  8431. */
  8432. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8433. /**
  8434. * Lambda to Update a vec3 of int in a uniform buffer.
  8435. * This is dynamic to allow compat with webgl 1 and 2.
  8436. * You will need to pass the name of the uniform as well as the value.
  8437. */
  8438. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8439. /**
  8440. * Lambda to Update a vec4 of int in a uniform buffer.
  8441. * This is dynamic to allow compat with webgl 1 and 2.
  8442. * You will need to pass the name of the uniform as well as the value.
  8443. */
  8444. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8445. /**
  8446. * Instantiates a new Uniform buffer objects.
  8447. *
  8448. * Handles blocks of uniform on the GPU.
  8449. *
  8450. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8451. *
  8452. * For more information, please refer to :
  8453. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8454. * @param engine Define the engine the buffer is associated with
  8455. * @param data Define the data contained in the buffer
  8456. * @param dynamic Define if the buffer is updatable
  8457. * @param name to assign to the buffer (debugging purpose)
  8458. */
  8459. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8460. /**
  8461. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8462. * or just falling back on setUniformXXX calls.
  8463. */
  8464. get useUbo(): boolean;
  8465. /**
  8466. * Indicates if the WebGL underlying uniform buffer is in sync
  8467. * with the javascript cache data.
  8468. */
  8469. get isSync(): boolean;
  8470. /**
  8471. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8472. * Also, a dynamic UniformBuffer will disable cache verification and always
  8473. * update the underlying WebGL uniform buffer to the GPU.
  8474. * @returns if Dynamic, otherwise false
  8475. */
  8476. isDynamic(): boolean;
  8477. /**
  8478. * The data cache on JS side.
  8479. * @returns the underlying data as a float array
  8480. */
  8481. getData(): Float32Array;
  8482. /**
  8483. * The underlying WebGL Uniform buffer.
  8484. * @returns the webgl buffer
  8485. */
  8486. getBuffer(): Nullable<DataBuffer>;
  8487. /**
  8488. * std140 layout specifies how to align data within an UBO structure.
  8489. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8490. * for specs.
  8491. */
  8492. private _fillAlignment;
  8493. /**
  8494. * Adds an uniform in the buffer.
  8495. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8496. * for the layout to be correct !
  8497. * @param name Name of the uniform, as used in the uniform block in the shader.
  8498. * @param size Data size, or data directly.
  8499. * @param arraySize The number of elements in the array, 0 if not an array.
  8500. */
  8501. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8502. /**
  8503. * Adds a Matrix 4x4 to the uniform buffer.
  8504. * @param name Name of the uniform, as used in the uniform block in the shader.
  8505. * @param mat A 4x4 matrix.
  8506. */
  8507. addMatrix(name: string, mat: Matrix): void;
  8508. /**
  8509. * Adds a vec2 to the uniform buffer.
  8510. * @param name Name of the uniform, as used in the uniform block in the shader.
  8511. * @param x Define the x component value of the vec2
  8512. * @param y Define the y component value of the vec2
  8513. */
  8514. addFloat2(name: string, x: number, y: number): void;
  8515. /**
  8516. * Adds a vec3 to the uniform buffer.
  8517. * @param name Name of the uniform, as used in the uniform block in the shader.
  8518. * @param x Define the x component value of the vec3
  8519. * @param y Define the y component value of the vec3
  8520. * @param z Define the z component value of the vec3
  8521. */
  8522. addFloat3(name: string, x: number, y: number, z: number): void;
  8523. /**
  8524. * Adds a vec3 to the uniform buffer.
  8525. * @param name Name of the uniform, as used in the uniform block in the shader.
  8526. * @param color Define the vec3 from a Color
  8527. */
  8528. addColor3(name: string, color: Color3): void;
  8529. /**
  8530. * Adds a vec4 to the uniform buffer.
  8531. * @param name Name of the uniform, as used in the uniform block in the shader.
  8532. * @param color Define the rgb components from a Color
  8533. * @param alpha Define the a component of the vec4
  8534. */
  8535. addColor4(name: string, color: Color3, alpha: number): void;
  8536. /**
  8537. * Adds a vec3 to the uniform buffer.
  8538. * @param name Name of the uniform, as used in the uniform block in the shader.
  8539. * @param vector Define the vec3 components from a Vector
  8540. */
  8541. addVector3(name: string, vector: Vector3): void;
  8542. /**
  8543. * Adds a Matrix 3x3 to the uniform buffer.
  8544. * @param name Name of the uniform, as used in the uniform block in the shader.
  8545. */
  8546. addMatrix3x3(name: string): void;
  8547. /**
  8548. * Adds a Matrix 2x2 to the uniform buffer.
  8549. * @param name Name of the uniform, as used in the uniform block in the shader.
  8550. */
  8551. addMatrix2x2(name: string): void;
  8552. /**
  8553. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8554. */
  8555. create(): void;
  8556. /** @hidden */
  8557. _rebuild(): void;
  8558. /** @hidden */
  8559. get _numBuffers(): number;
  8560. /** @hidden */
  8561. get _indexBuffer(): number;
  8562. /** Gets the name of this buffer */
  8563. get name(): string;
  8564. /**
  8565. * Updates the WebGL Uniform Buffer on the GPU.
  8566. * If the `dynamic` flag is set to true, no cache comparison is done.
  8567. * Otherwise, the buffer will be updated only if the cache differs.
  8568. */
  8569. update(): void;
  8570. private _createNewBuffer;
  8571. private _checkNewFrame;
  8572. /**
  8573. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8574. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8575. * @param data Define the flattened data
  8576. * @param size Define the size of the data.
  8577. */
  8578. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8579. /**
  8580. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8581. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8582. * @param data Define the flattened data
  8583. * @param size Define the size of the data.
  8584. */
  8585. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8586. private _valueCache;
  8587. private _cacheMatrix;
  8588. private _updateMatrix3x3ForUniform;
  8589. private _updateMatrix3x3ForEffect;
  8590. private _updateMatrix2x2ForEffect;
  8591. private _updateMatrix2x2ForUniform;
  8592. private _updateFloatForEffect;
  8593. private _updateFloatForUniform;
  8594. private _updateFloat2ForEffect;
  8595. private _updateFloat2ForUniform;
  8596. private _updateFloat3ForEffect;
  8597. private _updateFloat3ForUniform;
  8598. private _updateFloat4ForEffect;
  8599. private _updateFloat4ForUniform;
  8600. private _updateFloatArrayForEffect;
  8601. private _updateFloatArrayForUniform;
  8602. private _updateArrayForEffect;
  8603. private _updateArrayForUniform;
  8604. private _updateIntArrayForEffect;
  8605. private _updateIntArrayForUniform;
  8606. private _updateMatrixForEffect;
  8607. private _updateMatrixForUniform;
  8608. private _updateMatricesForEffect;
  8609. private _updateMatricesForUniform;
  8610. private _updateVector3ForEffect;
  8611. private _updateVector3ForUniform;
  8612. private _updateVector4ForEffect;
  8613. private _updateVector4ForUniform;
  8614. private _updateColor3ForEffect;
  8615. private _updateColor3ForUniform;
  8616. private _updateColor4ForEffect;
  8617. private _updateColor4ForUniform;
  8618. private _updateIntForEffect;
  8619. private _updateIntForUniform;
  8620. private _updateInt2ForEffect;
  8621. private _updateInt2ForUniform;
  8622. private _updateInt3ForEffect;
  8623. private _updateInt3ForUniform;
  8624. private _updateInt4ForEffect;
  8625. private _updateInt4ForUniform;
  8626. /**
  8627. * Sets a sampler uniform on the effect.
  8628. * @param name Define the name of the sampler.
  8629. * @param texture Define the texture to set in the sampler
  8630. */
  8631. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8632. /**
  8633. * Directly updates the value of the uniform in the cache AND on the GPU.
  8634. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8635. * @param data Define the flattened data
  8636. */
  8637. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8638. /**
  8639. * Binds this uniform buffer to an effect.
  8640. * @param effect Define the effect to bind the buffer to
  8641. * @param name Name of the uniform block in the shader.
  8642. */
  8643. bindToEffect(effect: Effect, name: string): void;
  8644. /**
  8645. * Disposes the uniform buffer.
  8646. */
  8647. dispose(): void;
  8648. }
  8649. }
  8650. declare module BABYLON {
  8651. /**
  8652. * Manages the defines for the Material
  8653. */
  8654. export class MaterialDefines {
  8655. /** @hidden */
  8656. protected _keys: string[];
  8657. private _isDirty;
  8658. /** @hidden */
  8659. _renderId: number;
  8660. /** @hidden */
  8661. _areLightsDirty: boolean;
  8662. /** @hidden */
  8663. _areLightsDisposed: boolean;
  8664. /** @hidden */
  8665. _areAttributesDirty: boolean;
  8666. /** @hidden */
  8667. _areTexturesDirty: boolean;
  8668. /** @hidden */
  8669. _areFresnelDirty: boolean;
  8670. /** @hidden */
  8671. _areMiscDirty: boolean;
  8672. /** @hidden */
  8673. _arePrePassDirty: boolean;
  8674. /** @hidden */
  8675. _areImageProcessingDirty: boolean;
  8676. /** @hidden */
  8677. _normals: boolean;
  8678. /** @hidden */
  8679. _uvs: boolean;
  8680. /** @hidden */
  8681. _needNormals: boolean;
  8682. /** @hidden */
  8683. _needUVs: boolean;
  8684. [id: string]: any;
  8685. /**
  8686. * Specifies if the material needs to be re-calculated
  8687. */
  8688. get isDirty(): boolean;
  8689. /**
  8690. * Marks the material to indicate that it has been re-calculated
  8691. */
  8692. markAsProcessed(): void;
  8693. /**
  8694. * Marks the material to indicate that it needs to be re-calculated
  8695. */
  8696. markAsUnprocessed(): void;
  8697. /**
  8698. * Marks the material to indicate all of its defines need to be re-calculated
  8699. */
  8700. markAllAsDirty(): void;
  8701. /**
  8702. * Marks the material to indicate that image processing needs to be re-calculated
  8703. */
  8704. markAsImageProcessingDirty(): void;
  8705. /**
  8706. * Marks the material to indicate the lights need to be re-calculated
  8707. * @param disposed Defines whether the light is dirty due to dispose or not
  8708. */
  8709. markAsLightDirty(disposed?: boolean): void;
  8710. /**
  8711. * Marks the attribute state as changed
  8712. */
  8713. markAsAttributesDirty(): void;
  8714. /**
  8715. * Marks the texture state as changed
  8716. */
  8717. markAsTexturesDirty(): void;
  8718. /**
  8719. * Marks the fresnel state as changed
  8720. */
  8721. markAsFresnelDirty(): void;
  8722. /**
  8723. * Marks the misc state as changed
  8724. */
  8725. markAsMiscDirty(): void;
  8726. /**
  8727. * Marks the prepass state as changed
  8728. */
  8729. markAsPrePassDirty(): void;
  8730. /**
  8731. * Rebuilds the material defines
  8732. */
  8733. rebuild(): void;
  8734. /**
  8735. * Specifies if two material defines are equal
  8736. * @param other - A material define instance to compare to
  8737. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8738. */
  8739. isEqual(other: MaterialDefines): boolean;
  8740. /**
  8741. * Clones this instance's defines to another instance
  8742. * @param other - material defines to clone values to
  8743. */
  8744. cloneTo(other: MaterialDefines): void;
  8745. /**
  8746. * Resets the material define values
  8747. */
  8748. reset(): void;
  8749. /**
  8750. * Converts the material define values to a string
  8751. * @returns - String of material define information
  8752. */
  8753. toString(): string;
  8754. }
  8755. }
  8756. declare module BABYLON {
  8757. /**
  8758. * Enum that determines the text-wrapping mode to use.
  8759. */
  8760. export enum InspectableType {
  8761. /**
  8762. * Checkbox for booleans
  8763. */
  8764. Checkbox = 0,
  8765. /**
  8766. * Sliders for numbers
  8767. */
  8768. Slider = 1,
  8769. /**
  8770. * Vector3
  8771. */
  8772. Vector3 = 2,
  8773. /**
  8774. * Quaternions
  8775. */
  8776. Quaternion = 3,
  8777. /**
  8778. * Color3
  8779. */
  8780. Color3 = 4,
  8781. /**
  8782. * String
  8783. */
  8784. String = 5
  8785. }
  8786. /**
  8787. * Interface used to define custom inspectable properties.
  8788. * This interface is used by the inspector to display custom property grids
  8789. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8790. */
  8791. export interface IInspectable {
  8792. /**
  8793. * Gets the label to display
  8794. */
  8795. label: string;
  8796. /**
  8797. * Gets the name of the property to edit
  8798. */
  8799. propertyName: string;
  8800. /**
  8801. * Gets the type of the editor to use
  8802. */
  8803. type: InspectableType;
  8804. /**
  8805. * Gets the minimum value of the property when using in "slider" mode
  8806. */
  8807. min?: number;
  8808. /**
  8809. * Gets the maximum value of the property when using in "slider" mode
  8810. */
  8811. max?: number;
  8812. /**
  8813. * Gets the setp to use when using in "slider" mode
  8814. */
  8815. step?: number;
  8816. }
  8817. }
  8818. declare module BABYLON {
  8819. /**
  8820. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8821. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8822. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  8823. */
  8824. export abstract class Light extends Node {
  8825. /**
  8826. * Falloff Default: light is falling off following the material specification:
  8827. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8828. */
  8829. static readonly FALLOFF_DEFAULT: number;
  8830. /**
  8831. * Falloff Physical: light is falling off following the inverse squared distance law.
  8832. */
  8833. static readonly FALLOFF_PHYSICAL: number;
  8834. /**
  8835. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8836. * to enhance interoperability with other engines.
  8837. */
  8838. static readonly FALLOFF_GLTF: number;
  8839. /**
  8840. * Falloff Standard: light is falling off like in the standard material
  8841. * to enhance interoperability with other materials.
  8842. */
  8843. static readonly FALLOFF_STANDARD: number;
  8844. /**
  8845. * If every light affecting the material is in this lightmapMode,
  8846. * material.lightmapTexture adds or multiplies
  8847. * (depends on material.useLightmapAsShadowmap)
  8848. * after every other light calculations.
  8849. */
  8850. static readonly LIGHTMAP_DEFAULT: number;
  8851. /**
  8852. * material.lightmapTexture as only diffuse lighting from this light
  8853. * adds only specular lighting from this light
  8854. * adds dynamic shadows
  8855. */
  8856. static readonly LIGHTMAP_SPECULAR: number;
  8857. /**
  8858. * material.lightmapTexture as only lighting
  8859. * no light calculation from this light
  8860. * only adds dynamic shadows from this light
  8861. */
  8862. static readonly LIGHTMAP_SHADOWSONLY: number;
  8863. /**
  8864. * Each light type uses the default quantity according to its type:
  8865. * point/spot lights use luminous intensity
  8866. * directional lights use illuminance
  8867. */
  8868. static readonly INTENSITYMODE_AUTOMATIC: number;
  8869. /**
  8870. * lumen (lm)
  8871. */
  8872. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8873. /**
  8874. * candela (lm/sr)
  8875. */
  8876. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8877. /**
  8878. * lux (lm/m^2)
  8879. */
  8880. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8881. /**
  8882. * nit (cd/m^2)
  8883. */
  8884. static readonly INTENSITYMODE_LUMINANCE: number;
  8885. /**
  8886. * Light type const id of the point light.
  8887. */
  8888. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8889. /**
  8890. * Light type const id of the directional light.
  8891. */
  8892. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8893. /**
  8894. * Light type const id of the spot light.
  8895. */
  8896. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8897. /**
  8898. * Light type const id of the hemispheric light.
  8899. */
  8900. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8901. /**
  8902. * Diffuse gives the basic color to an object.
  8903. */
  8904. diffuse: Color3;
  8905. /**
  8906. * Specular produces a highlight color on an object.
  8907. * Note: This is note affecting PBR materials.
  8908. */
  8909. specular: Color3;
  8910. /**
  8911. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8912. * falling off base on range or angle.
  8913. * This can be set to any values in Light.FALLOFF_x.
  8914. *
  8915. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8916. * other types of materials.
  8917. */
  8918. falloffType: number;
  8919. /**
  8920. * Strength of the light.
  8921. * Note: By default it is define in the framework own unit.
  8922. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8923. */
  8924. intensity: number;
  8925. private _range;
  8926. protected _inverseSquaredRange: number;
  8927. /**
  8928. * Defines how far from the source the light is impacting in scene units.
  8929. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8930. */
  8931. get range(): number;
  8932. /**
  8933. * Defines how far from the source the light is impacting in scene units.
  8934. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8935. */
  8936. set range(value: number);
  8937. /**
  8938. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8939. * of light.
  8940. */
  8941. private _photometricScale;
  8942. private _intensityMode;
  8943. /**
  8944. * Gets the photometric scale used to interpret the intensity.
  8945. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8946. */
  8947. get intensityMode(): number;
  8948. /**
  8949. * Sets the photometric scale used to interpret the intensity.
  8950. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8951. */
  8952. set intensityMode(value: number);
  8953. private _radius;
  8954. /**
  8955. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8956. */
  8957. get radius(): number;
  8958. /**
  8959. * sets the light radius used by PBR Materials to simulate soft area lights.
  8960. */
  8961. set radius(value: number);
  8962. private _renderPriority;
  8963. /**
  8964. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8965. * exceeding the number allowed of the materials.
  8966. */
  8967. renderPriority: number;
  8968. private _shadowEnabled;
  8969. /**
  8970. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8971. * the current shadow generator.
  8972. */
  8973. get shadowEnabled(): boolean;
  8974. /**
  8975. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8976. * the current shadow generator.
  8977. */
  8978. set shadowEnabled(value: boolean);
  8979. private _includedOnlyMeshes;
  8980. /**
  8981. * Gets the only meshes impacted by this light.
  8982. */
  8983. get includedOnlyMeshes(): AbstractMesh[];
  8984. /**
  8985. * Sets the only meshes impacted by this light.
  8986. */
  8987. set includedOnlyMeshes(value: AbstractMesh[]);
  8988. private _excludedMeshes;
  8989. /**
  8990. * Gets the meshes not impacted by this light.
  8991. */
  8992. get excludedMeshes(): AbstractMesh[];
  8993. /**
  8994. * Sets the meshes not impacted by this light.
  8995. */
  8996. set excludedMeshes(value: AbstractMesh[]);
  8997. private _excludeWithLayerMask;
  8998. /**
  8999. * Gets the layer id use to find what meshes are not impacted by the light.
  9000. * Inactive if 0
  9001. */
  9002. get excludeWithLayerMask(): number;
  9003. /**
  9004. * Sets the layer id use to find what meshes are not impacted by the light.
  9005. * Inactive if 0
  9006. */
  9007. set excludeWithLayerMask(value: number);
  9008. private _includeOnlyWithLayerMask;
  9009. /**
  9010. * Gets the layer id use to find what meshes are impacted by the light.
  9011. * Inactive if 0
  9012. */
  9013. get includeOnlyWithLayerMask(): number;
  9014. /**
  9015. * Sets the layer id use to find what meshes are impacted by the light.
  9016. * Inactive if 0
  9017. */
  9018. set includeOnlyWithLayerMask(value: number);
  9019. private _lightmapMode;
  9020. /**
  9021. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9022. */
  9023. get lightmapMode(): number;
  9024. /**
  9025. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9026. */
  9027. set lightmapMode(value: number);
  9028. /**
  9029. * Shadow generator associted to the light.
  9030. * @hidden Internal use only.
  9031. */
  9032. _shadowGenerator: Nullable<IShadowGenerator>;
  9033. /**
  9034. * @hidden Internal use only.
  9035. */
  9036. _excludedMeshesIds: string[];
  9037. /**
  9038. * @hidden Internal use only.
  9039. */
  9040. _includedOnlyMeshesIds: string[];
  9041. /**
  9042. * The current light unifom buffer.
  9043. * @hidden Internal use only.
  9044. */
  9045. _uniformBuffer: UniformBuffer;
  9046. /** @hidden */
  9047. _renderId: number;
  9048. /**
  9049. * Creates a Light object in the scene.
  9050. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9051. * @param name The firendly name of the light
  9052. * @param scene The scene the light belongs too
  9053. */
  9054. constructor(name: string, scene: Scene);
  9055. protected abstract _buildUniformLayout(): void;
  9056. /**
  9057. * Sets the passed Effect "effect" with the Light information.
  9058. * @param effect The effect to update
  9059. * @param lightIndex The index of the light in the effect to update
  9060. * @returns The light
  9061. */
  9062. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9063. /**
  9064. * Sets the passed Effect "effect" with the Light textures.
  9065. * @param effect The effect to update
  9066. * @param lightIndex The index of the light in the effect to update
  9067. * @returns The light
  9068. */
  9069. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9070. /**
  9071. * Binds the lights information from the scene to the effect for the given mesh.
  9072. * @param lightIndex Light index
  9073. * @param scene The scene where the light belongs to
  9074. * @param effect The effect we are binding the data to
  9075. * @param useSpecular Defines if specular is supported
  9076. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9077. */
  9078. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9079. /**
  9080. * Sets the passed Effect "effect" with the Light information.
  9081. * @param effect The effect to update
  9082. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9083. * @returns The light
  9084. */
  9085. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9086. /**
  9087. * Returns the string "Light".
  9088. * @returns the class name
  9089. */
  9090. getClassName(): string;
  9091. /** @hidden */
  9092. readonly _isLight: boolean;
  9093. /**
  9094. * Converts the light information to a readable string for debug purpose.
  9095. * @param fullDetails Supports for multiple levels of logging within scene loading
  9096. * @returns the human readable light info
  9097. */
  9098. toString(fullDetails?: boolean): string;
  9099. /** @hidden */
  9100. protected _syncParentEnabledState(): void;
  9101. /**
  9102. * Set the enabled state of this node.
  9103. * @param value - the new enabled state
  9104. */
  9105. setEnabled(value: boolean): void;
  9106. /**
  9107. * Returns the Light associated shadow generator if any.
  9108. * @return the associated shadow generator.
  9109. */
  9110. getShadowGenerator(): Nullable<IShadowGenerator>;
  9111. /**
  9112. * Returns a Vector3, the absolute light position in the World.
  9113. * @returns the world space position of the light
  9114. */
  9115. getAbsolutePosition(): Vector3;
  9116. /**
  9117. * Specifies if the light will affect the passed mesh.
  9118. * @param mesh The mesh to test against the light
  9119. * @return true the mesh is affected otherwise, false.
  9120. */
  9121. canAffectMesh(mesh: AbstractMesh): boolean;
  9122. /**
  9123. * Sort function to order lights for rendering.
  9124. * @param a First Light object to compare to second.
  9125. * @param b Second Light object to compare first.
  9126. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9127. */
  9128. static CompareLightsPriority(a: Light, b: Light): number;
  9129. /**
  9130. * Releases resources associated with this node.
  9131. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9132. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9133. */
  9134. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9135. /**
  9136. * Returns the light type ID (integer).
  9137. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9138. */
  9139. getTypeID(): number;
  9140. /**
  9141. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9142. * @returns the scaled intensity in intensity mode unit
  9143. */
  9144. getScaledIntensity(): number;
  9145. /**
  9146. * Returns a new Light object, named "name", from the current one.
  9147. * @param name The name of the cloned light
  9148. * @param newParent The parent of this light, if it has one
  9149. * @returns the new created light
  9150. */
  9151. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9152. /**
  9153. * Serializes the current light into a Serialization object.
  9154. * @returns the serialized object.
  9155. */
  9156. serialize(): any;
  9157. /**
  9158. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9159. * This new light is named "name" and added to the passed scene.
  9160. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9161. * @param name The friendly name of the light
  9162. * @param scene The scene the new light will belong to
  9163. * @returns the constructor function
  9164. */
  9165. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9166. /**
  9167. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9168. * @param parsedLight The JSON representation of the light
  9169. * @param scene The scene to create the parsed light in
  9170. * @returns the created light after parsing
  9171. */
  9172. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9173. private _hookArrayForExcluded;
  9174. private _hookArrayForIncludedOnly;
  9175. private _resyncMeshes;
  9176. /**
  9177. * Forces the meshes to update their light related information in their rendering used effects
  9178. * @hidden Internal Use Only
  9179. */
  9180. _markMeshesAsLightDirty(): void;
  9181. /**
  9182. * Recomputes the cached photometric scale if needed.
  9183. */
  9184. private _computePhotometricScale;
  9185. /**
  9186. * Returns the Photometric Scale according to the light type and intensity mode.
  9187. */
  9188. private _getPhotometricScale;
  9189. /**
  9190. * Reorder the light in the scene according to their defined priority.
  9191. * @hidden Internal Use Only
  9192. */
  9193. _reorderLightsInScene(): void;
  9194. /**
  9195. * Prepares the list of defines specific to the light type.
  9196. * @param defines the list of defines
  9197. * @param lightIndex defines the index of the light for the effect
  9198. */
  9199. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9200. }
  9201. }
  9202. declare module BABYLON {
  9203. /** Defines supported spaces */
  9204. export enum Space {
  9205. /** Local (object) space */
  9206. LOCAL = 0,
  9207. /** World space */
  9208. WORLD = 1,
  9209. /** Bone space */
  9210. BONE = 2
  9211. }
  9212. /** Defines the 3 main axes */
  9213. export class Axis {
  9214. /** X axis */
  9215. static X: Vector3;
  9216. /** Y axis */
  9217. static Y: Vector3;
  9218. /** Z axis */
  9219. static Z: Vector3;
  9220. }
  9221. /**
  9222. * Defines cartesian components.
  9223. */
  9224. export enum Coordinate {
  9225. /** X axis */
  9226. X = 0,
  9227. /** Y axis */
  9228. Y = 1,
  9229. /** Z axis */
  9230. Z = 2
  9231. }
  9232. }
  9233. declare module BABYLON {
  9234. /**
  9235. * Interface describing all the common properties and methods a shadow light needs to implement.
  9236. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9237. * as well as binding the different shadow properties to the effects.
  9238. */
  9239. export interface IShadowLight extends Light {
  9240. /**
  9241. * The light id in the scene (used in scene.findLighById for instance)
  9242. */
  9243. id: string;
  9244. /**
  9245. * The position the shdow will be casted from.
  9246. */
  9247. position: Vector3;
  9248. /**
  9249. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9250. */
  9251. direction: Vector3;
  9252. /**
  9253. * The transformed position. Position of the light in world space taking parenting in account.
  9254. */
  9255. transformedPosition: Vector3;
  9256. /**
  9257. * The transformed direction. Direction of the light in world space taking parenting in account.
  9258. */
  9259. transformedDirection: Vector3;
  9260. /**
  9261. * The friendly name of the light in the scene.
  9262. */
  9263. name: string;
  9264. /**
  9265. * Defines the shadow projection clipping minimum z value.
  9266. */
  9267. shadowMinZ: number;
  9268. /**
  9269. * Defines the shadow projection clipping maximum z value.
  9270. */
  9271. shadowMaxZ: number;
  9272. /**
  9273. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9274. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9275. */
  9276. computeTransformedInformation(): boolean;
  9277. /**
  9278. * Gets the scene the light belongs to.
  9279. * @returns The scene
  9280. */
  9281. getScene(): Scene;
  9282. /**
  9283. * Callback defining a custom Projection Matrix Builder.
  9284. * This can be used to override the default projection matrix computation.
  9285. */
  9286. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9287. /**
  9288. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9289. * @param matrix The materix to updated with the projection information
  9290. * @param viewMatrix The transform matrix of the light
  9291. * @param renderList The list of mesh to render in the map
  9292. * @returns The current light
  9293. */
  9294. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9295. /**
  9296. * Gets the current depth scale used in ESM.
  9297. * @returns The scale
  9298. */
  9299. getDepthScale(): number;
  9300. /**
  9301. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9302. * @returns true if a cube texture needs to be use
  9303. */
  9304. needCube(): boolean;
  9305. /**
  9306. * Detects if the projection matrix requires to be recomputed this frame.
  9307. * @returns true if it requires to be recomputed otherwise, false.
  9308. */
  9309. needProjectionMatrixCompute(): boolean;
  9310. /**
  9311. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9312. */
  9313. forceProjectionMatrixCompute(): void;
  9314. /**
  9315. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9316. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9317. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9318. */
  9319. getShadowDirection(faceIndex?: number): Vector3;
  9320. /**
  9321. * Gets the minZ used for shadow according to both the scene and the light.
  9322. * @param activeCamera The camera we are returning the min for
  9323. * @returns the depth min z
  9324. */
  9325. getDepthMinZ(activeCamera: Camera): number;
  9326. /**
  9327. * Gets the maxZ used for shadow according to both the scene and the light.
  9328. * @param activeCamera The camera we are returning the max for
  9329. * @returns the depth max z
  9330. */
  9331. getDepthMaxZ(activeCamera: Camera): number;
  9332. }
  9333. /**
  9334. * Base implementation IShadowLight
  9335. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9336. */
  9337. export abstract class ShadowLight extends Light implements IShadowLight {
  9338. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9339. protected _position: Vector3;
  9340. protected _setPosition(value: Vector3): void;
  9341. /**
  9342. * Sets the position the shadow will be casted from. Also use as the light position for both
  9343. * point and spot lights.
  9344. */
  9345. get position(): Vector3;
  9346. /**
  9347. * Sets the position the shadow will be casted from. Also use as the light position for both
  9348. * point and spot lights.
  9349. */
  9350. set position(value: Vector3);
  9351. protected _direction: Vector3;
  9352. protected _setDirection(value: Vector3): void;
  9353. /**
  9354. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9355. * Also use as the light direction on spot and directional lights.
  9356. */
  9357. get direction(): Vector3;
  9358. /**
  9359. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9360. * Also use as the light direction on spot and directional lights.
  9361. */
  9362. set direction(value: Vector3);
  9363. protected _shadowMinZ: number;
  9364. /**
  9365. * Gets the shadow projection clipping minimum z value.
  9366. */
  9367. get shadowMinZ(): number;
  9368. /**
  9369. * Sets the shadow projection clipping minimum z value.
  9370. */
  9371. set shadowMinZ(value: number);
  9372. protected _shadowMaxZ: number;
  9373. /**
  9374. * Sets the shadow projection clipping maximum z value.
  9375. */
  9376. get shadowMaxZ(): number;
  9377. /**
  9378. * Gets the shadow projection clipping maximum z value.
  9379. */
  9380. set shadowMaxZ(value: number);
  9381. /**
  9382. * Callback defining a custom Projection Matrix Builder.
  9383. * This can be used to override the default projection matrix computation.
  9384. */
  9385. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9386. /**
  9387. * The transformed position. Position of the light in world space taking parenting in account.
  9388. */
  9389. transformedPosition: Vector3;
  9390. /**
  9391. * The transformed direction. Direction of the light in world space taking parenting in account.
  9392. */
  9393. transformedDirection: Vector3;
  9394. private _needProjectionMatrixCompute;
  9395. /**
  9396. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9397. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9398. */
  9399. computeTransformedInformation(): boolean;
  9400. /**
  9401. * Return the depth scale used for the shadow map.
  9402. * @returns the depth scale.
  9403. */
  9404. getDepthScale(): number;
  9405. /**
  9406. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9407. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9408. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9409. */
  9410. getShadowDirection(faceIndex?: number): Vector3;
  9411. /**
  9412. * Returns the ShadowLight absolute position in the World.
  9413. * @returns the position vector in world space
  9414. */
  9415. getAbsolutePosition(): Vector3;
  9416. /**
  9417. * Sets the ShadowLight direction toward the passed target.
  9418. * @param target The point to target in local space
  9419. * @returns the updated ShadowLight direction
  9420. */
  9421. setDirectionToTarget(target: Vector3): Vector3;
  9422. /**
  9423. * Returns the light rotation in euler definition.
  9424. * @returns the x y z rotation in local space.
  9425. */
  9426. getRotation(): Vector3;
  9427. /**
  9428. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9429. * @returns true if a cube texture needs to be use
  9430. */
  9431. needCube(): boolean;
  9432. /**
  9433. * Detects if the projection matrix requires to be recomputed this frame.
  9434. * @returns true if it requires to be recomputed otherwise, false.
  9435. */
  9436. needProjectionMatrixCompute(): boolean;
  9437. /**
  9438. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9439. */
  9440. forceProjectionMatrixCompute(): void;
  9441. /** @hidden */
  9442. _initCache(): void;
  9443. /** @hidden */
  9444. _isSynchronized(): boolean;
  9445. /**
  9446. * Computes the world matrix of the node
  9447. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9448. * @returns the world matrix
  9449. */
  9450. computeWorldMatrix(force?: boolean): Matrix;
  9451. /**
  9452. * Gets the minZ used for shadow according to both the scene and the light.
  9453. * @param activeCamera The camera we are returning the min for
  9454. * @returns the depth min z
  9455. */
  9456. getDepthMinZ(activeCamera: Camera): number;
  9457. /**
  9458. * Gets the maxZ used for shadow according to both the scene and the light.
  9459. * @param activeCamera The camera we are returning the max for
  9460. * @returns the depth max z
  9461. */
  9462. getDepthMaxZ(activeCamera: Camera): number;
  9463. /**
  9464. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9465. * @param matrix The materix to updated with the projection information
  9466. * @param viewMatrix The transform matrix of the light
  9467. * @param renderList The list of mesh to render in the map
  9468. * @returns The current light
  9469. */
  9470. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9471. }
  9472. }
  9473. declare module BABYLON {
  9474. /**
  9475. * Configuration needed for prepass-capable materials
  9476. */
  9477. export class PrePassConfiguration {
  9478. /**
  9479. * Previous world matrices of meshes carrying this material
  9480. * Used for computing velocity
  9481. */
  9482. previousWorldMatrices: {
  9483. [index: number]: Matrix;
  9484. };
  9485. /**
  9486. * Previous view project matrix
  9487. * Used for computing velocity
  9488. */
  9489. previousViewProjection: Matrix;
  9490. /**
  9491. * Previous bones of meshes carrying this material
  9492. * Used for computing velocity
  9493. */
  9494. previousBones: {
  9495. [index: number]: Float32Array;
  9496. };
  9497. /**
  9498. * Add the required uniforms to the current list.
  9499. * @param uniforms defines the current uniform list.
  9500. */
  9501. static AddUniforms(uniforms: string[]): void;
  9502. /**
  9503. * Add the required samplers to the current list.
  9504. * @param samplers defines the current sampler list.
  9505. */
  9506. static AddSamplers(samplers: string[]): void;
  9507. /**
  9508. * Binds the material data.
  9509. * @param effect defines the effect to update
  9510. * @param scene defines the scene the material belongs to.
  9511. * @param mesh The mesh
  9512. * @param world World matrix of this mesh
  9513. * @param isFrozen Is the material frozen
  9514. */
  9515. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9516. }
  9517. }
  9518. declare module BABYLON {
  9519. /**
  9520. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9521. * This is the base of the follow, arc rotate cameras and Free camera
  9522. * @see https://doc.babylonjs.com/features/cameras
  9523. */
  9524. export class TargetCamera extends Camera {
  9525. private static _RigCamTransformMatrix;
  9526. private static _TargetTransformMatrix;
  9527. private static _TargetFocalPoint;
  9528. private _tmpUpVector;
  9529. private _tmpTargetVector;
  9530. /**
  9531. * Define the current direction the camera is moving to
  9532. */
  9533. cameraDirection: Vector3;
  9534. /**
  9535. * Define the current rotation the camera is rotating to
  9536. */
  9537. cameraRotation: Vector2;
  9538. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9539. ignoreParentScaling: boolean;
  9540. /**
  9541. * When set, the up vector of the camera will be updated by the rotation of the camera
  9542. */
  9543. updateUpVectorFromRotation: boolean;
  9544. private _tmpQuaternion;
  9545. /**
  9546. * Define the current rotation of the camera
  9547. */
  9548. rotation: Vector3;
  9549. /**
  9550. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9551. */
  9552. rotationQuaternion: Quaternion;
  9553. /**
  9554. * Define the current speed of the camera
  9555. */
  9556. speed: number;
  9557. /**
  9558. * Add constraint to the camera to prevent it to move freely in all directions and
  9559. * around all axis.
  9560. */
  9561. noRotationConstraint: boolean;
  9562. /**
  9563. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9564. * panning
  9565. */
  9566. invertRotation: boolean;
  9567. /**
  9568. * Speed multiplier for inverse camera panning
  9569. */
  9570. inverseRotationSpeed: number;
  9571. /**
  9572. * Define the current target of the camera as an object or a position.
  9573. */
  9574. lockedTarget: any;
  9575. /** @hidden */
  9576. _currentTarget: Vector3;
  9577. /** @hidden */
  9578. _initialFocalDistance: number;
  9579. /** @hidden */
  9580. _viewMatrix: Matrix;
  9581. /** @hidden */
  9582. _camMatrix: Matrix;
  9583. /** @hidden */
  9584. _cameraTransformMatrix: Matrix;
  9585. /** @hidden */
  9586. _cameraRotationMatrix: Matrix;
  9587. /** @hidden */
  9588. _referencePoint: Vector3;
  9589. /** @hidden */
  9590. _transformedReferencePoint: Vector3;
  9591. /** @hidden */
  9592. _reset: () => void;
  9593. private _defaultUp;
  9594. /**
  9595. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9596. * This is the base of the follow, arc rotate cameras and Free camera
  9597. * @see https://doc.babylonjs.com/features/cameras
  9598. * @param name Defines the name of the camera in the scene
  9599. * @param position Defines the start position of the camera in the scene
  9600. * @param scene Defines the scene the camera belongs to
  9601. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9602. */
  9603. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9604. /**
  9605. * Gets the position in front of the camera at a given distance.
  9606. * @param distance The distance from the camera we want the position to be
  9607. * @returns the position
  9608. */
  9609. getFrontPosition(distance: number): Vector3;
  9610. /** @hidden */
  9611. _getLockedTargetPosition(): Nullable<Vector3>;
  9612. private _storedPosition;
  9613. private _storedRotation;
  9614. private _storedRotationQuaternion;
  9615. /**
  9616. * Store current camera state of the camera (fov, position, rotation, etc..)
  9617. * @returns the camera
  9618. */
  9619. storeState(): Camera;
  9620. /**
  9621. * Restored camera state. You must call storeState() first
  9622. * @returns whether it was successful or not
  9623. * @hidden
  9624. */
  9625. _restoreStateValues(): boolean;
  9626. /** @hidden */
  9627. _initCache(): void;
  9628. /** @hidden */
  9629. _updateCache(ignoreParentClass?: boolean): void;
  9630. /** @hidden */
  9631. _isSynchronizedViewMatrix(): boolean;
  9632. /** @hidden */
  9633. _computeLocalCameraSpeed(): number;
  9634. /**
  9635. * Defines the target the camera should look at.
  9636. * @param target Defines the new target as a Vector or a mesh
  9637. */
  9638. setTarget(target: Vector3): void;
  9639. /**
  9640. * Defines the target point of the camera.
  9641. * The camera looks towards it form the radius distance.
  9642. */
  9643. get target(): Vector3;
  9644. set target(value: Vector3);
  9645. /**
  9646. * Return the current target position of the camera. This value is expressed in local space.
  9647. * @returns the target position
  9648. */
  9649. getTarget(): Vector3;
  9650. /** @hidden */
  9651. _decideIfNeedsToMove(): boolean;
  9652. /** @hidden */
  9653. _updatePosition(): void;
  9654. /** @hidden */
  9655. _checkInputs(): void;
  9656. protected _updateCameraRotationMatrix(): void;
  9657. /**
  9658. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  9659. * @returns the current camera
  9660. */
  9661. private _rotateUpVectorWithCameraRotationMatrix;
  9662. private _cachedRotationZ;
  9663. private _cachedQuaternionRotationZ;
  9664. /** @hidden */
  9665. _getViewMatrix(): Matrix;
  9666. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9667. /**
  9668. * @hidden
  9669. */
  9670. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9671. /**
  9672. * @hidden
  9673. */
  9674. _updateRigCameras(): void;
  9675. private _getRigCamPositionAndTarget;
  9676. /**
  9677. * Gets the current object class name.
  9678. * @return the class name
  9679. */
  9680. getClassName(): string;
  9681. }
  9682. }
  9683. declare module BABYLON {
  9684. /**
  9685. * @ignore
  9686. * This is a list of all the different input types that are available in the application.
  9687. * Fo instance: ArcRotateCameraGamepadInput...
  9688. */
  9689. export var CameraInputTypes: {};
  9690. /**
  9691. * This is the contract to implement in order to create a new input class.
  9692. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9693. */
  9694. export interface ICameraInput<TCamera extends Camera> {
  9695. /**
  9696. * Defines the camera the input is attached to.
  9697. */
  9698. camera: Nullable<TCamera>;
  9699. /**
  9700. * Gets the class name of the current intput.
  9701. * @returns the class name
  9702. */
  9703. getClassName(): string;
  9704. /**
  9705. * Get the friendly name associated with the input class.
  9706. * @returns the input friendly name
  9707. */
  9708. getSimpleName(): string;
  9709. /**
  9710. * Attach the input controls to a specific dom element to get the input from.
  9711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9712. */
  9713. attachControl(noPreventDefault?: boolean): void;
  9714. /**
  9715. * Detach the current controls from the specified dom element.
  9716. */
  9717. detachControl(): void;
  9718. /**
  9719. * Update the current camera state depending on the inputs that have been used this frame.
  9720. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9721. */
  9722. checkInputs?: () => void;
  9723. }
  9724. /**
  9725. * Represents a map of input types to input instance or input index to input instance.
  9726. */
  9727. export interface CameraInputsMap<TCamera extends Camera> {
  9728. /**
  9729. * Accessor to the input by input type.
  9730. */
  9731. [name: string]: ICameraInput<TCamera>;
  9732. /**
  9733. * Accessor to the input by input index.
  9734. */
  9735. [idx: number]: ICameraInput<TCamera>;
  9736. }
  9737. /**
  9738. * This represents the input manager used within a camera.
  9739. * It helps dealing with all the different kind of input attached to a camera.
  9740. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9741. */
  9742. export class CameraInputsManager<TCamera extends Camera> {
  9743. /**
  9744. * Defines the list of inputs attahed to the camera.
  9745. */
  9746. attached: CameraInputsMap<TCamera>;
  9747. /**
  9748. * Defines the dom element the camera is collecting inputs from.
  9749. * This is null if the controls have not been attached.
  9750. */
  9751. attachedToElement: boolean;
  9752. /**
  9753. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9754. */
  9755. noPreventDefault: boolean;
  9756. /**
  9757. * Defined the camera the input manager belongs to.
  9758. */
  9759. camera: TCamera;
  9760. /**
  9761. * Update the current camera state depending on the inputs that have been used this frame.
  9762. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9763. */
  9764. checkInputs: () => void;
  9765. /**
  9766. * Instantiate a new Camera Input Manager.
  9767. * @param camera Defines the camera the input manager blongs to
  9768. */
  9769. constructor(camera: TCamera);
  9770. /**
  9771. * Add an input method to a camera
  9772. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9773. * @param input camera input method
  9774. */
  9775. add(input: ICameraInput<TCamera>): void;
  9776. /**
  9777. * Remove a specific input method from a camera
  9778. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9779. * @param inputToRemove camera input method
  9780. */
  9781. remove(inputToRemove: ICameraInput<TCamera>): void;
  9782. /**
  9783. * Remove a specific input type from a camera
  9784. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9785. * @param inputType the type of the input to remove
  9786. */
  9787. removeByType(inputType: string): void;
  9788. private _addCheckInputs;
  9789. /**
  9790. * Attach the input controls to the currently attached dom element to listen the events from.
  9791. * @param input Defines the input to attach
  9792. */
  9793. attachInput(input: ICameraInput<TCamera>): void;
  9794. /**
  9795. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9796. * @param element Defines the dom element to collect the events from
  9797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9798. */
  9799. attachElement(noPreventDefault?: boolean): void;
  9800. /**
  9801. * Detach the current manager inputs controls from a specific dom element.
  9802. * @param element Defines the dom element to collect the events from
  9803. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9804. */
  9805. detachElement(disconnect?: boolean): void;
  9806. /**
  9807. * Rebuild the dynamic inputCheck function from the current list of
  9808. * defined inputs in the manager.
  9809. */
  9810. rebuildInputCheck(): void;
  9811. /**
  9812. * Remove all attached input methods from a camera
  9813. */
  9814. clear(): void;
  9815. /**
  9816. * Serialize the current input manager attached to a camera.
  9817. * This ensures than once parsed,
  9818. * the input associated to the camera will be identical to the current ones
  9819. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9820. */
  9821. serialize(serializedCamera: any): void;
  9822. /**
  9823. * Parses an input manager serialized JSON to restore the previous list of inputs
  9824. * and states associated to a camera.
  9825. * @param parsedCamera Defines the JSON to parse
  9826. */
  9827. parse(parsedCamera: any): void;
  9828. }
  9829. }
  9830. declare module BABYLON {
  9831. /**
  9832. * Gather the list of keyboard event types as constants.
  9833. */
  9834. export class KeyboardEventTypes {
  9835. /**
  9836. * The keydown event is fired when a key becomes active (pressed).
  9837. */
  9838. static readonly KEYDOWN: number;
  9839. /**
  9840. * The keyup event is fired when a key has been released.
  9841. */
  9842. static readonly KEYUP: number;
  9843. }
  9844. /**
  9845. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9846. */
  9847. export class KeyboardInfo {
  9848. /**
  9849. * Defines the type of event (KeyboardEventTypes)
  9850. */
  9851. type: number;
  9852. /**
  9853. * Defines the related dom event
  9854. */
  9855. event: KeyboardEvent;
  9856. /**
  9857. * Instantiates a new keyboard info.
  9858. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9859. * @param type Defines the type of event (KeyboardEventTypes)
  9860. * @param event Defines the related dom event
  9861. */
  9862. constructor(
  9863. /**
  9864. * Defines the type of event (KeyboardEventTypes)
  9865. */
  9866. type: number,
  9867. /**
  9868. * Defines the related dom event
  9869. */
  9870. event: KeyboardEvent);
  9871. }
  9872. /**
  9873. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9874. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9875. */
  9876. export class KeyboardInfoPre extends KeyboardInfo {
  9877. /**
  9878. * Defines the type of event (KeyboardEventTypes)
  9879. */
  9880. type: number;
  9881. /**
  9882. * Defines the related dom event
  9883. */
  9884. event: KeyboardEvent;
  9885. /**
  9886. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9887. */
  9888. skipOnPointerObservable: boolean;
  9889. /**
  9890. * Instantiates a new keyboard pre info.
  9891. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9892. * @param type Defines the type of event (KeyboardEventTypes)
  9893. * @param event Defines the related dom event
  9894. */
  9895. constructor(
  9896. /**
  9897. * Defines the type of event (KeyboardEventTypes)
  9898. */
  9899. type: number,
  9900. /**
  9901. * Defines the related dom event
  9902. */
  9903. event: KeyboardEvent);
  9904. }
  9905. }
  9906. declare module BABYLON {
  9907. /**
  9908. * Manage the keyboard inputs to control the movement of a free camera.
  9909. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9910. */
  9911. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9912. /**
  9913. * Defines the camera the input is attached to.
  9914. */
  9915. camera: FreeCamera;
  9916. /**
  9917. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9918. */
  9919. keysUp: number[];
  9920. /**
  9921. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9922. */
  9923. keysUpward: number[];
  9924. /**
  9925. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9926. */
  9927. keysDown: number[];
  9928. /**
  9929. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9930. */
  9931. keysDownward: number[];
  9932. /**
  9933. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9934. */
  9935. keysLeft: number[];
  9936. /**
  9937. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9938. */
  9939. keysRight: number[];
  9940. private _keys;
  9941. private _onCanvasBlurObserver;
  9942. private _onKeyboardObserver;
  9943. private _engine;
  9944. private _scene;
  9945. /**
  9946. * Attach the input controls to a specific dom element to get the input from.
  9947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9948. */
  9949. attachControl(noPreventDefault?: boolean): void;
  9950. /**
  9951. * Detach the current controls from the specified dom element.
  9952. */
  9953. detachControl(): void;
  9954. /**
  9955. * Update the current camera state depending on the inputs that have been used this frame.
  9956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9957. */
  9958. checkInputs(): void;
  9959. /**
  9960. * Gets the class name of the current intput.
  9961. * @returns the class name
  9962. */
  9963. getClassName(): string;
  9964. /** @hidden */
  9965. _onLostFocus(): void;
  9966. /**
  9967. * Get the friendly name associated with the input class.
  9968. * @returns the input friendly name
  9969. */
  9970. getSimpleName(): string;
  9971. }
  9972. }
  9973. declare module BABYLON {
  9974. /**
  9975. * Interface used to define Action
  9976. */
  9977. export interface IAction {
  9978. /**
  9979. * Trigger for the action
  9980. */
  9981. trigger: number;
  9982. /** Options of the trigger */
  9983. triggerOptions: any;
  9984. /**
  9985. * Gets the trigger parameters
  9986. * @returns the trigger parameters
  9987. */
  9988. getTriggerParameter(): any;
  9989. /**
  9990. * Internal only - executes current action event
  9991. * @hidden
  9992. */
  9993. _executeCurrent(evt?: ActionEvent): void;
  9994. /**
  9995. * Serialize placeholder for child classes
  9996. * @param parent of child
  9997. * @returns the serialized object
  9998. */
  9999. serialize(parent: any): any;
  10000. /**
  10001. * Internal only
  10002. * @hidden
  10003. */
  10004. _prepare(): void;
  10005. /**
  10006. * Internal only - manager for action
  10007. * @hidden
  10008. */
  10009. _actionManager: Nullable<AbstractActionManager>;
  10010. /**
  10011. * Adds action to chain of actions, may be a DoNothingAction
  10012. * @param action defines the next action to execute
  10013. * @returns The action passed in
  10014. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10015. */
  10016. then(action: IAction): IAction;
  10017. }
  10018. /**
  10019. * The action to be carried out following a trigger
  10020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10021. */
  10022. export class Action implements IAction {
  10023. /** the trigger, with or without parameters, for the action */
  10024. triggerOptions: any;
  10025. /**
  10026. * Trigger for the action
  10027. */
  10028. trigger: number;
  10029. /**
  10030. * Internal only - manager for action
  10031. * @hidden
  10032. */
  10033. _actionManager: ActionManager;
  10034. private _nextActiveAction;
  10035. private _child;
  10036. private _condition?;
  10037. private _triggerParameter;
  10038. /**
  10039. * An event triggered prior to action being executed.
  10040. */
  10041. onBeforeExecuteObservable: Observable<Action>;
  10042. /**
  10043. * Creates a new Action
  10044. * @param triggerOptions the trigger, with or without parameters, for the action
  10045. * @param condition an optional determinant of action
  10046. */
  10047. constructor(
  10048. /** the trigger, with or without parameters, for the action */
  10049. triggerOptions: any, condition?: Condition);
  10050. /**
  10051. * Internal only
  10052. * @hidden
  10053. */
  10054. _prepare(): void;
  10055. /**
  10056. * Gets the trigger parameter
  10057. * @returns the trigger parameter
  10058. */
  10059. getTriggerParameter(): any;
  10060. /**
  10061. * Sets the trigger parameter
  10062. * @param value defines the new trigger parameter
  10063. */
  10064. setTriggerParameter(value: any): void;
  10065. /**
  10066. * Internal only - executes current action event
  10067. * @hidden
  10068. */
  10069. _executeCurrent(evt?: ActionEvent): void;
  10070. /**
  10071. * Execute placeholder for child classes
  10072. * @param evt optional action event
  10073. */
  10074. execute(evt?: ActionEvent): void;
  10075. /**
  10076. * Skips to next active action
  10077. */
  10078. skipToNextActiveAction(): void;
  10079. /**
  10080. * Adds action to chain of actions, may be a DoNothingAction
  10081. * @param action defines the next action to execute
  10082. * @returns The action passed in
  10083. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10084. */
  10085. then(action: Action): Action;
  10086. /**
  10087. * Internal only
  10088. * @hidden
  10089. */
  10090. _getProperty(propertyPath: string): string;
  10091. /**
  10092. * Internal only
  10093. * @hidden
  10094. */
  10095. _getEffectiveTarget(target: any, propertyPath: string): any;
  10096. /**
  10097. * Serialize placeholder for child classes
  10098. * @param parent of child
  10099. * @returns the serialized object
  10100. */
  10101. serialize(parent: any): any;
  10102. /**
  10103. * Internal only called by serialize
  10104. * @hidden
  10105. */
  10106. protected _serialize(serializedAction: any, parent?: any): any;
  10107. /**
  10108. * Internal only
  10109. * @hidden
  10110. */
  10111. static _SerializeValueAsString: (value: any) => string;
  10112. /**
  10113. * Internal only
  10114. * @hidden
  10115. */
  10116. static _GetTargetProperty: (target: Scene | Node) => {
  10117. name: string;
  10118. targetType: string;
  10119. value: string;
  10120. };
  10121. }
  10122. }
  10123. declare module BABYLON {
  10124. /**
  10125. * A Condition applied to an Action
  10126. */
  10127. export class Condition {
  10128. /**
  10129. * Internal only - manager for action
  10130. * @hidden
  10131. */
  10132. _actionManager: ActionManager;
  10133. /**
  10134. * Internal only
  10135. * @hidden
  10136. */
  10137. _evaluationId: number;
  10138. /**
  10139. * Internal only
  10140. * @hidden
  10141. */
  10142. _currentResult: boolean;
  10143. /**
  10144. * Creates a new Condition
  10145. * @param actionManager the manager of the action the condition is applied to
  10146. */
  10147. constructor(actionManager: ActionManager);
  10148. /**
  10149. * Check if the current condition is valid
  10150. * @returns a boolean
  10151. */
  10152. isValid(): boolean;
  10153. /**
  10154. * Internal only
  10155. * @hidden
  10156. */
  10157. _getProperty(propertyPath: string): string;
  10158. /**
  10159. * Internal only
  10160. * @hidden
  10161. */
  10162. _getEffectiveTarget(target: any, propertyPath: string): any;
  10163. /**
  10164. * Serialize placeholder for child classes
  10165. * @returns the serialized object
  10166. */
  10167. serialize(): any;
  10168. /**
  10169. * Internal only
  10170. * @hidden
  10171. */
  10172. protected _serialize(serializedCondition: any): any;
  10173. }
  10174. /**
  10175. * Defines specific conditional operators as extensions of Condition
  10176. */
  10177. export class ValueCondition extends Condition {
  10178. /** path to specify the property of the target the conditional operator uses */
  10179. propertyPath: string;
  10180. /** the value compared by the conditional operator against the current value of the property */
  10181. value: any;
  10182. /** the conditional operator, default ValueCondition.IsEqual */
  10183. operator: number;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. private static _IsEqual;
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */
  10193. private static _IsDifferent;
  10194. /**
  10195. * Internal only
  10196. * @hidden
  10197. */
  10198. private static _IsGreater;
  10199. /**
  10200. * Internal only
  10201. * @hidden
  10202. */
  10203. private static _IsLesser;
  10204. /**
  10205. * returns the number for IsEqual
  10206. */
  10207. static get IsEqual(): number;
  10208. /**
  10209. * Returns the number for IsDifferent
  10210. */
  10211. static get IsDifferent(): number;
  10212. /**
  10213. * Returns the number for IsGreater
  10214. */
  10215. static get IsGreater(): number;
  10216. /**
  10217. * Returns the number for IsLesser
  10218. */
  10219. static get IsLesser(): number;
  10220. /**
  10221. * Internal only The action manager for the condition
  10222. * @hidden
  10223. */
  10224. _actionManager: ActionManager;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. private _target;
  10230. /**
  10231. * Internal only
  10232. * @hidden
  10233. */
  10234. private _effectiveTarget;
  10235. /**
  10236. * Internal only
  10237. * @hidden
  10238. */
  10239. private _property;
  10240. /**
  10241. * Creates a new ValueCondition
  10242. * @param actionManager manager for the action the condition applies to
  10243. * @param target for the action
  10244. * @param propertyPath path to specify the property of the target the conditional operator uses
  10245. * @param value the value compared by the conditional operator against the current value of the property
  10246. * @param operator the conditional operator, default ValueCondition.IsEqual
  10247. */
  10248. constructor(actionManager: ActionManager, target: any,
  10249. /** path to specify the property of the target the conditional operator uses */
  10250. propertyPath: string,
  10251. /** the value compared by the conditional operator against the current value of the property */
  10252. value: any,
  10253. /** the conditional operator, default ValueCondition.IsEqual */
  10254. operator?: number);
  10255. /**
  10256. * Compares the given value with the property value for the specified conditional operator
  10257. * @returns the result of the comparison
  10258. */
  10259. isValid(): boolean;
  10260. /**
  10261. * Serialize the ValueCondition into a JSON compatible object
  10262. * @returns serialization object
  10263. */
  10264. serialize(): any;
  10265. /**
  10266. * Gets the name of the conditional operator for the ValueCondition
  10267. * @param operator the conditional operator
  10268. * @returns the name
  10269. */
  10270. static GetOperatorName(operator: number): string;
  10271. }
  10272. /**
  10273. * Defines a predicate condition as an extension of Condition
  10274. */
  10275. export class PredicateCondition extends Condition {
  10276. /** defines the predicate function used to validate the condition */
  10277. predicate: () => boolean;
  10278. /**
  10279. * Internal only - manager for action
  10280. * @hidden
  10281. */
  10282. _actionManager: ActionManager;
  10283. /**
  10284. * Creates a new PredicateCondition
  10285. * @param actionManager manager for the action the condition applies to
  10286. * @param predicate defines the predicate function used to validate the condition
  10287. */
  10288. constructor(actionManager: ActionManager,
  10289. /** defines the predicate function used to validate the condition */
  10290. predicate: () => boolean);
  10291. /**
  10292. * @returns the validity of the predicate condition
  10293. */
  10294. isValid(): boolean;
  10295. }
  10296. /**
  10297. * Defines a state condition as an extension of Condition
  10298. */
  10299. export class StateCondition extends Condition {
  10300. /** Value to compare with target state */
  10301. value: string;
  10302. /**
  10303. * Internal only - manager for action
  10304. * @hidden
  10305. */
  10306. _actionManager: ActionManager;
  10307. /**
  10308. * Internal only
  10309. * @hidden
  10310. */
  10311. private _target;
  10312. /**
  10313. * Creates a new StateCondition
  10314. * @param actionManager manager for the action the condition applies to
  10315. * @param target of the condition
  10316. * @param value to compare with target state
  10317. */
  10318. constructor(actionManager: ActionManager, target: any,
  10319. /** Value to compare with target state */
  10320. value: string);
  10321. /**
  10322. * Gets a boolean indicating if the current condition is met
  10323. * @returns the validity of the state
  10324. */
  10325. isValid(): boolean;
  10326. /**
  10327. * Serialize the StateCondition into a JSON compatible object
  10328. * @returns serialization object
  10329. */
  10330. serialize(): any;
  10331. }
  10332. }
  10333. declare module BABYLON {
  10334. /**
  10335. * This defines an action responsible to toggle a boolean once triggered.
  10336. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10337. */
  10338. export class SwitchBooleanAction extends Action {
  10339. /**
  10340. * The path to the boolean property in the target object
  10341. */
  10342. propertyPath: string;
  10343. private _target;
  10344. private _effectiveTarget;
  10345. private _property;
  10346. /**
  10347. * Instantiate the action
  10348. * @param triggerOptions defines the trigger options
  10349. * @param target defines the object containing the boolean
  10350. * @param propertyPath defines the path to the boolean property in the target object
  10351. * @param condition defines the trigger related conditions
  10352. */
  10353. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10354. /** @hidden */
  10355. _prepare(): void;
  10356. /**
  10357. * Execute the action toggle the boolean value.
  10358. */
  10359. execute(): void;
  10360. /**
  10361. * Serializes the actions and its related information.
  10362. * @param parent defines the object to serialize in
  10363. * @returns the serialized object
  10364. */
  10365. serialize(parent: any): any;
  10366. }
  10367. /**
  10368. * This defines an action responsible to set a the state field of the target
  10369. * to a desired value once triggered.
  10370. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10371. */
  10372. export class SetStateAction extends Action {
  10373. /**
  10374. * The value to store in the state field.
  10375. */
  10376. value: string;
  10377. private _target;
  10378. /**
  10379. * Instantiate the action
  10380. * @param triggerOptions defines the trigger options
  10381. * @param target defines the object containing the state property
  10382. * @param value defines the value to store in the state field
  10383. * @param condition defines the trigger related conditions
  10384. */
  10385. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10386. /**
  10387. * Execute the action and store the value on the target state property.
  10388. */
  10389. execute(): void;
  10390. /**
  10391. * Serializes the actions and its related information.
  10392. * @param parent defines the object to serialize in
  10393. * @returns the serialized object
  10394. */
  10395. serialize(parent: any): any;
  10396. }
  10397. /**
  10398. * This defines an action responsible to set a property of the target
  10399. * to a desired value once triggered.
  10400. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10401. */
  10402. export class SetValueAction extends Action {
  10403. /**
  10404. * The path of the property to set in the target.
  10405. */
  10406. propertyPath: string;
  10407. /**
  10408. * The value to set in the property
  10409. */
  10410. value: any;
  10411. private _target;
  10412. private _effectiveTarget;
  10413. private _property;
  10414. /**
  10415. * Instantiate the action
  10416. * @param triggerOptions defines the trigger options
  10417. * @param target defines the object containing the property
  10418. * @param propertyPath defines the path of the property to set in the target
  10419. * @param value defines the value to set in the property
  10420. * @param condition defines the trigger related conditions
  10421. */
  10422. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10423. /** @hidden */
  10424. _prepare(): void;
  10425. /**
  10426. * Execute the action and set the targetted property to the desired value.
  10427. */
  10428. execute(): void;
  10429. /**
  10430. * Serializes the actions and its related information.
  10431. * @param parent defines the object to serialize in
  10432. * @returns the serialized object
  10433. */
  10434. serialize(parent: any): any;
  10435. }
  10436. /**
  10437. * This defines an action responsible to increment the target value
  10438. * to a desired value once triggered.
  10439. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10440. */
  10441. export class IncrementValueAction extends Action {
  10442. /**
  10443. * The path of the property to increment in the target.
  10444. */
  10445. propertyPath: string;
  10446. /**
  10447. * The value we should increment the property by.
  10448. */
  10449. value: any;
  10450. private _target;
  10451. private _effectiveTarget;
  10452. private _property;
  10453. /**
  10454. * Instantiate the action
  10455. * @param triggerOptions defines the trigger options
  10456. * @param target defines the object containing the property
  10457. * @param propertyPath defines the path of the property to increment in the target
  10458. * @param value defines the value value we should increment the property by
  10459. * @param condition defines the trigger related conditions
  10460. */
  10461. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10462. /** @hidden */
  10463. _prepare(): void;
  10464. /**
  10465. * Execute the action and increment the target of the value amount.
  10466. */
  10467. execute(): void;
  10468. /**
  10469. * Serializes the actions and its related information.
  10470. * @param parent defines the object to serialize in
  10471. * @returns the serialized object
  10472. */
  10473. serialize(parent: any): any;
  10474. }
  10475. /**
  10476. * This defines an action responsible to start an animation once triggered.
  10477. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10478. */
  10479. export class PlayAnimationAction extends Action {
  10480. /**
  10481. * Where the animation should start (animation frame)
  10482. */
  10483. from: number;
  10484. /**
  10485. * Where the animation should stop (animation frame)
  10486. */
  10487. to: number;
  10488. /**
  10489. * Define if the animation should loop or stop after the first play.
  10490. */
  10491. loop?: boolean;
  10492. private _target;
  10493. /**
  10494. * Instantiate the action
  10495. * @param triggerOptions defines the trigger options
  10496. * @param target defines the target animation or animation name
  10497. * @param from defines from where the animation should start (animation frame)
  10498. * @param end defines where the animation should stop (animation frame)
  10499. * @param loop defines if the animation should loop or stop after the first play
  10500. * @param condition defines the trigger related conditions
  10501. */
  10502. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10503. /** @hidden */
  10504. _prepare(): void;
  10505. /**
  10506. * Execute the action and play the animation.
  10507. */
  10508. execute(): void;
  10509. /**
  10510. * Serializes the actions and its related information.
  10511. * @param parent defines the object to serialize in
  10512. * @returns the serialized object
  10513. */
  10514. serialize(parent: any): any;
  10515. }
  10516. /**
  10517. * This defines an action responsible to stop an animation once triggered.
  10518. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10519. */
  10520. export class StopAnimationAction extends Action {
  10521. private _target;
  10522. /**
  10523. * Instantiate the action
  10524. * @param triggerOptions defines the trigger options
  10525. * @param target defines the target animation or animation name
  10526. * @param condition defines the trigger related conditions
  10527. */
  10528. constructor(triggerOptions: any, target: any, condition?: Condition);
  10529. /** @hidden */
  10530. _prepare(): void;
  10531. /**
  10532. * Execute the action and stop the animation.
  10533. */
  10534. execute(): void;
  10535. /**
  10536. * Serializes the actions and its related information.
  10537. * @param parent defines the object to serialize in
  10538. * @returns the serialized object
  10539. */
  10540. serialize(parent: any): any;
  10541. }
  10542. /**
  10543. * This defines an action responsible that does nothing once triggered.
  10544. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10545. */
  10546. export class DoNothingAction extends Action {
  10547. /**
  10548. * Instantiate the action
  10549. * @param triggerOptions defines the trigger options
  10550. * @param condition defines the trigger related conditions
  10551. */
  10552. constructor(triggerOptions?: any, condition?: Condition);
  10553. /**
  10554. * Execute the action and do nothing.
  10555. */
  10556. execute(): void;
  10557. /**
  10558. * Serializes the actions and its related information.
  10559. * @param parent defines the object to serialize in
  10560. * @returns the serialized object
  10561. */
  10562. serialize(parent: any): any;
  10563. }
  10564. /**
  10565. * This defines an action responsible to trigger several actions once triggered.
  10566. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10567. */
  10568. export class CombineAction extends Action {
  10569. /**
  10570. * The list of aggregated animations to run.
  10571. */
  10572. children: Action[];
  10573. /**
  10574. * Instantiate the action
  10575. * @param triggerOptions defines the trigger options
  10576. * @param children defines the list of aggregated animations to run
  10577. * @param condition defines the trigger related conditions
  10578. */
  10579. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10580. /** @hidden */
  10581. _prepare(): void;
  10582. /**
  10583. * Execute the action and executes all the aggregated actions.
  10584. */
  10585. execute(evt: ActionEvent): void;
  10586. /**
  10587. * Serializes the actions and its related information.
  10588. * @param parent defines the object to serialize in
  10589. * @returns the serialized object
  10590. */
  10591. serialize(parent: any): any;
  10592. }
  10593. /**
  10594. * This defines an action responsible to run code (external event) once triggered.
  10595. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10596. */
  10597. export class ExecuteCodeAction extends Action {
  10598. /**
  10599. * The callback function to run.
  10600. */
  10601. func: (evt: ActionEvent) => void;
  10602. /**
  10603. * Instantiate the action
  10604. * @param triggerOptions defines the trigger options
  10605. * @param func defines the callback function to run
  10606. * @param condition defines the trigger related conditions
  10607. */
  10608. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10609. /**
  10610. * Execute the action and run the attached code.
  10611. */
  10612. execute(evt: ActionEvent): void;
  10613. }
  10614. /**
  10615. * This defines an action responsible to set the parent property of the target once triggered.
  10616. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class SetParentAction extends Action {
  10619. private _parent;
  10620. private _target;
  10621. /**
  10622. * Instantiate the action
  10623. * @param triggerOptions defines the trigger options
  10624. * @param target defines the target containing the parent property
  10625. * @param parent defines from where the animation should start (animation frame)
  10626. * @param condition defines the trigger related conditions
  10627. */
  10628. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10629. /** @hidden */
  10630. _prepare(): void;
  10631. /**
  10632. * Execute the action and set the parent property.
  10633. */
  10634. execute(): void;
  10635. /**
  10636. * Serializes the actions and its related information.
  10637. * @param parent defines the object to serialize in
  10638. * @returns the serialized object
  10639. */
  10640. serialize(parent: any): any;
  10641. }
  10642. }
  10643. declare module BABYLON {
  10644. /**
  10645. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10646. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10647. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10648. */
  10649. export class ActionManager extends AbstractActionManager {
  10650. /**
  10651. * Nothing
  10652. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10653. */
  10654. static readonly NothingTrigger: number;
  10655. /**
  10656. * On pick
  10657. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10658. */
  10659. static readonly OnPickTrigger: number;
  10660. /**
  10661. * On left pick
  10662. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10663. */
  10664. static readonly OnLeftPickTrigger: number;
  10665. /**
  10666. * On right pick
  10667. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10668. */
  10669. static readonly OnRightPickTrigger: number;
  10670. /**
  10671. * On center pick
  10672. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10673. */
  10674. static readonly OnCenterPickTrigger: number;
  10675. /**
  10676. * On pick down
  10677. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10678. */
  10679. static readonly OnPickDownTrigger: number;
  10680. /**
  10681. * On double pick
  10682. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10683. */
  10684. static readonly OnDoublePickTrigger: number;
  10685. /**
  10686. * On pick up
  10687. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10688. */
  10689. static readonly OnPickUpTrigger: number;
  10690. /**
  10691. * On pick out.
  10692. * This trigger will only be raised if you also declared a OnPickDown
  10693. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10694. */
  10695. static readonly OnPickOutTrigger: number;
  10696. /**
  10697. * On long press
  10698. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10699. */
  10700. static readonly OnLongPressTrigger: number;
  10701. /**
  10702. * On pointer over
  10703. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10704. */
  10705. static readonly OnPointerOverTrigger: number;
  10706. /**
  10707. * On pointer out
  10708. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10709. */
  10710. static readonly OnPointerOutTrigger: number;
  10711. /**
  10712. * On every frame
  10713. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10714. */
  10715. static readonly OnEveryFrameTrigger: number;
  10716. /**
  10717. * On intersection enter
  10718. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10719. */
  10720. static readonly OnIntersectionEnterTrigger: number;
  10721. /**
  10722. * On intersection exit
  10723. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10724. */
  10725. static readonly OnIntersectionExitTrigger: number;
  10726. /**
  10727. * On key down
  10728. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10729. */
  10730. static readonly OnKeyDownTrigger: number;
  10731. /**
  10732. * On key up
  10733. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10734. */
  10735. static readonly OnKeyUpTrigger: number;
  10736. private _scene;
  10737. /**
  10738. * Creates a new action manager
  10739. * @param scene defines the hosting scene
  10740. */
  10741. constructor(scene: Scene);
  10742. /**
  10743. * Releases all associated resources
  10744. */
  10745. dispose(): void;
  10746. /**
  10747. * Gets hosting scene
  10748. * @returns the hosting scene
  10749. */
  10750. getScene(): Scene;
  10751. /**
  10752. * Does this action manager handles actions of any of the given triggers
  10753. * @param triggers defines the triggers to be tested
  10754. * @return a boolean indicating whether one (or more) of the triggers is handled
  10755. */
  10756. hasSpecificTriggers(triggers: number[]): boolean;
  10757. /**
  10758. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10759. * speed.
  10760. * @param triggerA defines the trigger to be tested
  10761. * @param triggerB defines the trigger to be tested
  10762. * @return a boolean indicating whether one (or more) of the triggers is handled
  10763. */
  10764. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10765. /**
  10766. * Does this action manager handles actions of a given trigger
  10767. * @param trigger defines the trigger to be tested
  10768. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10769. * @return whether the trigger is handled
  10770. */
  10771. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10772. /**
  10773. * Does this action manager has pointer triggers
  10774. */
  10775. get hasPointerTriggers(): boolean;
  10776. /**
  10777. * Does this action manager has pick triggers
  10778. */
  10779. get hasPickTriggers(): boolean;
  10780. /**
  10781. * Registers an action to this action manager
  10782. * @param action defines the action to be registered
  10783. * @return the action amended (prepared) after registration
  10784. */
  10785. registerAction(action: IAction): Nullable<IAction>;
  10786. /**
  10787. * Unregisters an action to this action manager
  10788. * @param action defines the action to be unregistered
  10789. * @return a boolean indicating whether the action has been unregistered
  10790. */
  10791. unregisterAction(action: IAction): Boolean;
  10792. /**
  10793. * Process a specific trigger
  10794. * @param trigger defines the trigger to process
  10795. * @param evt defines the event details to be processed
  10796. */
  10797. processTrigger(trigger: number, evt?: IActionEvent): void;
  10798. /** @hidden */
  10799. _getEffectiveTarget(target: any, propertyPath: string): any;
  10800. /** @hidden */
  10801. _getProperty(propertyPath: string): string;
  10802. /**
  10803. * Serialize this manager to a JSON object
  10804. * @param name defines the property name to store this manager
  10805. * @returns a JSON representation of this manager
  10806. */
  10807. serialize(name: string): any;
  10808. /**
  10809. * Creates a new ActionManager from a JSON data
  10810. * @param parsedActions defines the JSON data to read from
  10811. * @param object defines the hosting mesh
  10812. * @param scene defines the hosting scene
  10813. */
  10814. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10815. /**
  10816. * Get a trigger name by index
  10817. * @param trigger defines the trigger index
  10818. * @returns a trigger name
  10819. */
  10820. static GetTriggerName(trigger: number): string;
  10821. }
  10822. }
  10823. declare module BABYLON {
  10824. /**
  10825. * Class representing a ray with position and direction
  10826. */
  10827. export class Ray {
  10828. /** origin point */
  10829. origin: Vector3;
  10830. /** direction */
  10831. direction: Vector3;
  10832. /** length of the ray */
  10833. length: number;
  10834. private static readonly _TmpVector3;
  10835. private _tmpRay;
  10836. /**
  10837. * Creates a new ray
  10838. * @param origin origin point
  10839. * @param direction direction
  10840. * @param length length of the ray
  10841. */
  10842. constructor(
  10843. /** origin point */
  10844. origin: Vector3,
  10845. /** direction */
  10846. direction: Vector3,
  10847. /** length of the ray */
  10848. length?: number);
  10849. /**
  10850. * Checks if the ray intersects a box
  10851. * This does not account for the ray lenght by design to improve perfs.
  10852. * @param minimum bound of the box
  10853. * @param maximum bound of the box
  10854. * @param intersectionTreshold extra extend to be added to the box in all direction
  10855. * @returns if the box was hit
  10856. */
  10857. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10858. /**
  10859. * Checks if the ray intersects a box
  10860. * This does not account for the ray lenght by design to improve perfs.
  10861. * @param box the bounding box to check
  10862. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10863. * @returns if the box was hit
  10864. */
  10865. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10866. /**
  10867. * If the ray hits a sphere
  10868. * @param sphere the bounding sphere to check
  10869. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10870. * @returns true if it hits the sphere
  10871. */
  10872. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10873. /**
  10874. * If the ray hits a triange
  10875. * @param vertex0 triangle vertex
  10876. * @param vertex1 triangle vertex
  10877. * @param vertex2 triangle vertex
  10878. * @returns intersection information if hit
  10879. */
  10880. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10881. /**
  10882. * Checks if ray intersects a plane
  10883. * @param plane the plane to check
  10884. * @returns the distance away it was hit
  10885. */
  10886. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10887. /**
  10888. * Calculate the intercept of a ray on a given axis
  10889. * @param axis to check 'x' | 'y' | 'z'
  10890. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10891. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10892. */
  10893. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10894. /**
  10895. * Checks if ray intersects a mesh
  10896. * @param mesh the mesh to check
  10897. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10898. * @returns picking info of the intersecton
  10899. */
  10900. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10901. /**
  10902. * Checks if ray intersects a mesh
  10903. * @param meshes the meshes to check
  10904. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10905. * @param results array to store result in
  10906. * @returns Array of picking infos
  10907. */
  10908. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10909. private _comparePickingInfo;
  10910. private static smallnum;
  10911. private static rayl;
  10912. /**
  10913. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10914. * @param sega the first point of the segment to test the intersection against
  10915. * @param segb the second point of the segment to test the intersection against
  10916. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10917. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10918. */
  10919. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10920. /**
  10921. * Update the ray from viewport position
  10922. * @param x position
  10923. * @param y y position
  10924. * @param viewportWidth viewport width
  10925. * @param viewportHeight viewport height
  10926. * @param world world matrix
  10927. * @param view view matrix
  10928. * @param projection projection matrix
  10929. * @returns this ray updated
  10930. */
  10931. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10932. /**
  10933. * Creates a ray with origin and direction of 0,0,0
  10934. * @returns the new ray
  10935. */
  10936. static Zero(): Ray;
  10937. /**
  10938. * Creates a new ray from screen space and viewport
  10939. * @param x position
  10940. * @param y y position
  10941. * @param viewportWidth viewport width
  10942. * @param viewportHeight viewport height
  10943. * @param world world matrix
  10944. * @param view view matrix
  10945. * @param projection projection matrix
  10946. * @returns new ray
  10947. */
  10948. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10949. /**
  10950. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  10951. * transformed to the given world matrix.
  10952. * @param origin The origin point
  10953. * @param end The end point
  10954. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10955. * @returns the new ray
  10956. */
  10957. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10958. /**
  10959. * Transforms a ray by a matrix
  10960. * @param ray ray to transform
  10961. * @param matrix matrix to apply
  10962. * @returns the resulting new ray
  10963. */
  10964. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10965. /**
  10966. * Transforms a ray by a matrix
  10967. * @param ray ray to transform
  10968. * @param matrix matrix to apply
  10969. * @param result ray to store result in
  10970. */
  10971. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10972. /**
  10973. * Unproject a ray from screen space to object space
  10974. * @param sourceX defines the screen space x coordinate to use
  10975. * @param sourceY defines the screen space y coordinate to use
  10976. * @param viewportWidth defines the current width of the viewport
  10977. * @param viewportHeight defines the current height of the viewport
  10978. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10979. * @param view defines the view matrix to use
  10980. * @param projection defines the projection matrix to use
  10981. */
  10982. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10983. }
  10984. /**
  10985. * Type used to define predicate used to select faces when a mesh intersection is detected
  10986. */
  10987. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10988. interface Scene {
  10989. /** @hidden */
  10990. _tempPickingRay: Nullable<Ray>;
  10991. /** @hidden */
  10992. _cachedRayForTransform: Ray;
  10993. /** @hidden */
  10994. _pickWithRayInverseMatrix: Matrix;
  10995. /** @hidden */
  10996. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10997. /** @hidden */
  10998. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10999. /** @hidden */
  11000. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11001. }
  11002. }
  11003. declare module BABYLON {
  11004. /**
  11005. * Groups all the scene component constants in one place to ease maintenance.
  11006. * @hidden
  11007. */
  11008. export class SceneComponentConstants {
  11009. static readonly NAME_EFFECTLAYER: string;
  11010. static readonly NAME_LAYER: string;
  11011. static readonly NAME_LENSFLARESYSTEM: string;
  11012. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11013. static readonly NAME_PARTICLESYSTEM: string;
  11014. static readonly NAME_GAMEPAD: string;
  11015. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11016. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11017. static readonly NAME_PREPASSRENDERER: string;
  11018. static readonly NAME_DEPTHRENDERER: string;
  11019. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11020. static readonly NAME_SPRITE: string;
  11021. static readonly NAME_SUBSURFACE: string;
  11022. static readonly NAME_OUTLINERENDERER: string;
  11023. static readonly NAME_PROCEDURALTEXTURE: string;
  11024. static readonly NAME_SHADOWGENERATOR: string;
  11025. static readonly NAME_OCTREE: string;
  11026. static readonly NAME_PHYSICSENGINE: string;
  11027. static readonly NAME_AUDIO: string;
  11028. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11029. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11030. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11031. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11032. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11033. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11034. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11035. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11036. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11037. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11038. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11039. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11040. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11041. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11042. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11043. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11044. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11045. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11046. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11047. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11048. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11049. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11050. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11051. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11052. static readonly STEP_AFTERRENDER_AUDIO: number;
  11053. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11054. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11055. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11056. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11057. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11058. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11059. static readonly STEP_POINTERMOVE_SPRITE: number;
  11060. static readonly STEP_POINTERDOWN_SPRITE: number;
  11061. static readonly STEP_POINTERUP_SPRITE: number;
  11062. }
  11063. /**
  11064. * This represents a scene component.
  11065. *
  11066. * This is used to decouple the dependency the scene is having on the different workloads like
  11067. * layers, post processes...
  11068. */
  11069. export interface ISceneComponent {
  11070. /**
  11071. * The name of the component. Each component must have a unique name.
  11072. */
  11073. name: string;
  11074. /**
  11075. * The scene the component belongs to.
  11076. */
  11077. scene: Scene;
  11078. /**
  11079. * Register the component to one instance of a scene.
  11080. */
  11081. register(): void;
  11082. /**
  11083. * Rebuilds the elements related to this component in case of
  11084. * context lost for instance.
  11085. */
  11086. rebuild(): void;
  11087. /**
  11088. * Disposes the component and the associated ressources.
  11089. */
  11090. dispose(): void;
  11091. }
  11092. /**
  11093. * This represents a SERIALIZABLE scene component.
  11094. *
  11095. * This extends Scene Component to add Serialization methods on top.
  11096. */
  11097. export interface ISceneSerializableComponent extends ISceneComponent {
  11098. /**
  11099. * Adds all the elements from the container to the scene
  11100. * @param container the container holding the elements
  11101. */
  11102. addFromContainer(container: AbstractScene): void;
  11103. /**
  11104. * Removes all the elements in the container from the scene
  11105. * @param container contains the elements to remove
  11106. * @param dispose if the removed element should be disposed (default: false)
  11107. */
  11108. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11109. /**
  11110. * Serializes the component data to the specified json object
  11111. * @param serializationObject The object to serialize to
  11112. */
  11113. serialize(serializationObject: any): void;
  11114. }
  11115. /**
  11116. * Strong typing of a Mesh related stage step action
  11117. */
  11118. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11119. /**
  11120. * Strong typing of a Evaluate Sub Mesh related stage step action
  11121. */
  11122. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11123. /**
  11124. * Strong typing of a pre active Mesh related stage step action
  11125. */
  11126. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11127. /**
  11128. * Strong typing of a Camera related stage step action
  11129. */
  11130. export type CameraStageAction = (camera: Camera) => void;
  11131. /**
  11132. * Strong typing of a Camera Frame buffer related stage step action
  11133. */
  11134. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11135. /**
  11136. * Strong typing of a Render Target related stage step action
  11137. */
  11138. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11139. /**
  11140. * Strong typing of a RenderingGroup related stage step action
  11141. */
  11142. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11143. /**
  11144. * Strong typing of a Mesh Render related stage step action
  11145. */
  11146. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11147. /**
  11148. * Strong typing of a simple stage step action
  11149. */
  11150. export type SimpleStageAction = () => void;
  11151. /**
  11152. * Strong typing of a render target action.
  11153. */
  11154. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11155. /**
  11156. * Strong typing of a pointer move action.
  11157. */
  11158. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11159. /**
  11160. * Strong typing of a pointer up/down action.
  11161. */
  11162. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11163. /**
  11164. * Representation of a stage in the scene (Basically a list of ordered steps)
  11165. * @hidden
  11166. */
  11167. export class Stage<T extends Function> extends Array<{
  11168. index: number;
  11169. component: ISceneComponent;
  11170. action: T;
  11171. }> {
  11172. /**
  11173. * Hide ctor from the rest of the world.
  11174. * @param items The items to add.
  11175. */
  11176. private constructor();
  11177. /**
  11178. * Creates a new Stage.
  11179. * @returns A new instance of a Stage
  11180. */
  11181. static Create<T extends Function>(): Stage<T>;
  11182. /**
  11183. * Registers a step in an ordered way in the targeted stage.
  11184. * @param index Defines the position to register the step in
  11185. * @param component Defines the component attached to the step
  11186. * @param action Defines the action to launch during the step
  11187. */
  11188. registerStep(index: number, component: ISceneComponent, action: T): void;
  11189. /**
  11190. * Clears all the steps from the stage.
  11191. */
  11192. clear(): void;
  11193. }
  11194. }
  11195. declare module BABYLON {
  11196. interface Scene {
  11197. /** @hidden */
  11198. _pointerOverSprite: Nullable<Sprite>;
  11199. /** @hidden */
  11200. _pickedDownSprite: Nullable<Sprite>;
  11201. /** @hidden */
  11202. _tempSpritePickingRay: Nullable<Ray>;
  11203. /**
  11204. * All of the sprite managers added to this scene
  11205. * @see https://doc.babylonjs.com/babylon101/sprites
  11206. */
  11207. spriteManagers: Array<ISpriteManager>;
  11208. /**
  11209. * An event triggered when sprites rendering is about to start
  11210. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11211. */
  11212. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11213. /**
  11214. * An event triggered when sprites rendering is done
  11215. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11216. */
  11217. onAfterSpritesRenderingObservable: Observable<Scene>;
  11218. /** @hidden */
  11219. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11220. /** Launch a ray to try to pick a sprite in the scene
  11221. * @param x position on screen
  11222. * @param y position on screen
  11223. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11224. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11225. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11226. * @returns a PickingInfo
  11227. */
  11228. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11229. /** Use the given ray to pick a sprite in the scene
  11230. * @param ray The ray (in world space) to use to pick meshes
  11231. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11232. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11233. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11234. * @returns a PickingInfo
  11235. */
  11236. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11237. /** @hidden */
  11238. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11239. /** Launch a ray to try to pick sprites in the scene
  11240. * @param x position on screen
  11241. * @param y position on screen
  11242. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11243. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11244. * @returns a PickingInfo array
  11245. */
  11246. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11247. /** Use the given ray to pick sprites in the scene
  11248. * @param ray The ray (in world space) to use to pick meshes
  11249. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11250. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11251. * @returns a PickingInfo array
  11252. */
  11253. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11254. /**
  11255. * Force the sprite under the pointer
  11256. * @param sprite defines the sprite to use
  11257. */
  11258. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11259. /**
  11260. * Gets the sprite under the pointer
  11261. * @returns a Sprite or null if no sprite is under the pointer
  11262. */
  11263. getPointerOverSprite(): Nullable<Sprite>;
  11264. }
  11265. /**
  11266. * Defines the sprite scene component responsible to manage sprites
  11267. * in a given scene.
  11268. */
  11269. export class SpriteSceneComponent implements ISceneComponent {
  11270. /**
  11271. * The component name helpfull to identify the component in the list of scene components.
  11272. */
  11273. readonly name: string;
  11274. /**
  11275. * The scene the component belongs to.
  11276. */
  11277. scene: Scene;
  11278. /** @hidden */
  11279. private _spritePredicate;
  11280. /**
  11281. * Creates a new instance of the component for the given scene
  11282. * @param scene Defines the scene to register the component in
  11283. */
  11284. constructor(scene: Scene);
  11285. /**
  11286. * Registers the component in a given scene
  11287. */
  11288. register(): void;
  11289. /**
  11290. * Rebuilds the elements related to this component in case of
  11291. * context lost for instance.
  11292. */
  11293. rebuild(): void;
  11294. /**
  11295. * Disposes the component and the associated ressources.
  11296. */
  11297. dispose(): void;
  11298. private _pickSpriteButKeepRay;
  11299. private _pointerMove;
  11300. private _pointerDown;
  11301. private _pointerUp;
  11302. }
  11303. }
  11304. declare module BABYLON {
  11305. /**
  11306. * Class used to provide helper for timing
  11307. */
  11308. export class TimingTools {
  11309. /**
  11310. * Polyfill for setImmediate
  11311. * @param action defines the action to execute after the current execution block
  11312. */
  11313. static SetImmediate(action: () => void): void;
  11314. }
  11315. }
  11316. declare module BABYLON {
  11317. /**
  11318. * Class used to enable instatition of objects by class name
  11319. */
  11320. export class InstantiationTools {
  11321. /**
  11322. * Use this object to register external classes like custom textures or material
  11323. * to allow the laoders to instantiate them
  11324. */
  11325. static RegisteredExternalClasses: {
  11326. [key: string]: Object;
  11327. };
  11328. /**
  11329. * Tries to instantiate a new object from a given class name
  11330. * @param className defines the class name to instantiate
  11331. * @returns the new object or null if the system was not able to do the instantiation
  11332. */
  11333. static Instantiate(className: string): any;
  11334. }
  11335. }
  11336. declare module BABYLON {
  11337. /**
  11338. * Class used to host copy specific utilities
  11339. */
  11340. export class CopyTools {
  11341. /**
  11342. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11343. * @param texture defines the texture to read pixels from
  11344. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11345. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11346. * @returns The base64 encoded string or null
  11347. */
  11348. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11349. }
  11350. }
  11351. declare module BABYLON {
  11352. /**
  11353. * Define options used to create a depth texture
  11354. */
  11355. export class DepthTextureCreationOptions {
  11356. /** Specifies whether or not a stencil should be allocated in the texture */
  11357. generateStencil?: boolean;
  11358. /** Specifies whether or not bilinear filtering is enable on the texture */
  11359. bilinearFiltering?: boolean;
  11360. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11361. comparisonFunction?: number;
  11362. /** Specifies if the created texture is a cube texture */
  11363. isCube?: boolean;
  11364. /** Specifies the sample count of the depth/stencil texture texture */
  11365. samples?: number;
  11366. }
  11367. }
  11368. declare module BABYLON {
  11369. interface ThinEngine {
  11370. /**
  11371. * Creates a depth stencil cube texture.
  11372. * This is only available in WebGL 2.
  11373. * @param size The size of face edge in the cube texture.
  11374. * @param options The options defining the cube texture.
  11375. * @returns The cube texture
  11376. */
  11377. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11378. /**
  11379. * Creates a cube texture
  11380. * @param rootUrl defines the url where the files to load is located
  11381. * @param scene defines the current scene
  11382. * @param files defines the list of files to load (1 per face)
  11383. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11384. * @param onLoad defines an optional callback raised when the texture is loaded
  11385. * @param onError defines an optional callback raised if there is an issue to load the texture
  11386. * @param format defines the format of the data
  11387. * @param forcedExtension defines the extension to use to pick the right loader
  11388. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11389. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11390. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11391. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11392. * @param loaderOptions options to be passed to the loader
  11393. * @returns the cube texture as an InternalTexture
  11394. */
  11395. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, loaderOptions: any): InternalTexture;
  11396. /**
  11397. * Creates a cube texture
  11398. * @param rootUrl defines the url where the files to load is located
  11399. * @param scene defines the current scene
  11400. * @param files defines the list of files to load (1 per face)
  11401. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11402. * @param onLoad defines an optional callback raised when the texture is loaded
  11403. * @param onError defines an optional callback raised if there is an issue to load the texture
  11404. * @param format defines the format of the data
  11405. * @param forcedExtension defines the extension to use to pick the right loader
  11406. * @returns the cube texture as an InternalTexture
  11407. */
  11408. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  11409. /**
  11410. * Creates a cube texture
  11411. * @param rootUrl defines the url where the files to load is located
  11412. * @param scene defines the current scene
  11413. * @param files defines the list of files to load (1 per face)
  11414. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11415. * @param onLoad defines an optional callback raised when the texture is loaded
  11416. * @param onError defines an optional callback raised if there is an issue to load the texture
  11417. * @param format defines the format of the data
  11418. * @param forcedExtension defines the extension to use to pick the right loader
  11419. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11420. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11421. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11422. * @returns the cube texture as an InternalTexture
  11423. */
  11424. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  11425. /** @hidden */
  11426. createCubeTextureBase(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, beforeLoadCubeDataCallback: Nullable<(texture: InternalTexture, data: ArrayBufferView | ArrayBufferView[]) => void>, imageHandler: Nullable<(texture: InternalTexture, imgs: HTMLImageElement[] | ImageBitmap[]) => void>): InternalTexture;
  11427. /** @hidden */
  11428. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11429. /** @hidden */
  11430. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11431. /** @hidden */
  11432. _cascadeLoadImgs(scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11433. /** @hidden */
  11434. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[] | ImageBitmap[], scene: Nullable<Scene>, texture: InternalTexture, onfinish: Nullable<(texture: InternalTexture, images: HTMLImageElement[] | ImageBitmap[]) => void>, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  11435. /**
  11436. * @hidden
  11437. */
  11438. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11439. }
  11440. }
  11441. declare module BABYLON {
  11442. /**
  11443. * Class for creating a cube texture
  11444. */
  11445. export class CubeTexture extends BaseTexture {
  11446. private _delayedOnLoad;
  11447. /**
  11448. * Observable triggered once the texture has been loaded.
  11449. */
  11450. onLoadObservable: Observable<CubeTexture>;
  11451. /**
  11452. * The url of the texture
  11453. */
  11454. url: string;
  11455. /**
  11456. * Gets or sets the center of the bounding box associated with the cube texture.
  11457. * It must define where the camera used to render the texture was set
  11458. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11459. */
  11460. boundingBoxPosition: Vector3;
  11461. private _boundingBoxSize;
  11462. /**
  11463. * Gets or sets the size of the bounding box associated with the cube texture
  11464. * When defined, the cubemap will switch to local mode
  11465. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11466. * @example https://www.babylonjs-playground.com/#RNASML
  11467. */
  11468. set boundingBoxSize(value: Vector3);
  11469. /**
  11470. * Returns the bounding box size
  11471. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11472. */
  11473. get boundingBoxSize(): Vector3;
  11474. protected _rotationY: number;
  11475. /**
  11476. * Sets texture matrix rotation angle around Y axis in radians.
  11477. */
  11478. set rotationY(value: number);
  11479. /**
  11480. * Gets texture matrix rotation angle around Y axis radians.
  11481. */
  11482. get rotationY(): number;
  11483. /**
  11484. * Are mip maps generated for this texture or not.
  11485. */
  11486. get noMipmap(): boolean;
  11487. private _noMipmap;
  11488. private _files;
  11489. protected _forcedExtension: Nullable<string>;
  11490. private _extensions;
  11491. private _textureMatrix;
  11492. private _format;
  11493. private _createPolynomials;
  11494. private _loaderOptions;
  11495. /**
  11496. * Creates a cube texture from an array of image urls
  11497. * @param files defines an array of image urls
  11498. * @param scene defines the hosting scene
  11499. * @param noMipmap specifies if mip maps are not used
  11500. * @returns a cube texture
  11501. */
  11502. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11503. /**
  11504. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11505. * @param url defines the url of the prefiltered texture
  11506. * @param scene defines the scene the texture is attached to
  11507. * @param forcedExtension defines the extension of the file if different from the url
  11508. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11509. * @return the prefiltered texture
  11510. */
  11511. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11512. /**
  11513. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11514. * as prefiltered data.
  11515. * @param rootUrl defines the url of the texture or the root name of the six images
  11516. * @param null defines the scene or engine the texture is attached to
  11517. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11518. * @param noMipmap defines if mipmaps should be created or not
  11519. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11520. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11521. * @param onError defines a callback triggered in case of error during load
  11522. * @param format defines the internal format to use for the texture once loaded
  11523. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11524. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11525. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11526. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11527. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11528. * @param loaderOptions options to be passed to the loader
  11529. * @return the cube texture
  11530. */
  11531. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, loaderOptions?: any);
  11532. /**
  11533. * Get the current class name of the texture useful for serialization or dynamic coding.
  11534. * @returns "CubeTexture"
  11535. */
  11536. getClassName(): string;
  11537. /**
  11538. * Update the url (and optional buffer) of this texture if url was null during construction.
  11539. * @param url the url of the texture
  11540. * @param forcedExtension defines the extension to use
  11541. * @param onLoad callback called when the texture is loaded (defaults to null)
  11542. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11543. */
  11544. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11545. /**
  11546. * Delays loading of the cube texture
  11547. * @param forcedExtension defines the extension to use
  11548. */
  11549. delayLoad(forcedExtension?: string): void;
  11550. /**
  11551. * Returns the reflection texture matrix
  11552. * @returns the reflection texture matrix
  11553. */
  11554. getReflectionTextureMatrix(): Matrix;
  11555. /**
  11556. * Sets the reflection texture matrix
  11557. * @param value Reflection texture matrix
  11558. */
  11559. setReflectionTextureMatrix(value: Matrix): void;
  11560. /**
  11561. * Parses text to create a cube texture
  11562. * @param parsedTexture define the serialized text to read from
  11563. * @param scene defines the hosting scene
  11564. * @param rootUrl defines the root url of the cube texture
  11565. * @returns a cube texture
  11566. */
  11567. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11568. /**
  11569. * Makes a clone, or deep copy, of the cube texture
  11570. * @returns a new cube texture
  11571. */
  11572. clone(): CubeTexture;
  11573. }
  11574. }
  11575. declare module BABYLON {
  11576. /**
  11577. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11578. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11579. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  11580. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11581. */
  11582. export class ColorCurves {
  11583. private _dirty;
  11584. private _tempColor;
  11585. private _globalCurve;
  11586. private _highlightsCurve;
  11587. private _midtonesCurve;
  11588. private _shadowsCurve;
  11589. private _positiveCurve;
  11590. private _negativeCurve;
  11591. private _globalHue;
  11592. private _globalDensity;
  11593. private _globalSaturation;
  11594. private _globalExposure;
  11595. /**
  11596. * Gets the global Hue value.
  11597. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11598. */
  11599. get globalHue(): number;
  11600. /**
  11601. * Sets the global Hue value.
  11602. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11603. */
  11604. set globalHue(value: number);
  11605. /**
  11606. * Gets the global Density value.
  11607. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11608. * Values less than zero provide a filter of opposite hue.
  11609. */
  11610. get globalDensity(): number;
  11611. /**
  11612. * Sets the global Density value.
  11613. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11614. * Values less than zero provide a filter of opposite hue.
  11615. */
  11616. set globalDensity(value: number);
  11617. /**
  11618. * Gets the global Saturation value.
  11619. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11620. */
  11621. get globalSaturation(): number;
  11622. /**
  11623. * Sets the global Saturation value.
  11624. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11625. */
  11626. set globalSaturation(value: number);
  11627. /**
  11628. * Gets the global Exposure value.
  11629. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11630. */
  11631. get globalExposure(): number;
  11632. /**
  11633. * Sets the global Exposure value.
  11634. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11635. */
  11636. set globalExposure(value: number);
  11637. private _highlightsHue;
  11638. private _highlightsDensity;
  11639. private _highlightsSaturation;
  11640. private _highlightsExposure;
  11641. /**
  11642. * Gets the highlights Hue value.
  11643. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11644. */
  11645. get highlightsHue(): number;
  11646. /**
  11647. * Sets the highlights Hue value.
  11648. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11649. */
  11650. set highlightsHue(value: number);
  11651. /**
  11652. * Gets the highlights Density value.
  11653. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11654. * Values less than zero provide a filter of opposite hue.
  11655. */
  11656. get highlightsDensity(): number;
  11657. /**
  11658. * Sets the highlights Density value.
  11659. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11660. * Values less than zero provide a filter of opposite hue.
  11661. */
  11662. set highlightsDensity(value: number);
  11663. /**
  11664. * Gets the highlights Saturation value.
  11665. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11666. */
  11667. get highlightsSaturation(): number;
  11668. /**
  11669. * Sets the highlights Saturation value.
  11670. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11671. */
  11672. set highlightsSaturation(value: number);
  11673. /**
  11674. * Gets the highlights Exposure value.
  11675. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11676. */
  11677. get highlightsExposure(): number;
  11678. /**
  11679. * Sets the highlights Exposure value.
  11680. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11681. */
  11682. set highlightsExposure(value: number);
  11683. private _midtonesHue;
  11684. private _midtonesDensity;
  11685. private _midtonesSaturation;
  11686. private _midtonesExposure;
  11687. /**
  11688. * Gets the midtones Hue value.
  11689. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11690. */
  11691. get midtonesHue(): number;
  11692. /**
  11693. * Sets the midtones Hue value.
  11694. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11695. */
  11696. set midtonesHue(value: number);
  11697. /**
  11698. * Gets the midtones Density value.
  11699. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11700. * Values less than zero provide a filter of opposite hue.
  11701. */
  11702. get midtonesDensity(): number;
  11703. /**
  11704. * Sets the midtones Density value.
  11705. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11706. * Values less than zero provide a filter of opposite hue.
  11707. */
  11708. set midtonesDensity(value: number);
  11709. /**
  11710. * Gets the midtones Saturation value.
  11711. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11712. */
  11713. get midtonesSaturation(): number;
  11714. /**
  11715. * Sets the midtones Saturation value.
  11716. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11717. */
  11718. set midtonesSaturation(value: number);
  11719. /**
  11720. * Gets the midtones Exposure value.
  11721. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11722. */
  11723. get midtonesExposure(): number;
  11724. /**
  11725. * Sets the midtones Exposure value.
  11726. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11727. */
  11728. set midtonesExposure(value: number);
  11729. private _shadowsHue;
  11730. private _shadowsDensity;
  11731. private _shadowsSaturation;
  11732. private _shadowsExposure;
  11733. /**
  11734. * Gets the shadows Hue value.
  11735. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11736. */
  11737. get shadowsHue(): number;
  11738. /**
  11739. * Sets the shadows Hue value.
  11740. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  11741. */
  11742. set shadowsHue(value: number);
  11743. /**
  11744. * Gets the shadows Density value.
  11745. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11746. * Values less than zero provide a filter of opposite hue.
  11747. */
  11748. get shadowsDensity(): number;
  11749. /**
  11750. * Sets the shadows Density value.
  11751. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  11752. * Values less than zero provide a filter of opposite hue.
  11753. */
  11754. set shadowsDensity(value: number);
  11755. /**
  11756. * Gets the shadows Saturation value.
  11757. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11758. */
  11759. get shadowsSaturation(): number;
  11760. /**
  11761. * Sets the shadows Saturation value.
  11762. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  11763. */
  11764. set shadowsSaturation(value: number);
  11765. /**
  11766. * Gets the shadows Exposure value.
  11767. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11768. */
  11769. get shadowsExposure(): number;
  11770. /**
  11771. * Sets the shadows Exposure value.
  11772. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  11773. */
  11774. set shadowsExposure(value: number);
  11775. /**
  11776. * Returns the class name
  11777. * @returns The class name
  11778. */
  11779. getClassName(): string;
  11780. /**
  11781. * Binds the color curves to the shader.
  11782. * @param colorCurves The color curve to bind
  11783. * @param effect The effect to bind to
  11784. * @param positiveUniform The positive uniform shader parameter
  11785. * @param neutralUniform The neutral uniform shader parameter
  11786. * @param negativeUniform The negative uniform shader parameter
  11787. */
  11788. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11789. /**
  11790. * Prepare the list of uniforms associated with the ColorCurves effects.
  11791. * @param uniformsList The list of uniforms used in the effect
  11792. */
  11793. static PrepareUniforms(uniformsList: string[]): void;
  11794. /**
  11795. * Returns color grading data based on a hue, density, saturation and exposure value.
  11796. * @param filterHue The hue of the color filter.
  11797. * @param filterDensity The density of the color filter.
  11798. * @param saturation The saturation.
  11799. * @param exposure The exposure.
  11800. * @param result The result data container.
  11801. */
  11802. private getColorGradingDataToRef;
  11803. /**
  11804. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11805. * @param value The input slider value in range [-100,100].
  11806. * @returns Adjusted value.
  11807. */
  11808. private static applyColorGradingSliderNonlinear;
  11809. /**
  11810. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11811. * @param hue The hue (H) input.
  11812. * @param saturation The saturation (S) input.
  11813. * @param brightness The brightness (B) input.
  11814. * @result An RGBA color represented as Vector4.
  11815. */
  11816. private static fromHSBToRef;
  11817. /**
  11818. * Returns a value clamped between min and max
  11819. * @param value The value to clamp
  11820. * @param min The minimum of value
  11821. * @param max The maximum of value
  11822. * @returns The clamped value.
  11823. */
  11824. private static clamp;
  11825. /**
  11826. * Clones the current color curve instance.
  11827. * @return The cloned curves
  11828. */
  11829. clone(): ColorCurves;
  11830. /**
  11831. * Serializes the current color curve instance to a json representation.
  11832. * @return a JSON representation
  11833. */
  11834. serialize(): any;
  11835. /**
  11836. * Parses the color curve from a json representation.
  11837. * @param source the JSON source to parse
  11838. * @return The parsed curves
  11839. */
  11840. static Parse(source: any): ColorCurves;
  11841. }
  11842. }
  11843. declare module BABYLON {
  11844. /**
  11845. * Interface to follow in your material defines to integrate easily the
  11846. * Image proccessing functions.
  11847. * @hidden
  11848. */
  11849. export interface IImageProcessingConfigurationDefines {
  11850. IMAGEPROCESSING: boolean;
  11851. VIGNETTE: boolean;
  11852. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11853. VIGNETTEBLENDMODEOPAQUE: boolean;
  11854. TONEMAPPING: boolean;
  11855. TONEMAPPING_ACES: boolean;
  11856. CONTRAST: boolean;
  11857. EXPOSURE: boolean;
  11858. COLORCURVES: boolean;
  11859. COLORGRADING: boolean;
  11860. COLORGRADING3D: boolean;
  11861. SAMPLER3DGREENDEPTH: boolean;
  11862. SAMPLER3DBGRMAP: boolean;
  11863. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11864. }
  11865. /**
  11866. * @hidden
  11867. */
  11868. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11869. IMAGEPROCESSING: boolean;
  11870. VIGNETTE: boolean;
  11871. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11872. VIGNETTEBLENDMODEOPAQUE: boolean;
  11873. TONEMAPPING: boolean;
  11874. TONEMAPPING_ACES: boolean;
  11875. CONTRAST: boolean;
  11876. COLORCURVES: boolean;
  11877. COLORGRADING: boolean;
  11878. COLORGRADING3D: boolean;
  11879. SAMPLER3DGREENDEPTH: boolean;
  11880. SAMPLER3DBGRMAP: boolean;
  11881. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11882. EXPOSURE: boolean;
  11883. constructor();
  11884. }
  11885. /**
  11886. * This groups together the common properties used for image processing either in direct forward pass
  11887. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11888. * or not.
  11889. */
  11890. export class ImageProcessingConfiguration {
  11891. /**
  11892. * Default tone mapping applied in BabylonJS.
  11893. */
  11894. static readonly TONEMAPPING_STANDARD: number;
  11895. /**
  11896. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11897. * to other engines rendering to increase portability.
  11898. */
  11899. static readonly TONEMAPPING_ACES: number;
  11900. /**
  11901. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11902. */
  11903. colorCurves: Nullable<ColorCurves>;
  11904. private _colorCurvesEnabled;
  11905. /**
  11906. * Gets wether the color curves effect is enabled.
  11907. */
  11908. get colorCurvesEnabled(): boolean;
  11909. /**
  11910. * Sets wether the color curves effect is enabled.
  11911. */
  11912. set colorCurvesEnabled(value: boolean);
  11913. private _colorGradingTexture;
  11914. /**
  11915. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11916. */
  11917. get colorGradingTexture(): Nullable<BaseTexture>;
  11918. /**
  11919. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11920. */
  11921. set colorGradingTexture(value: Nullable<BaseTexture>);
  11922. private _colorGradingEnabled;
  11923. /**
  11924. * Gets wether the color grading effect is enabled.
  11925. */
  11926. get colorGradingEnabled(): boolean;
  11927. /**
  11928. * Sets wether the color grading effect is enabled.
  11929. */
  11930. set colorGradingEnabled(value: boolean);
  11931. private _colorGradingWithGreenDepth;
  11932. /**
  11933. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11934. */
  11935. get colorGradingWithGreenDepth(): boolean;
  11936. /**
  11937. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11938. */
  11939. set colorGradingWithGreenDepth(value: boolean);
  11940. private _colorGradingBGR;
  11941. /**
  11942. * Gets wether the color grading texture contains BGR values.
  11943. */
  11944. get colorGradingBGR(): boolean;
  11945. /**
  11946. * Sets wether the color grading texture contains BGR values.
  11947. */
  11948. set colorGradingBGR(value: boolean);
  11949. /** @hidden */
  11950. _exposure: number;
  11951. /**
  11952. * Gets the Exposure used in the effect.
  11953. */
  11954. get exposure(): number;
  11955. /**
  11956. * Sets the Exposure used in the effect.
  11957. */
  11958. set exposure(value: number);
  11959. private _toneMappingEnabled;
  11960. /**
  11961. * Gets wether the tone mapping effect is enabled.
  11962. */
  11963. get toneMappingEnabled(): boolean;
  11964. /**
  11965. * Sets wether the tone mapping effect is enabled.
  11966. */
  11967. set toneMappingEnabled(value: boolean);
  11968. private _toneMappingType;
  11969. /**
  11970. * Gets the type of tone mapping effect.
  11971. */
  11972. get toneMappingType(): number;
  11973. /**
  11974. * Sets the type of tone mapping effect used in BabylonJS.
  11975. */
  11976. set toneMappingType(value: number);
  11977. protected _contrast: number;
  11978. /**
  11979. * Gets the contrast used in the effect.
  11980. */
  11981. get contrast(): number;
  11982. /**
  11983. * Sets the contrast used in the effect.
  11984. */
  11985. set contrast(value: number);
  11986. /**
  11987. * Vignette stretch size.
  11988. */
  11989. vignetteStretch: number;
  11990. /**
  11991. * Vignette centre X Offset.
  11992. */
  11993. vignetteCentreX: number;
  11994. /**
  11995. * Vignette centre Y Offset.
  11996. */
  11997. vignetteCentreY: number;
  11998. /**
  11999. * Vignette weight or intensity of the vignette effect.
  12000. */
  12001. vignetteWeight: number;
  12002. /**
  12003. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12004. * if vignetteEnabled is set to true.
  12005. */
  12006. vignetteColor: Color4;
  12007. /**
  12008. * Camera field of view used by the Vignette effect.
  12009. */
  12010. vignetteCameraFov: number;
  12011. private _vignetteBlendMode;
  12012. /**
  12013. * Gets the vignette blend mode allowing different kind of effect.
  12014. */
  12015. get vignetteBlendMode(): number;
  12016. /**
  12017. * Sets the vignette blend mode allowing different kind of effect.
  12018. */
  12019. set vignetteBlendMode(value: number);
  12020. private _vignetteEnabled;
  12021. /**
  12022. * Gets wether the vignette effect is enabled.
  12023. */
  12024. get vignetteEnabled(): boolean;
  12025. /**
  12026. * Sets wether the vignette effect is enabled.
  12027. */
  12028. set vignetteEnabled(value: boolean);
  12029. private _applyByPostProcess;
  12030. /**
  12031. * Gets wether the image processing is applied through a post process or not.
  12032. */
  12033. get applyByPostProcess(): boolean;
  12034. /**
  12035. * Sets wether the image processing is applied through a post process or not.
  12036. */
  12037. set applyByPostProcess(value: boolean);
  12038. private _isEnabled;
  12039. /**
  12040. * Gets wether the image processing is enabled or not.
  12041. */
  12042. get isEnabled(): boolean;
  12043. /**
  12044. * Sets wether the image processing is enabled or not.
  12045. */
  12046. set isEnabled(value: boolean);
  12047. /**
  12048. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12049. */
  12050. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12051. /**
  12052. * Method called each time the image processing information changes requires to recompile the effect.
  12053. */
  12054. protected _updateParameters(): void;
  12055. /**
  12056. * Gets the current class name.
  12057. * @return "ImageProcessingConfiguration"
  12058. */
  12059. getClassName(): string;
  12060. /**
  12061. * Prepare the list of uniforms associated with the Image Processing effects.
  12062. * @param uniforms The list of uniforms used in the effect
  12063. * @param defines the list of defines currently in use
  12064. */
  12065. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12066. /**
  12067. * Prepare the list of samplers associated with the Image Processing effects.
  12068. * @param samplersList The list of uniforms used in the effect
  12069. * @param defines the list of defines currently in use
  12070. */
  12071. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12072. /**
  12073. * Prepare the list of defines associated to the shader.
  12074. * @param defines the list of defines to complete
  12075. * @param forPostProcess Define if we are currently in post process mode or not
  12076. */
  12077. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12078. /**
  12079. * Returns true if all the image processing information are ready.
  12080. * @returns True if ready, otherwise, false
  12081. */
  12082. isReady(): boolean;
  12083. /**
  12084. * Binds the image processing to the shader.
  12085. * @param effect The effect to bind to
  12086. * @param overrideAspectRatio Override the aspect ratio of the effect
  12087. */
  12088. bind(effect: Effect, overrideAspectRatio?: number): void;
  12089. /**
  12090. * Clones the current image processing instance.
  12091. * @return The cloned image processing
  12092. */
  12093. clone(): ImageProcessingConfiguration;
  12094. /**
  12095. * Serializes the current image processing instance to a json representation.
  12096. * @return a JSON representation
  12097. */
  12098. serialize(): any;
  12099. /**
  12100. * Parses the image processing from a json representation.
  12101. * @param source the JSON source to parse
  12102. * @return The parsed image processing
  12103. */
  12104. static Parse(source: any): ImageProcessingConfiguration;
  12105. private static _VIGNETTEMODE_MULTIPLY;
  12106. private static _VIGNETTEMODE_OPAQUE;
  12107. /**
  12108. * Used to apply the vignette as a mix with the pixel color.
  12109. */
  12110. static get VIGNETTEMODE_MULTIPLY(): number;
  12111. /**
  12112. * Used to apply the vignette as a replacement of the pixel color.
  12113. */
  12114. static get VIGNETTEMODE_OPAQUE(): number;
  12115. }
  12116. }
  12117. declare module BABYLON {
  12118. /** @hidden */
  12119. export var postprocessVertexShader: {
  12120. name: string;
  12121. shader: string;
  12122. };
  12123. }
  12124. declare module BABYLON {
  12125. /**
  12126. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12127. */
  12128. export type RenderTargetTextureSize = number | {
  12129. width: number;
  12130. height: number;
  12131. layers?: number;
  12132. };
  12133. interface ThinEngine {
  12134. /**
  12135. * Creates a new render target texture
  12136. * @param size defines the size of the texture
  12137. * @param options defines the options used to create the texture
  12138. * @returns a new render target texture stored in an InternalTexture
  12139. */
  12140. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12141. /**
  12142. * Creates a depth stencil texture.
  12143. * This is only available in WebGL 2 or with the depth texture extension available.
  12144. * @param size The size of face edge in the texture.
  12145. * @param options The options defining the texture.
  12146. * @returns The texture
  12147. */
  12148. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12149. /** @hidden */
  12150. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12151. }
  12152. }
  12153. declare module BABYLON {
  12154. /**
  12155. * Defines the kind of connection point for node based material
  12156. */
  12157. export enum NodeMaterialBlockConnectionPointTypes {
  12158. /** Float */
  12159. Float = 1,
  12160. /** Int */
  12161. Int = 2,
  12162. /** Vector2 */
  12163. Vector2 = 4,
  12164. /** Vector3 */
  12165. Vector3 = 8,
  12166. /** Vector4 */
  12167. Vector4 = 16,
  12168. /** Color3 */
  12169. Color3 = 32,
  12170. /** Color4 */
  12171. Color4 = 64,
  12172. /** Matrix */
  12173. Matrix = 128,
  12174. /** Custom object */
  12175. Object = 256,
  12176. /** Detect type based on connection */
  12177. AutoDetect = 1024,
  12178. /** Output type that will be defined by input type */
  12179. BasedOnInput = 2048
  12180. }
  12181. }
  12182. declare module BABYLON {
  12183. /**
  12184. * Enum used to define the target of a block
  12185. */
  12186. export enum NodeMaterialBlockTargets {
  12187. /** Vertex shader */
  12188. Vertex = 1,
  12189. /** Fragment shader */
  12190. Fragment = 2,
  12191. /** Neutral */
  12192. Neutral = 4,
  12193. /** Vertex and Fragment */
  12194. VertexAndFragment = 3
  12195. }
  12196. }
  12197. declare module BABYLON {
  12198. /**
  12199. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12200. */
  12201. export enum NodeMaterialBlockConnectionPointMode {
  12202. /** Value is an uniform */
  12203. Uniform = 0,
  12204. /** Value is a mesh attribute */
  12205. Attribute = 1,
  12206. /** Value is a varying between vertex and fragment shaders */
  12207. Varying = 2,
  12208. /** Mode is undefined */
  12209. Undefined = 3
  12210. }
  12211. }
  12212. declare module BABYLON {
  12213. /**
  12214. * Enum used to define system values e.g. values automatically provided by the system
  12215. */
  12216. export enum NodeMaterialSystemValues {
  12217. /** World */
  12218. World = 1,
  12219. /** View */
  12220. View = 2,
  12221. /** Projection */
  12222. Projection = 3,
  12223. /** ViewProjection */
  12224. ViewProjection = 4,
  12225. /** WorldView */
  12226. WorldView = 5,
  12227. /** WorldViewProjection */
  12228. WorldViewProjection = 6,
  12229. /** CameraPosition */
  12230. CameraPosition = 7,
  12231. /** Fog Color */
  12232. FogColor = 8,
  12233. /** Delta time */
  12234. DeltaTime = 9
  12235. }
  12236. }
  12237. declare module BABYLON {
  12238. /**
  12239. * Represents a camera frustum
  12240. */
  12241. export class Frustum {
  12242. /**
  12243. * Gets the planes representing the frustum
  12244. * @param transform matrix to be applied to the returned planes
  12245. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12246. */
  12247. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12248. /**
  12249. * Gets the near frustum plane transformed by the transform matrix
  12250. * @param transform transformation matrix to be applied to the resulting frustum plane
  12251. * @param frustumPlane the resuling frustum plane
  12252. */
  12253. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12254. /**
  12255. * Gets the far frustum plane transformed by the transform matrix
  12256. * @param transform transformation matrix to be applied to the resulting frustum plane
  12257. * @param frustumPlane the resuling frustum plane
  12258. */
  12259. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12260. /**
  12261. * Gets the left frustum plane transformed by the transform matrix
  12262. * @param transform transformation matrix to be applied to the resulting frustum plane
  12263. * @param frustumPlane the resuling frustum plane
  12264. */
  12265. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12266. /**
  12267. * Gets the right frustum plane transformed by the transform matrix
  12268. * @param transform transformation matrix to be applied to the resulting frustum plane
  12269. * @param frustumPlane the resuling frustum plane
  12270. */
  12271. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12272. /**
  12273. * Gets the top frustum plane transformed by the transform matrix
  12274. * @param transform transformation matrix to be applied to the resulting frustum plane
  12275. * @param frustumPlane the resuling frustum plane
  12276. */
  12277. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12278. /**
  12279. * Gets the bottom frustum plane transformed by the transform matrix
  12280. * @param transform transformation matrix to be applied to the resulting frustum plane
  12281. * @param frustumPlane the resuling frustum plane
  12282. */
  12283. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12284. /**
  12285. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12286. * @param transform transformation matrix to be applied to the resulting frustum planes
  12287. * @param frustumPlanes the resuling frustum planes
  12288. */
  12289. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12290. }
  12291. }
  12292. declare module BABYLON {
  12293. /**
  12294. * Contains position and normal vectors for a vertex
  12295. */
  12296. export class PositionNormalVertex {
  12297. /** the position of the vertex (defaut: 0,0,0) */
  12298. position: Vector3;
  12299. /** the normal of the vertex (defaut: 0,1,0) */
  12300. normal: Vector3;
  12301. /**
  12302. * Creates a PositionNormalVertex
  12303. * @param position the position of the vertex (defaut: 0,0,0)
  12304. * @param normal the normal of the vertex (defaut: 0,1,0)
  12305. */
  12306. constructor(
  12307. /** the position of the vertex (defaut: 0,0,0) */
  12308. position?: Vector3,
  12309. /** the normal of the vertex (defaut: 0,1,0) */
  12310. normal?: Vector3);
  12311. /**
  12312. * Clones the PositionNormalVertex
  12313. * @returns the cloned PositionNormalVertex
  12314. */
  12315. clone(): PositionNormalVertex;
  12316. }
  12317. /**
  12318. * Contains position, normal and uv vectors for a vertex
  12319. */
  12320. export class PositionNormalTextureVertex {
  12321. /** the position of the vertex (defaut: 0,0,0) */
  12322. position: Vector3;
  12323. /** the normal of the vertex (defaut: 0,1,0) */
  12324. normal: Vector3;
  12325. /** the uv of the vertex (default: 0,0) */
  12326. uv: Vector2;
  12327. /**
  12328. * Creates a PositionNormalTextureVertex
  12329. * @param position the position of the vertex (defaut: 0,0,0)
  12330. * @param normal the normal of the vertex (defaut: 0,1,0)
  12331. * @param uv the uv of the vertex (default: 0,0)
  12332. */
  12333. constructor(
  12334. /** the position of the vertex (defaut: 0,0,0) */
  12335. position?: Vector3,
  12336. /** the normal of the vertex (defaut: 0,1,0) */
  12337. normal?: Vector3,
  12338. /** the uv of the vertex (default: 0,0) */
  12339. uv?: Vector2);
  12340. /**
  12341. * Clones the PositionNormalTextureVertex
  12342. * @returns the cloned PositionNormalTextureVertex
  12343. */
  12344. clone(): PositionNormalTextureVertex;
  12345. }
  12346. }
  12347. declare module BABYLON {
  12348. /**
  12349. * Enum defining the type of animations supported by InputBlock
  12350. */
  12351. export enum AnimatedInputBlockTypes {
  12352. /** No animation */
  12353. None = 0,
  12354. /** Time based animation. Will only work for floats */
  12355. Time = 1
  12356. }
  12357. }
  12358. declare module BABYLON {
  12359. /**
  12360. * Block used to expose an input value
  12361. */
  12362. export class InputBlock extends NodeMaterialBlock {
  12363. private _mode;
  12364. private _associatedVariableName;
  12365. private _storedValue;
  12366. private _valueCallback;
  12367. private _type;
  12368. private _animationType;
  12369. /** Gets or set a value used to limit the range of float values */
  12370. min: number;
  12371. /** Gets or set a value used to limit the range of float values */
  12372. max: number;
  12373. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12374. isBoolean: boolean;
  12375. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12376. matrixMode: number;
  12377. /** @hidden */
  12378. _systemValue: Nullable<NodeMaterialSystemValues>;
  12379. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12380. isConstant: boolean;
  12381. /** Gets or sets the group to use to display this block in the Inspector */
  12382. groupInInspector: string;
  12383. /** Gets an observable raised when the value is changed */
  12384. onValueChangedObservable: Observable<InputBlock>;
  12385. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12386. convertToGammaSpace: boolean;
  12387. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12388. convertToLinearSpace: boolean;
  12389. /**
  12390. * Gets or sets the connection point type (default is float)
  12391. */
  12392. get type(): NodeMaterialBlockConnectionPointTypes;
  12393. /**
  12394. * Creates a new InputBlock
  12395. * @param name defines the block name
  12396. * @param target defines the target of that block (Vertex by default)
  12397. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12398. */
  12399. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12400. /**
  12401. * Validates if a name is a reserve word.
  12402. * @param newName the new name to be given to the node.
  12403. * @returns false if the name is a reserve word, else true.
  12404. */
  12405. validateBlockName(newName: string): boolean;
  12406. /**
  12407. * Gets the output component
  12408. */
  12409. get output(): NodeMaterialConnectionPoint;
  12410. /**
  12411. * Set the source of this connection point to a vertex attribute
  12412. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12413. * @returns the current connection point
  12414. */
  12415. setAsAttribute(attributeName?: string): InputBlock;
  12416. /**
  12417. * Set the source of this connection point to a system value
  12418. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12419. * @returns the current connection point
  12420. */
  12421. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12422. /**
  12423. * Gets or sets the value of that point.
  12424. * Please note that this value will be ignored if valueCallback is defined
  12425. */
  12426. get value(): any;
  12427. set value(value: any);
  12428. /**
  12429. * Gets or sets a callback used to get the value of that point.
  12430. * Please note that setting this value will force the connection point to ignore the value property
  12431. */
  12432. get valueCallback(): () => any;
  12433. set valueCallback(value: () => any);
  12434. /**
  12435. * Gets or sets the associated variable name in the shader
  12436. */
  12437. get associatedVariableName(): string;
  12438. set associatedVariableName(value: string);
  12439. /** Gets or sets the type of animation applied to the input */
  12440. get animationType(): AnimatedInputBlockTypes;
  12441. set animationType(value: AnimatedInputBlockTypes);
  12442. /**
  12443. * Gets a boolean indicating that this connection point not defined yet
  12444. */
  12445. get isUndefined(): boolean;
  12446. /**
  12447. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12448. * In this case the connection point name must be the name of the uniform to use.
  12449. * Can only be set on inputs
  12450. */
  12451. get isUniform(): boolean;
  12452. set isUniform(value: boolean);
  12453. /**
  12454. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12455. * In this case the connection point name must be the name of the attribute to use
  12456. * Can only be set on inputs
  12457. */
  12458. get isAttribute(): boolean;
  12459. set isAttribute(value: boolean);
  12460. /**
  12461. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12462. * Can only be set on exit points
  12463. */
  12464. get isVarying(): boolean;
  12465. set isVarying(value: boolean);
  12466. /**
  12467. * Gets a boolean indicating that the current connection point is a system value
  12468. */
  12469. get isSystemValue(): boolean;
  12470. /**
  12471. * Gets or sets the current well known value or null if not defined as a system value
  12472. */
  12473. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12474. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12475. /**
  12476. * Gets the current class name
  12477. * @returns the class name
  12478. */
  12479. getClassName(): string;
  12480. /**
  12481. * Animate the input if animationType !== None
  12482. * @param scene defines the rendering scene
  12483. */
  12484. animate(scene: Scene): void;
  12485. private _emitDefine;
  12486. initialize(state: NodeMaterialBuildState): void;
  12487. /**
  12488. * Set the input block to its default value (based on its type)
  12489. */
  12490. setDefaultValue(): void;
  12491. private _emitConstant;
  12492. /** @hidden */
  12493. get _noContextSwitch(): boolean;
  12494. private _emit;
  12495. /** @hidden */
  12496. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12497. /** @hidden */
  12498. _transmit(effect: Effect, scene: Scene): void;
  12499. protected _buildBlock(state: NodeMaterialBuildState): void;
  12500. protected _dumpPropertiesCode(): string;
  12501. dispose(): void;
  12502. serialize(): any;
  12503. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12504. }
  12505. }
  12506. declare module BABYLON {
  12507. /**
  12508. * Enum used to define the compatibility state between two connection points
  12509. */
  12510. export enum NodeMaterialConnectionPointCompatibilityStates {
  12511. /** Points are compatibles */
  12512. Compatible = 0,
  12513. /** Points are incompatible because of their types */
  12514. TypeIncompatible = 1,
  12515. /** Points are incompatible because of their targets (vertex vs fragment) */
  12516. TargetIncompatible = 2
  12517. }
  12518. /**
  12519. * Defines the direction of a connection point
  12520. */
  12521. export enum NodeMaterialConnectionPointDirection {
  12522. /** Input */
  12523. Input = 0,
  12524. /** Output */
  12525. Output = 1
  12526. }
  12527. /**
  12528. * Defines a connection point for a block
  12529. */
  12530. export class NodeMaterialConnectionPoint {
  12531. /**
  12532. * Checks if two types are equivalent
  12533. * @param type1 type 1 to check
  12534. * @param type2 type 2 to check
  12535. * @returns true if both types are equivalent, else false
  12536. */
  12537. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12538. /** @hidden */
  12539. _ownerBlock: NodeMaterialBlock;
  12540. /** @hidden */
  12541. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12542. private _endpoints;
  12543. private _associatedVariableName;
  12544. private _direction;
  12545. /** @hidden */
  12546. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12547. /** @hidden */
  12548. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12549. /** @hidden */
  12550. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12551. private _type;
  12552. /** @hidden */
  12553. _enforceAssociatedVariableName: boolean;
  12554. /** Gets the direction of the point */
  12555. get direction(): NodeMaterialConnectionPointDirection;
  12556. /** Indicates that this connection point needs dual validation before being connected to another point */
  12557. needDualDirectionValidation: boolean;
  12558. /**
  12559. * Gets or sets the additional types supported by this connection point
  12560. */
  12561. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12562. /**
  12563. * Gets or sets the additional types excluded by this connection point
  12564. */
  12565. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12566. /**
  12567. * Observable triggered when this point is connected
  12568. */
  12569. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12570. /**
  12571. * Gets or sets the associated variable name in the shader
  12572. */
  12573. get associatedVariableName(): string;
  12574. set associatedVariableName(value: string);
  12575. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12576. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12577. /**
  12578. * Gets or sets the connection point type (default is float)
  12579. */
  12580. get type(): NodeMaterialBlockConnectionPointTypes;
  12581. set type(value: NodeMaterialBlockConnectionPointTypes);
  12582. /**
  12583. * Gets or sets the connection point name
  12584. */
  12585. name: string;
  12586. /**
  12587. * Gets or sets the connection point name
  12588. */
  12589. displayName: string;
  12590. /**
  12591. * Gets or sets a boolean indicating that this connection point can be omitted
  12592. */
  12593. isOptional: boolean;
  12594. /**
  12595. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12596. */
  12597. isExposedOnFrame: boolean;
  12598. /**
  12599. * Gets or sets number indicating the position that the port is exposed to on a frame
  12600. */
  12601. exposedPortPosition: number;
  12602. /**
  12603. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12604. */
  12605. define: string;
  12606. /** @hidden */
  12607. _prioritizeVertex: boolean;
  12608. private _target;
  12609. /** Gets or sets the target of that connection point */
  12610. get target(): NodeMaterialBlockTargets;
  12611. set target(value: NodeMaterialBlockTargets);
  12612. /**
  12613. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12614. */
  12615. get isConnected(): boolean;
  12616. /**
  12617. * Gets a boolean indicating that the current point is connected to an input block
  12618. */
  12619. get isConnectedToInputBlock(): boolean;
  12620. /**
  12621. * Gets a the connected input block (if any)
  12622. */
  12623. get connectInputBlock(): Nullable<InputBlock>;
  12624. /** Get the other side of the connection (if any) */
  12625. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12626. /** Get the block that owns this connection point */
  12627. get ownerBlock(): NodeMaterialBlock;
  12628. /** Get the block connected on the other side of this connection (if any) */
  12629. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12630. /** Get the block connected on the endpoints of this connection (if any) */
  12631. get connectedBlocks(): Array<NodeMaterialBlock>;
  12632. /** Gets the list of connected endpoints */
  12633. get endpoints(): NodeMaterialConnectionPoint[];
  12634. /** Gets a boolean indicating if that output point is connected to at least one input */
  12635. get hasEndpoints(): boolean;
  12636. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12637. get isConnectedInVertexShader(): boolean;
  12638. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12639. get isConnectedInFragmentShader(): boolean;
  12640. /**
  12641. * Creates a block suitable to be used as an input for this input point.
  12642. * If null is returned, a block based on the point type will be created.
  12643. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  12644. */
  12645. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12646. /**
  12647. * Creates a new connection point
  12648. * @param name defines the connection point name
  12649. * @param ownerBlock defines the block hosting this connection point
  12650. * @param direction defines the direction of the connection point
  12651. */
  12652. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12653. /**
  12654. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12655. * @returns the class name
  12656. */
  12657. getClassName(): string;
  12658. /**
  12659. * Gets a boolean indicating if the current point can be connected to another point
  12660. * @param connectionPoint defines the other connection point
  12661. * @returns a boolean
  12662. */
  12663. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12664. /**
  12665. * Gets a number indicating if the current point can be connected to another point
  12666. * @param connectionPoint defines the other connection point
  12667. * @returns a number defining the compatibility state
  12668. */
  12669. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12670. /**
  12671. * Connect this point to another connection point
  12672. * @param connectionPoint defines the other connection point
  12673. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12674. * @returns the current connection point
  12675. */
  12676. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12677. /**
  12678. * Disconnect this point from one of his endpoint
  12679. * @param endpoint defines the other connection point
  12680. * @returns the current connection point
  12681. */
  12682. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12683. /**
  12684. * Serializes this point in a JSON representation
  12685. * @param isInput defines if the connection point is an input (default is true)
  12686. * @returns the serialized point object
  12687. */
  12688. serialize(isInput?: boolean): any;
  12689. /**
  12690. * Release resources
  12691. */
  12692. dispose(): void;
  12693. }
  12694. }
  12695. declare module BABYLON {
  12696. /**
  12697. * Enum used to define the material modes
  12698. */
  12699. export enum NodeMaterialModes {
  12700. /** Regular material */
  12701. Material = 0,
  12702. /** For post process */
  12703. PostProcess = 1,
  12704. /** For particle system */
  12705. Particle = 2,
  12706. /** For procedural texture */
  12707. ProceduralTexture = 3
  12708. }
  12709. }
  12710. declare module BABYLON {
  12711. /** @hidden */
  12712. export var helperFunctions: {
  12713. name: string;
  12714. shader: string;
  12715. };
  12716. }
  12717. declare module BABYLON {
  12718. /**
  12719. * Block used to read a texture from a sampler
  12720. */
  12721. export class TextureBlock extends NodeMaterialBlock {
  12722. private _defineName;
  12723. private _linearDefineName;
  12724. private _gammaDefineName;
  12725. private _tempTextureRead;
  12726. private _samplerName;
  12727. private _transformedUVName;
  12728. private _textureTransformName;
  12729. private _textureInfoName;
  12730. private _mainUVName;
  12731. private _mainUVDefineName;
  12732. private _fragmentOnly;
  12733. /**
  12734. * Gets or sets the texture associated with the node
  12735. */
  12736. texture: Nullable<Texture>;
  12737. /**
  12738. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12739. */
  12740. convertToGammaSpace: boolean;
  12741. /**
  12742. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12743. */
  12744. convertToLinearSpace: boolean;
  12745. /**
  12746. * Create a new TextureBlock
  12747. * @param name defines the block name
  12748. */
  12749. constructor(name: string, fragmentOnly?: boolean);
  12750. /**
  12751. * Gets the current class name
  12752. * @returns the class name
  12753. */
  12754. getClassName(): string;
  12755. /**
  12756. * Gets the uv input component
  12757. */
  12758. get uv(): NodeMaterialConnectionPoint;
  12759. /**
  12760. * Gets the rgba output component
  12761. */
  12762. get rgba(): NodeMaterialConnectionPoint;
  12763. /**
  12764. * Gets the rgb output component
  12765. */
  12766. get rgb(): NodeMaterialConnectionPoint;
  12767. /**
  12768. * Gets the r output component
  12769. */
  12770. get r(): NodeMaterialConnectionPoint;
  12771. /**
  12772. * Gets the g output component
  12773. */
  12774. get g(): NodeMaterialConnectionPoint;
  12775. /**
  12776. * Gets the b output component
  12777. */
  12778. get b(): NodeMaterialConnectionPoint;
  12779. /**
  12780. * Gets the a output component
  12781. */
  12782. get a(): NodeMaterialConnectionPoint;
  12783. get target(): NodeMaterialBlockTargets;
  12784. autoConfigure(material: NodeMaterial): void;
  12785. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12786. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12787. isReady(): boolean;
  12788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12789. private get _isMixed();
  12790. private _injectVertexCode;
  12791. private _writeTextureRead;
  12792. private _writeOutput;
  12793. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12794. protected _dumpPropertiesCode(): string;
  12795. serialize(): any;
  12796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12797. }
  12798. }
  12799. declare module BABYLON {
  12800. /** @hidden */
  12801. export var reflectionFunction: {
  12802. name: string;
  12803. shader: string;
  12804. };
  12805. }
  12806. declare module BABYLON {
  12807. /**
  12808. * Base block used to read a reflection texture from a sampler
  12809. */
  12810. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12811. /** @hidden */
  12812. _define3DName: string;
  12813. /** @hidden */
  12814. _defineCubicName: string;
  12815. /** @hidden */
  12816. _defineExplicitName: string;
  12817. /** @hidden */
  12818. _defineProjectionName: string;
  12819. /** @hidden */
  12820. _defineLocalCubicName: string;
  12821. /** @hidden */
  12822. _defineSphericalName: string;
  12823. /** @hidden */
  12824. _definePlanarName: string;
  12825. /** @hidden */
  12826. _defineEquirectangularName: string;
  12827. /** @hidden */
  12828. _defineMirroredEquirectangularFixedName: string;
  12829. /** @hidden */
  12830. _defineEquirectangularFixedName: string;
  12831. /** @hidden */
  12832. _defineSkyboxName: string;
  12833. /** @hidden */
  12834. _defineOppositeZ: string;
  12835. /** @hidden */
  12836. _cubeSamplerName: string;
  12837. /** @hidden */
  12838. _2DSamplerName: string;
  12839. protected _positionUVWName: string;
  12840. protected _directionWName: string;
  12841. protected _reflectionVectorName: string;
  12842. /** @hidden */
  12843. _reflectionCoordsName: string;
  12844. /** @hidden */
  12845. _reflectionMatrixName: string;
  12846. protected _reflectionColorName: string;
  12847. /**
  12848. * Gets or sets the texture associated with the node
  12849. */
  12850. texture: Nullable<BaseTexture>;
  12851. /**
  12852. * Create a new ReflectionTextureBaseBlock
  12853. * @param name defines the block name
  12854. */
  12855. constructor(name: string);
  12856. /**
  12857. * Gets the current class name
  12858. * @returns the class name
  12859. */
  12860. getClassName(): string;
  12861. /**
  12862. * Gets the world position input component
  12863. */
  12864. abstract get position(): NodeMaterialConnectionPoint;
  12865. /**
  12866. * Gets the world position input component
  12867. */
  12868. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12869. /**
  12870. * Gets the world normal input component
  12871. */
  12872. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12873. /**
  12874. * Gets the world input component
  12875. */
  12876. abstract get world(): NodeMaterialConnectionPoint;
  12877. /**
  12878. * Gets the camera (or eye) position component
  12879. */
  12880. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12881. /**
  12882. * Gets the view input component
  12883. */
  12884. abstract get view(): NodeMaterialConnectionPoint;
  12885. protected _getTexture(): Nullable<BaseTexture>;
  12886. autoConfigure(material: NodeMaterial): void;
  12887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12888. isReady(): boolean;
  12889. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12890. /**
  12891. * Gets the code to inject in the vertex shader
  12892. * @param state current state of the node material building
  12893. * @returns the shader code
  12894. */
  12895. handleVertexSide(state: NodeMaterialBuildState): string;
  12896. /**
  12897. * Handles the inits for the fragment code path
  12898. * @param state node material build state
  12899. */
  12900. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12901. /**
  12902. * Generates the reflection coords code for the fragment code path
  12903. * @param worldNormalVarName name of the world normal variable
  12904. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12905. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12906. * @returns the shader code
  12907. */
  12908. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12909. /**
  12910. * Generates the reflection color code for the fragment code path
  12911. * @param lodVarName name of the lod variable
  12912. * @param swizzleLookupTexture swizzle to use for the final color variable
  12913. * @returns the shader code
  12914. */
  12915. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12916. /**
  12917. * Generates the code corresponding to the connected output points
  12918. * @param state node material build state
  12919. * @param varName name of the variable to output
  12920. * @returns the shader code
  12921. */
  12922. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12923. protected _buildBlock(state: NodeMaterialBuildState): this;
  12924. protected _dumpPropertiesCode(): string;
  12925. serialize(): any;
  12926. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12927. }
  12928. }
  12929. declare module BABYLON {
  12930. /**
  12931. * Defines a connection point to be used for points with a custom object type
  12932. */
  12933. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12934. private _blockType;
  12935. private _blockName;
  12936. private _nameForCheking?;
  12937. /**
  12938. * Creates a new connection point
  12939. * @param name defines the connection point name
  12940. * @param ownerBlock defines the block hosting this connection point
  12941. * @param direction defines the direction of the connection point
  12942. */
  12943. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12944. /**
  12945. * Gets a number indicating if the current point can be connected to another point
  12946. * @param connectionPoint defines the other connection point
  12947. * @returns a number defining the compatibility state
  12948. */
  12949. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12950. /**
  12951. * Creates a block suitable to be used as an input for this input point.
  12952. * If null is returned, a block based on the point type will be created.
  12953. * @returns The returned string parameter is the name of the output point of NodeMaterialBlock (first parameter of the returned array) that can be connected to the input
  12954. */
  12955. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12956. }
  12957. }
  12958. declare module BABYLON {
  12959. /**
  12960. * Enum defining the type of properties that can be edited in the property pages in the NME
  12961. */
  12962. export enum PropertyTypeForEdition {
  12963. /** property is a boolean */
  12964. Boolean = 0,
  12965. /** property is a float */
  12966. Float = 1,
  12967. /** property is a Vector2 */
  12968. Vector2 = 2,
  12969. /** property is a list of values */
  12970. List = 3
  12971. }
  12972. /**
  12973. * Interface that defines an option in a variable of type list
  12974. */
  12975. export interface IEditablePropertyListOption {
  12976. /** label of the option */
  12977. "label": string;
  12978. /** value of the option */
  12979. "value": number;
  12980. }
  12981. /**
  12982. * Interface that defines the options available for an editable property
  12983. */
  12984. export interface IEditablePropertyOption {
  12985. /** min value */
  12986. "min"?: number;
  12987. /** max value */
  12988. "max"?: number;
  12989. /** notifiers: indicates which actions to take when the property is changed */
  12990. "notifiers"?: {
  12991. /** the material should be rebuilt */
  12992. "rebuild"?: boolean;
  12993. /** the preview should be updated */
  12994. "update"?: boolean;
  12995. };
  12996. /** list of the options for a variable of type list */
  12997. "options"?: IEditablePropertyListOption[];
  12998. }
  12999. /**
  13000. * Interface that describes an editable property
  13001. */
  13002. export interface IPropertyDescriptionForEdition {
  13003. /** name of the property */
  13004. "propertyName": string;
  13005. /** display name of the property */
  13006. "displayName": string;
  13007. /** type of the property */
  13008. "type": PropertyTypeForEdition;
  13009. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13010. "groupName": string;
  13011. /** options for the property */
  13012. "options": IEditablePropertyOption;
  13013. }
  13014. /**
  13015. * Decorator that flags a property in a node material block as being editable
  13016. */
  13017. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13018. }
  13019. declare module BABYLON {
  13020. /**
  13021. * Block used to implement the refraction part of the sub surface module of the PBR material
  13022. */
  13023. export class RefractionBlock extends NodeMaterialBlock {
  13024. /** @hidden */
  13025. _define3DName: string;
  13026. /** @hidden */
  13027. _refractionMatrixName: string;
  13028. /** @hidden */
  13029. _defineLODRefractionAlpha: string;
  13030. /** @hidden */
  13031. _defineLinearSpecularRefraction: string;
  13032. /** @hidden */
  13033. _defineOppositeZ: string;
  13034. /** @hidden */
  13035. _cubeSamplerName: string;
  13036. /** @hidden */
  13037. _2DSamplerName: string;
  13038. /** @hidden */
  13039. _vRefractionMicrosurfaceInfosName: string;
  13040. /** @hidden */
  13041. _vRefractionInfosName: string;
  13042. /** @hidden */
  13043. _vRefractionFilteringInfoName: string;
  13044. private _scene;
  13045. /**
  13046. * The properties below are set by the main PBR block prior to calling methods of this class.
  13047. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13048. * It's less burden on the user side in the editor part.
  13049. */
  13050. /** @hidden */
  13051. viewConnectionPoint: NodeMaterialConnectionPoint;
  13052. /** @hidden */
  13053. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13054. /**
  13055. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  13056. * Materials half opaque for instance using refraction could benefit from this control.
  13057. */
  13058. linkRefractionWithTransparency: boolean;
  13059. /**
  13060. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13061. */
  13062. invertRefractionY: boolean;
  13063. /**
  13064. * Gets or sets the texture associated with the node
  13065. */
  13066. texture: Nullable<BaseTexture>;
  13067. /**
  13068. * Create a new RefractionBlock
  13069. * @param name defines the block name
  13070. */
  13071. constructor(name: string);
  13072. /**
  13073. * Gets the current class name
  13074. * @returns the class name
  13075. */
  13076. getClassName(): string;
  13077. /**
  13078. * Gets the intensity input component
  13079. */
  13080. get intensity(): NodeMaterialConnectionPoint;
  13081. /**
  13082. * Gets the tint at distance input component
  13083. */
  13084. get tintAtDistance(): NodeMaterialConnectionPoint;
  13085. /**
  13086. * Gets the view input component
  13087. */
  13088. get view(): NodeMaterialConnectionPoint;
  13089. /**
  13090. * Gets the refraction object output component
  13091. */
  13092. get refraction(): NodeMaterialConnectionPoint;
  13093. /**
  13094. * Returns true if the block has a texture
  13095. */
  13096. get hasTexture(): boolean;
  13097. protected _getTexture(): Nullable<BaseTexture>;
  13098. autoConfigure(material: NodeMaterial): void;
  13099. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13100. isReady(): boolean;
  13101. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13102. /**
  13103. * Gets the main code of the block (fragment side)
  13104. * @param state current state of the node material building
  13105. * @returns the shader code
  13106. */
  13107. getCode(state: NodeMaterialBuildState): string;
  13108. protected _buildBlock(state: NodeMaterialBuildState): this;
  13109. protected _dumpPropertiesCode(): string;
  13110. serialize(): any;
  13111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13112. }
  13113. }
  13114. declare module BABYLON {
  13115. /**
  13116. * Base block used as input for post process
  13117. */
  13118. export class CurrentScreenBlock extends NodeMaterialBlock {
  13119. private _samplerName;
  13120. private _linearDefineName;
  13121. private _gammaDefineName;
  13122. private _mainUVName;
  13123. private _tempTextureRead;
  13124. /**
  13125. * Gets or sets the texture associated with the node
  13126. */
  13127. texture: Nullable<BaseTexture>;
  13128. /**
  13129. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13130. */
  13131. convertToGammaSpace: boolean;
  13132. /**
  13133. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13134. */
  13135. convertToLinearSpace: boolean;
  13136. /**
  13137. * Create a new CurrentScreenBlock
  13138. * @param name defines the block name
  13139. */
  13140. constructor(name: string);
  13141. /**
  13142. * Gets the current class name
  13143. * @returns the class name
  13144. */
  13145. getClassName(): string;
  13146. /**
  13147. * Gets the uv input component
  13148. */
  13149. get uv(): NodeMaterialConnectionPoint;
  13150. /**
  13151. * Gets the rgba output component
  13152. */
  13153. get rgba(): NodeMaterialConnectionPoint;
  13154. /**
  13155. * Gets the rgb output component
  13156. */
  13157. get rgb(): NodeMaterialConnectionPoint;
  13158. /**
  13159. * Gets the r output component
  13160. */
  13161. get r(): NodeMaterialConnectionPoint;
  13162. /**
  13163. * Gets the g output component
  13164. */
  13165. get g(): NodeMaterialConnectionPoint;
  13166. /**
  13167. * Gets the b output component
  13168. */
  13169. get b(): NodeMaterialConnectionPoint;
  13170. /**
  13171. * Gets the a output component
  13172. */
  13173. get a(): NodeMaterialConnectionPoint;
  13174. /**
  13175. * Initialize the block and prepare the context for build
  13176. * @param state defines the state that will be used for the build
  13177. */
  13178. initialize(state: NodeMaterialBuildState): void;
  13179. get target(): NodeMaterialBlockTargets;
  13180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13181. isReady(): boolean;
  13182. private _injectVertexCode;
  13183. private _writeTextureRead;
  13184. private _writeOutput;
  13185. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13186. serialize(): any;
  13187. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13188. }
  13189. }
  13190. declare module BABYLON {
  13191. /**
  13192. * Base block used for the particle texture
  13193. */
  13194. export class ParticleTextureBlock extends NodeMaterialBlock {
  13195. private _samplerName;
  13196. private _linearDefineName;
  13197. private _gammaDefineName;
  13198. private _tempTextureRead;
  13199. /**
  13200. * Gets or sets the texture associated with the node
  13201. */
  13202. texture: Nullable<BaseTexture>;
  13203. /**
  13204. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13205. */
  13206. convertToGammaSpace: boolean;
  13207. /**
  13208. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13209. */
  13210. convertToLinearSpace: boolean;
  13211. /**
  13212. * Create a new ParticleTextureBlock
  13213. * @param name defines the block name
  13214. */
  13215. constructor(name: string);
  13216. /**
  13217. * Gets the current class name
  13218. * @returns the class name
  13219. */
  13220. getClassName(): string;
  13221. /**
  13222. * Gets the uv input component
  13223. */
  13224. get uv(): NodeMaterialConnectionPoint;
  13225. /**
  13226. * Gets the rgba output component
  13227. */
  13228. get rgba(): NodeMaterialConnectionPoint;
  13229. /**
  13230. * Gets the rgb output component
  13231. */
  13232. get rgb(): NodeMaterialConnectionPoint;
  13233. /**
  13234. * Gets the r output component
  13235. */
  13236. get r(): NodeMaterialConnectionPoint;
  13237. /**
  13238. * Gets the g output component
  13239. */
  13240. get g(): NodeMaterialConnectionPoint;
  13241. /**
  13242. * Gets the b output component
  13243. */
  13244. get b(): NodeMaterialConnectionPoint;
  13245. /**
  13246. * Gets the a output component
  13247. */
  13248. get a(): NodeMaterialConnectionPoint;
  13249. /**
  13250. * Initialize the block and prepare the context for build
  13251. * @param state defines the state that will be used for the build
  13252. */
  13253. initialize(state: NodeMaterialBuildState): void;
  13254. autoConfigure(material: NodeMaterial): void;
  13255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13256. isReady(): boolean;
  13257. private _writeOutput;
  13258. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13259. serialize(): any;
  13260. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13261. }
  13262. }
  13263. declare module BABYLON {
  13264. /**
  13265. * Class used to store shared data between 2 NodeMaterialBuildState
  13266. */
  13267. export class NodeMaterialBuildStateSharedData {
  13268. /**
  13269. * Gets the list of emitted varyings
  13270. */
  13271. temps: string[];
  13272. /**
  13273. * Gets the list of emitted varyings
  13274. */
  13275. varyings: string[];
  13276. /**
  13277. * Gets the varying declaration string
  13278. */
  13279. varyingDeclaration: string;
  13280. /**
  13281. * Input blocks
  13282. */
  13283. inputBlocks: InputBlock[];
  13284. /**
  13285. * Input blocks
  13286. */
  13287. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13288. /**
  13289. * Bindable blocks (Blocks that need to set data to the effect)
  13290. */
  13291. bindableBlocks: NodeMaterialBlock[];
  13292. /**
  13293. * List of blocks that can provide a compilation fallback
  13294. */
  13295. blocksWithFallbacks: NodeMaterialBlock[];
  13296. /**
  13297. * List of blocks that can provide a define update
  13298. */
  13299. blocksWithDefines: NodeMaterialBlock[];
  13300. /**
  13301. * List of blocks that can provide a repeatable content
  13302. */
  13303. repeatableContentBlocks: NodeMaterialBlock[];
  13304. /**
  13305. * List of blocks that can provide a dynamic list of uniforms
  13306. */
  13307. dynamicUniformBlocks: NodeMaterialBlock[];
  13308. /**
  13309. * List of blocks that can block the isReady function for the material
  13310. */
  13311. blockingBlocks: NodeMaterialBlock[];
  13312. /**
  13313. * Gets the list of animated inputs
  13314. */
  13315. animatedInputs: InputBlock[];
  13316. /**
  13317. * Build Id used to avoid multiple recompilations
  13318. */
  13319. buildId: number;
  13320. /** List of emitted variables */
  13321. variableNames: {
  13322. [key: string]: number;
  13323. };
  13324. /** List of emitted defines */
  13325. defineNames: {
  13326. [key: string]: number;
  13327. };
  13328. /** Should emit comments? */
  13329. emitComments: boolean;
  13330. /** Emit build activity */
  13331. verbose: boolean;
  13332. /** Gets or sets the hosting scene */
  13333. scene: Scene;
  13334. /**
  13335. * Gets the compilation hints emitted at compilation time
  13336. */
  13337. hints: {
  13338. needWorldViewMatrix: boolean;
  13339. needWorldViewProjectionMatrix: boolean;
  13340. needAlphaBlending: boolean;
  13341. needAlphaTesting: boolean;
  13342. };
  13343. /**
  13344. * List of compilation checks
  13345. */
  13346. checks: {
  13347. emitVertex: boolean;
  13348. emitFragment: boolean;
  13349. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13350. };
  13351. /**
  13352. * Is vertex program allowed to be empty?
  13353. */
  13354. allowEmptyVertexProgram: boolean;
  13355. /** Creates a new shared data */
  13356. constructor();
  13357. /**
  13358. * Emits console errors and exceptions if there is a failing check
  13359. */
  13360. emitErrors(): void;
  13361. }
  13362. }
  13363. declare module BABYLON {
  13364. /**
  13365. * Class used to store node based material build state
  13366. */
  13367. export class NodeMaterialBuildState {
  13368. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13369. supportUniformBuffers: boolean;
  13370. /**
  13371. * Gets the list of emitted attributes
  13372. */
  13373. attributes: string[];
  13374. /**
  13375. * Gets the list of emitted uniforms
  13376. */
  13377. uniforms: string[];
  13378. /**
  13379. * Gets the list of emitted constants
  13380. */
  13381. constants: string[];
  13382. /**
  13383. * Gets the list of emitted samplers
  13384. */
  13385. samplers: string[];
  13386. /**
  13387. * Gets the list of emitted functions
  13388. */
  13389. functions: {
  13390. [key: string]: string;
  13391. };
  13392. /**
  13393. * Gets the list of emitted extensions
  13394. */
  13395. extensions: {
  13396. [key: string]: string;
  13397. };
  13398. /**
  13399. * Gets the target of the compilation state
  13400. */
  13401. target: NodeMaterialBlockTargets;
  13402. /**
  13403. * Gets the list of emitted counters
  13404. */
  13405. counters: {
  13406. [key: string]: number;
  13407. };
  13408. /**
  13409. * Shared data between multiple NodeMaterialBuildState instances
  13410. */
  13411. sharedData: NodeMaterialBuildStateSharedData;
  13412. /** @hidden */
  13413. _vertexState: NodeMaterialBuildState;
  13414. /** @hidden */
  13415. _attributeDeclaration: string;
  13416. /** @hidden */
  13417. _uniformDeclaration: string;
  13418. /** @hidden */
  13419. _constantDeclaration: string;
  13420. /** @hidden */
  13421. _samplerDeclaration: string;
  13422. /** @hidden */
  13423. _varyingTransfer: string;
  13424. /** @hidden */
  13425. _injectAtEnd: string;
  13426. private _repeatableContentAnchorIndex;
  13427. /** @hidden */
  13428. _builtCompilationString: string;
  13429. /**
  13430. * Gets the emitted compilation strings
  13431. */
  13432. compilationString: string;
  13433. /**
  13434. * Finalize the compilation strings
  13435. * @param state defines the current compilation state
  13436. */
  13437. finalize(state: NodeMaterialBuildState): void;
  13438. /** @hidden */
  13439. get _repeatableContentAnchor(): string;
  13440. /** @hidden */
  13441. _getFreeVariableName(prefix: string): string;
  13442. /** @hidden */
  13443. _getFreeDefineName(prefix: string): string;
  13444. /** @hidden */
  13445. _excludeVariableName(name: string): void;
  13446. /** @hidden */
  13447. _emit2DSampler(name: string): void;
  13448. /** @hidden */
  13449. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13450. /** @hidden */
  13451. _emitExtension(name: string, extension: string, define?: string): void;
  13452. /** @hidden */
  13453. _emitFunction(name: string, code: string, comments: string): void;
  13454. /** @hidden */
  13455. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13456. replaceStrings?: {
  13457. search: RegExp;
  13458. replace: string;
  13459. }[];
  13460. repeatKey?: string;
  13461. }): string;
  13462. /** @hidden */
  13463. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13464. repeatKey?: string;
  13465. removeAttributes?: boolean;
  13466. removeUniforms?: boolean;
  13467. removeVaryings?: boolean;
  13468. removeIfDef?: boolean;
  13469. replaceStrings?: {
  13470. search: RegExp;
  13471. replace: string;
  13472. }[];
  13473. }, storeKey?: string): void;
  13474. /** @hidden */
  13475. _registerTempVariable(name: string): boolean;
  13476. /** @hidden */
  13477. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13478. /** @hidden */
  13479. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13480. /** @hidden */
  13481. _emitFloat(value: number): string;
  13482. }
  13483. }
  13484. declare module BABYLON {
  13485. /**
  13486. * Helper class used to generate session unique ID
  13487. */
  13488. export class UniqueIdGenerator {
  13489. private static _UniqueIdCounter;
  13490. /**
  13491. * Gets an unique (relatively to the current scene) Id
  13492. */
  13493. static get UniqueId(): number;
  13494. }
  13495. }
  13496. declare module BABYLON {
  13497. /**
  13498. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13499. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13500. */
  13501. export class EffectFallbacks implements IEffectFallbacks {
  13502. private _defines;
  13503. private _currentRank;
  13504. private _maxRank;
  13505. private _mesh;
  13506. /**
  13507. * Removes the fallback from the bound mesh.
  13508. */
  13509. unBindMesh(): void;
  13510. /**
  13511. * Adds a fallback on the specified property.
  13512. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13513. * @param define The name of the define in the shader
  13514. */
  13515. addFallback(rank: number, define: string): void;
  13516. /**
  13517. * Sets the mesh to use CPU skinning when needing to fallback.
  13518. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13519. * @param mesh The mesh to use the fallbacks.
  13520. */
  13521. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13522. /**
  13523. * Checks to see if more fallbacks are still availible.
  13524. */
  13525. get hasMoreFallbacks(): boolean;
  13526. /**
  13527. * Removes the defines that should be removed when falling back.
  13528. * @param currentDefines defines the current define statements for the shader.
  13529. * @param effect defines the current effect we try to compile
  13530. * @returns The resulting defines with defines of the current rank removed.
  13531. */
  13532. reduce(currentDefines: string, effect: Effect): string;
  13533. }
  13534. }
  13535. declare module BABYLON {
  13536. /**
  13537. * Defines a block that can be used inside a node based material
  13538. */
  13539. export class NodeMaterialBlock {
  13540. private _buildId;
  13541. private _buildTarget;
  13542. private _target;
  13543. private _isFinalMerger;
  13544. private _isInput;
  13545. private _name;
  13546. protected _isUnique: boolean;
  13547. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13548. inputsAreExclusive: boolean;
  13549. /** @hidden */
  13550. _codeVariableName: string;
  13551. /** @hidden */
  13552. _inputs: NodeMaterialConnectionPoint[];
  13553. /** @hidden */
  13554. _outputs: NodeMaterialConnectionPoint[];
  13555. /** @hidden */
  13556. _preparationId: number;
  13557. /**
  13558. * Gets the name of the block
  13559. */
  13560. get name(): string;
  13561. /**
  13562. * Sets the name of the block. Will check if the name is valid.
  13563. */
  13564. set name(newName: string);
  13565. /**
  13566. * Gets or sets the unique id of the node
  13567. */
  13568. uniqueId: number;
  13569. /**
  13570. * Gets or sets the comments associated with this block
  13571. */
  13572. comments: string;
  13573. /**
  13574. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13575. */
  13576. get isUnique(): boolean;
  13577. /**
  13578. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13579. */
  13580. get isFinalMerger(): boolean;
  13581. /**
  13582. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13583. */
  13584. get isInput(): boolean;
  13585. /**
  13586. * Gets or sets the build Id
  13587. */
  13588. get buildId(): number;
  13589. set buildId(value: number);
  13590. /**
  13591. * Gets or sets the target of the block
  13592. */
  13593. get target(): NodeMaterialBlockTargets;
  13594. set target(value: NodeMaterialBlockTargets);
  13595. /**
  13596. * Gets the list of input points
  13597. */
  13598. get inputs(): NodeMaterialConnectionPoint[];
  13599. /** Gets the list of output points */
  13600. get outputs(): NodeMaterialConnectionPoint[];
  13601. /**
  13602. * Find an input by its name
  13603. * @param name defines the name of the input to look for
  13604. * @returns the input or null if not found
  13605. */
  13606. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13607. /**
  13608. * Find an output by its name
  13609. * @param name defines the name of the outputto look for
  13610. * @returns the output or null if not found
  13611. */
  13612. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13613. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13614. visibleInInspector: boolean;
  13615. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13616. visibleOnFrame: boolean;
  13617. /**
  13618. * Creates a new NodeMaterialBlock
  13619. * @param name defines the block name
  13620. * @param target defines the target of that block (Vertex by default)
  13621. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13622. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13623. */
  13624. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13625. /**
  13626. * Initialize the block and prepare the context for build
  13627. * @param state defines the state that will be used for the build
  13628. */
  13629. initialize(state: NodeMaterialBuildState): void;
  13630. /**
  13631. * Bind data to effect. Will only be called for blocks with isBindable === true
  13632. * @param effect defines the effect to bind data to
  13633. * @param nodeMaterial defines the hosting NodeMaterial
  13634. * @param mesh defines the mesh that will be rendered
  13635. * @param subMesh defines the submesh that will be rendered
  13636. */
  13637. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13638. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13639. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13640. protected _writeFloat(value: number): string;
  13641. /**
  13642. * Gets the current class name e.g. "NodeMaterialBlock"
  13643. * @returns the class name
  13644. */
  13645. getClassName(): string;
  13646. /**
  13647. * Register a new input. Must be called inside a block constructor
  13648. * @param name defines the connection point name
  13649. * @param type defines the connection point type
  13650. * @param isOptional defines a boolean indicating that this input can be omitted
  13651. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13652. * @param point an already created connection point. If not provided, create a new one
  13653. * @returns the current block
  13654. */
  13655. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13656. /**
  13657. * Register a new output. Must be called inside a block constructor
  13658. * @param name defines the connection point name
  13659. * @param type defines the connection point type
  13660. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13661. * @param point an already created connection point. If not provided, create a new one
  13662. * @returns the current block
  13663. */
  13664. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13665. /**
  13666. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13667. * @param forOutput defines an optional connection point to check compatibility with
  13668. * @returns the first available input or null
  13669. */
  13670. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13671. /**
  13672. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13673. * @param forBlock defines an optional block to check compatibility with
  13674. * @returns the first available input or null
  13675. */
  13676. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13677. /**
  13678. * Gets the sibling of the given output
  13679. * @param current defines the current output
  13680. * @returns the next output in the list or null
  13681. */
  13682. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13683. /**
  13684. * Connect current block with another block
  13685. * @param other defines the block to connect with
  13686. * @param options define the various options to help pick the right connections
  13687. * @returns the current block
  13688. */
  13689. connectTo(other: NodeMaterialBlock, options?: {
  13690. input?: string;
  13691. output?: string;
  13692. outputSwizzle?: string;
  13693. }): this | undefined;
  13694. protected _buildBlock(state: NodeMaterialBuildState): void;
  13695. /**
  13696. * Add uniforms, samplers and uniform buffers at compilation time
  13697. * @param state defines the state to update
  13698. * @param nodeMaterial defines the node material requesting the update
  13699. * @param defines defines the material defines to update
  13700. * @param uniformBuffers defines the list of uniform buffer names
  13701. */
  13702. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13703. /**
  13704. * Add potential fallbacks if shader compilation fails
  13705. * @param mesh defines the mesh to be rendered
  13706. * @param fallbacks defines the current prioritized list of fallbacks
  13707. */
  13708. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13709. /**
  13710. * Initialize defines for shader compilation
  13711. * @param mesh defines the mesh to be rendered
  13712. * @param nodeMaterial defines the node material requesting the update
  13713. * @param defines defines the material defines to update
  13714. * @param useInstances specifies that instances should be used
  13715. */
  13716. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13717. /**
  13718. * Update defines for shader compilation
  13719. * @param mesh defines the mesh to be rendered
  13720. * @param nodeMaterial defines the node material requesting the update
  13721. * @param defines defines the material defines to update
  13722. * @param useInstances specifies that instances should be used
  13723. * @param subMesh defines which submesh to render
  13724. */
  13725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13726. /**
  13727. * Lets the block try to connect some inputs automatically
  13728. * @param material defines the hosting NodeMaterial
  13729. */
  13730. autoConfigure(material: NodeMaterial): void;
  13731. /**
  13732. * Function called when a block is declared as repeatable content generator
  13733. * @param vertexShaderState defines the current compilation state for the vertex shader
  13734. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13735. * @param mesh defines the mesh to be rendered
  13736. * @param defines defines the material defines to update
  13737. */
  13738. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13739. /**
  13740. * Checks if the block is ready
  13741. * @param mesh defines the mesh to be rendered
  13742. * @param nodeMaterial defines the node material requesting the update
  13743. * @param defines defines the material defines to update
  13744. * @param useInstances specifies that instances should be used
  13745. * @returns true if the block is ready
  13746. */
  13747. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13748. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13749. private _processBuild;
  13750. /**
  13751. * Validates the new name for the block node.
  13752. * @param newName the new name to be given to the node.
  13753. * @returns false if the name is a reserve word, else true.
  13754. */
  13755. validateBlockName(newName: string): boolean;
  13756. /**
  13757. * Compile the current node and generate the shader code
  13758. * @param state defines the current compilation state (uniforms, samplers, current string)
  13759. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13760. * @returns true if already built
  13761. */
  13762. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13763. protected _inputRename(name: string): string;
  13764. protected _outputRename(name: string): string;
  13765. protected _dumpPropertiesCode(): string;
  13766. /** @hidden */
  13767. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13768. /** @hidden */
  13769. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13770. /**
  13771. * Clone the current block to a new identical block
  13772. * @param scene defines the hosting scene
  13773. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13774. * @returns a copy of the current block
  13775. */
  13776. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13777. /**
  13778. * Serializes this block in a JSON representation
  13779. * @returns the serialized block object
  13780. */
  13781. serialize(): any;
  13782. /** @hidden */
  13783. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13784. private _deserializePortDisplayNamesAndExposedOnFrame;
  13785. /**
  13786. * Release resources
  13787. */
  13788. dispose(): void;
  13789. }
  13790. }
  13791. declare module BABYLON {
  13792. /**
  13793. * Base class of materials working in push mode in babylon JS
  13794. * @hidden
  13795. */
  13796. export class PushMaterial extends Material {
  13797. protected _activeEffect: Effect;
  13798. protected _normalMatrix: Matrix;
  13799. constructor(name: string, scene: Scene);
  13800. getEffect(): Effect;
  13801. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13802. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13803. /**
  13804. * Binds the given world matrix to the active effect
  13805. *
  13806. * @param world the matrix to bind
  13807. */
  13808. bindOnlyWorldMatrix(world: Matrix): void;
  13809. /**
  13810. * Binds the given normal matrix to the active effect
  13811. *
  13812. * @param normalMatrix the matrix to bind
  13813. */
  13814. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13815. bind(world: Matrix, mesh?: Mesh): void;
  13816. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13817. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13818. }
  13819. }
  13820. declare module BABYLON {
  13821. /**
  13822. * Root class for all node material optimizers
  13823. */
  13824. export class NodeMaterialOptimizer {
  13825. /**
  13826. * Function used to optimize a NodeMaterial graph
  13827. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13828. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13829. */
  13830. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13831. }
  13832. }
  13833. declare module BABYLON {
  13834. /**
  13835. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13836. */
  13837. export class TransformBlock extends NodeMaterialBlock {
  13838. /**
  13839. * Defines the value to use to complement W value to transform it to a Vector4
  13840. */
  13841. complementW: number;
  13842. /**
  13843. * Defines the value to use to complement z value to transform it to a Vector4
  13844. */
  13845. complementZ: number;
  13846. /**
  13847. * Creates a new TransformBlock
  13848. * @param name defines the block name
  13849. */
  13850. constructor(name: string);
  13851. /**
  13852. * Gets the current class name
  13853. * @returns the class name
  13854. */
  13855. getClassName(): string;
  13856. /**
  13857. * Gets the vector input
  13858. */
  13859. get vector(): NodeMaterialConnectionPoint;
  13860. /**
  13861. * Gets the output component
  13862. */
  13863. get output(): NodeMaterialConnectionPoint;
  13864. /**
  13865. * Gets the xyz output component
  13866. */
  13867. get xyz(): NodeMaterialConnectionPoint;
  13868. /**
  13869. * Gets the matrix transform input
  13870. */
  13871. get transform(): NodeMaterialConnectionPoint;
  13872. protected _buildBlock(state: NodeMaterialBuildState): this;
  13873. /**
  13874. * Update defines for shader compilation
  13875. * @param mesh defines the mesh to be rendered
  13876. * @param nodeMaterial defines the node material requesting the update
  13877. * @param defines defines the material defines to update
  13878. * @param useInstances specifies that instances should be used
  13879. * @param subMesh defines which submesh to render
  13880. */
  13881. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13882. serialize(): any;
  13883. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13884. protected _dumpPropertiesCode(): string;
  13885. }
  13886. }
  13887. declare module BABYLON {
  13888. /**
  13889. * Block used to output the vertex position
  13890. */
  13891. export class VertexOutputBlock extends NodeMaterialBlock {
  13892. /**
  13893. * Creates a new VertexOutputBlock
  13894. * @param name defines the block name
  13895. */
  13896. constructor(name: string);
  13897. /**
  13898. * Gets the current class name
  13899. * @returns the class name
  13900. */
  13901. getClassName(): string;
  13902. /**
  13903. * Gets the vector input component
  13904. */
  13905. get vector(): NodeMaterialConnectionPoint;
  13906. protected _buildBlock(state: NodeMaterialBuildState): this;
  13907. }
  13908. }
  13909. declare module BABYLON {
  13910. /**
  13911. * Block used to output the final color
  13912. */
  13913. export class FragmentOutputBlock extends NodeMaterialBlock {
  13914. /**
  13915. * Create a new FragmentOutputBlock
  13916. * @param name defines the block name
  13917. */
  13918. constructor(name: string);
  13919. /**
  13920. * Gets the current class name
  13921. * @returns the class name
  13922. */
  13923. getClassName(): string;
  13924. /**
  13925. * Gets the rgba input component
  13926. */
  13927. get rgba(): NodeMaterialConnectionPoint;
  13928. /**
  13929. * Gets the rgb input component
  13930. */
  13931. get rgb(): NodeMaterialConnectionPoint;
  13932. /**
  13933. * Gets the a input component
  13934. */
  13935. get a(): NodeMaterialConnectionPoint;
  13936. protected _buildBlock(state: NodeMaterialBuildState): this;
  13937. }
  13938. }
  13939. declare module BABYLON {
  13940. /**
  13941. * Block used for the particle ramp gradient section
  13942. */
  13943. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13944. /**
  13945. * Create a new ParticleRampGradientBlock
  13946. * @param name defines the block name
  13947. */
  13948. constructor(name: string);
  13949. /**
  13950. * Gets the current class name
  13951. * @returns the class name
  13952. */
  13953. getClassName(): string;
  13954. /**
  13955. * Gets the color input component
  13956. */
  13957. get color(): NodeMaterialConnectionPoint;
  13958. /**
  13959. * Gets the rampColor output component
  13960. */
  13961. get rampColor(): NodeMaterialConnectionPoint;
  13962. /**
  13963. * Initialize the block and prepare the context for build
  13964. * @param state defines the state that will be used for the build
  13965. */
  13966. initialize(state: NodeMaterialBuildState): void;
  13967. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13968. }
  13969. }
  13970. declare module BABYLON {
  13971. /**
  13972. * Block used for the particle blend multiply section
  13973. */
  13974. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13975. /**
  13976. * Create a new ParticleBlendMultiplyBlock
  13977. * @param name defines the block name
  13978. */
  13979. constructor(name: string);
  13980. /**
  13981. * Gets the current class name
  13982. * @returns the class name
  13983. */
  13984. getClassName(): string;
  13985. /**
  13986. * Gets the color input component
  13987. */
  13988. get color(): NodeMaterialConnectionPoint;
  13989. /**
  13990. * Gets the alphaTexture input component
  13991. */
  13992. get alphaTexture(): NodeMaterialConnectionPoint;
  13993. /**
  13994. * Gets the alphaColor input component
  13995. */
  13996. get alphaColor(): NodeMaterialConnectionPoint;
  13997. /**
  13998. * Gets the blendColor output component
  13999. */
  14000. get blendColor(): NodeMaterialConnectionPoint;
  14001. /**
  14002. * Initialize the block and prepare the context for build
  14003. * @param state defines the state that will be used for the build
  14004. */
  14005. initialize(state: NodeMaterialBuildState): void;
  14006. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14007. }
  14008. }
  14009. declare module BABYLON {
  14010. /**
  14011. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14012. */
  14013. export class VectorMergerBlock extends NodeMaterialBlock {
  14014. /**
  14015. * Create a new VectorMergerBlock
  14016. * @param name defines the block name
  14017. */
  14018. constructor(name: string);
  14019. /**
  14020. * Gets the current class name
  14021. * @returns the class name
  14022. */
  14023. getClassName(): string;
  14024. /**
  14025. * Gets the xyz component (input)
  14026. */
  14027. get xyzIn(): NodeMaterialConnectionPoint;
  14028. /**
  14029. * Gets the xy component (input)
  14030. */
  14031. get xyIn(): NodeMaterialConnectionPoint;
  14032. /**
  14033. * Gets the x component (input)
  14034. */
  14035. get x(): NodeMaterialConnectionPoint;
  14036. /**
  14037. * Gets the y component (input)
  14038. */
  14039. get y(): NodeMaterialConnectionPoint;
  14040. /**
  14041. * Gets the z component (input)
  14042. */
  14043. get z(): NodeMaterialConnectionPoint;
  14044. /**
  14045. * Gets the w component (input)
  14046. */
  14047. get w(): NodeMaterialConnectionPoint;
  14048. /**
  14049. * Gets the xyzw component (output)
  14050. */
  14051. get xyzw(): NodeMaterialConnectionPoint;
  14052. /**
  14053. * Gets the xyz component (output)
  14054. */
  14055. get xyzOut(): NodeMaterialConnectionPoint;
  14056. /**
  14057. * Gets the xy component (output)
  14058. */
  14059. get xyOut(): NodeMaterialConnectionPoint;
  14060. /**
  14061. * Gets the xy component (output)
  14062. * @deprecated Please use xyOut instead.
  14063. */
  14064. get xy(): NodeMaterialConnectionPoint;
  14065. /**
  14066. * Gets the xyz component (output)
  14067. * @deprecated Please use xyzOut instead.
  14068. */
  14069. get xyz(): NodeMaterialConnectionPoint;
  14070. protected _buildBlock(state: NodeMaterialBuildState): this;
  14071. }
  14072. }
  14073. declare module BABYLON {
  14074. /**
  14075. * Block used to remap a float from a range to a new one
  14076. */
  14077. export class RemapBlock extends NodeMaterialBlock {
  14078. /**
  14079. * Gets or sets the source range
  14080. */
  14081. sourceRange: Vector2;
  14082. /**
  14083. * Gets or sets the target range
  14084. */
  14085. targetRange: Vector2;
  14086. /**
  14087. * Creates a new RemapBlock
  14088. * @param name defines the block name
  14089. */
  14090. constructor(name: string);
  14091. /**
  14092. * Gets the current class name
  14093. * @returns the class name
  14094. */
  14095. getClassName(): string;
  14096. /**
  14097. * Gets the input component
  14098. */
  14099. get input(): NodeMaterialConnectionPoint;
  14100. /**
  14101. * Gets the source min input component
  14102. */
  14103. get sourceMin(): NodeMaterialConnectionPoint;
  14104. /**
  14105. * Gets the source max input component
  14106. */
  14107. get sourceMax(): NodeMaterialConnectionPoint;
  14108. /**
  14109. * Gets the target min input component
  14110. */
  14111. get targetMin(): NodeMaterialConnectionPoint;
  14112. /**
  14113. * Gets the target max input component
  14114. */
  14115. get targetMax(): NodeMaterialConnectionPoint;
  14116. /**
  14117. * Gets the output component
  14118. */
  14119. get output(): NodeMaterialConnectionPoint;
  14120. protected _buildBlock(state: NodeMaterialBuildState): this;
  14121. protected _dumpPropertiesCode(): string;
  14122. serialize(): any;
  14123. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14124. }
  14125. }
  14126. declare module BABYLON {
  14127. /**
  14128. * Block used to multiply 2 values
  14129. */
  14130. export class MultiplyBlock extends NodeMaterialBlock {
  14131. /**
  14132. * Creates a new MultiplyBlock
  14133. * @param name defines the block name
  14134. */
  14135. constructor(name: string);
  14136. /**
  14137. * Gets the current class name
  14138. * @returns the class name
  14139. */
  14140. getClassName(): string;
  14141. /**
  14142. * Gets the left operand input component
  14143. */
  14144. get left(): NodeMaterialConnectionPoint;
  14145. /**
  14146. * Gets the right operand input component
  14147. */
  14148. get right(): NodeMaterialConnectionPoint;
  14149. /**
  14150. * Gets the output component
  14151. */
  14152. get output(): NodeMaterialConnectionPoint;
  14153. protected _buildBlock(state: NodeMaterialBuildState): this;
  14154. }
  14155. }
  14156. declare module BABYLON {
  14157. /** Interface used by value gradients (color, factor, ...) */
  14158. export interface IValueGradient {
  14159. /**
  14160. * Gets or sets the gradient value (between 0 and 1)
  14161. */
  14162. gradient: number;
  14163. }
  14164. /** Class used to store color4 gradient */
  14165. export class ColorGradient implements IValueGradient {
  14166. /**
  14167. * Gets or sets the gradient value (between 0 and 1)
  14168. */
  14169. gradient: number;
  14170. /**
  14171. * Gets or sets first associated color
  14172. */
  14173. color1: Color4;
  14174. /**
  14175. * Gets or sets second associated color
  14176. */
  14177. color2?: Color4 | undefined;
  14178. /**
  14179. * Creates a new color4 gradient
  14180. * @param gradient gets or sets the gradient value (between 0 and 1)
  14181. * @param color1 gets or sets first associated color
  14182. * @param color2 gets or sets first second color
  14183. */
  14184. constructor(
  14185. /**
  14186. * Gets or sets the gradient value (between 0 and 1)
  14187. */
  14188. gradient: number,
  14189. /**
  14190. * Gets or sets first associated color
  14191. */
  14192. color1: Color4,
  14193. /**
  14194. * Gets or sets second associated color
  14195. */
  14196. color2?: Color4 | undefined);
  14197. /**
  14198. * Will get a color picked randomly between color1 and color2.
  14199. * If color2 is undefined then color1 will be used
  14200. * @param result defines the target Color4 to store the result in
  14201. */
  14202. getColorToRef(result: Color4): void;
  14203. }
  14204. /** Class used to store color 3 gradient */
  14205. export class Color3Gradient implements IValueGradient {
  14206. /**
  14207. * Gets or sets the gradient value (between 0 and 1)
  14208. */
  14209. gradient: number;
  14210. /**
  14211. * Gets or sets the associated color
  14212. */
  14213. color: Color3;
  14214. /**
  14215. * Creates a new color3 gradient
  14216. * @param gradient gets or sets the gradient value (between 0 and 1)
  14217. * @param color gets or sets associated color
  14218. */
  14219. constructor(
  14220. /**
  14221. * Gets or sets the gradient value (between 0 and 1)
  14222. */
  14223. gradient: number,
  14224. /**
  14225. * Gets or sets the associated color
  14226. */
  14227. color: Color3);
  14228. }
  14229. /** Class used to store factor gradient */
  14230. export class FactorGradient implements IValueGradient {
  14231. /**
  14232. * Gets or sets the gradient value (between 0 and 1)
  14233. */
  14234. gradient: number;
  14235. /**
  14236. * Gets or sets first associated factor
  14237. */
  14238. factor1: number;
  14239. /**
  14240. * Gets or sets second associated factor
  14241. */
  14242. factor2?: number | undefined;
  14243. /**
  14244. * Creates a new factor gradient
  14245. * @param gradient gets or sets the gradient value (between 0 and 1)
  14246. * @param factor1 gets or sets first associated factor
  14247. * @param factor2 gets or sets second associated factor
  14248. */
  14249. constructor(
  14250. /**
  14251. * Gets or sets the gradient value (between 0 and 1)
  14252. */
  14253. gradient: number,
  14254. /**
  14255. * Gets or sets first associated factor
  14256. */
  14257. factor1: number,
  14258. /**
  14259. * Gets or sets second associated factor
  14260. */
  14261. factor2?: number | undefined);
  14262. /**
  14263. * Will get a number picked randomly between factor1 and factor2.
  14264. * If factor2 is undefined then factor1 will be used
  14265. * @returns the picked number
  14266. */
  14267. getFactor(): number;
  14268. }
  14269. /**
  14270. * Helper used to simplify some generic gradient tasks
  14271. */
  14272. export class GradientHelper {
  14273. /**
  14274. * Gets the current gradient from an array of IValueGradient
  14275. * @param ratio defines the current ratio to get
  14276. * @param gradients defines the array of IValueGradient
  14277. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14278. */
  14279. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14280. }
  14281. }
  14282. declare module BABYLON {
  14283. interface ThinEngine {
  14284. /**
  14285. * Creates a raw texture
  14286. * @param data defines the data to store in the texture
  14287. * @param width defines the width of the texture
  14288. * @param height defines the height of the texture
  14289. * @param format defines the format of the data
  14290. * @param generateMipMaps defines if the engine should generate the mip levels
  14291. * @param invertY defines if data must be stored with Y axis inverted
  14292. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14293. * @param compression defines the compression used (null by default)
  14294. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14295. * @returns the raw texture inside an InternalTexture
  14296. */
  14297. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14298. /**
  14299. * Update a raw texture
  14300. * @param texture defines the texture to update
  14301. * @param data defines the data to store in the texture
  14302. * @param format defines the format of the data
  14303. * @param invertY defines if data must be stored with Y axis inverted
  14304. */
  14305. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14306. /**
  14307. * Update a raw texture
  14308. * @param texture defines the texture to update
  14309. * @param data defines the data to store in the texture
  14310. * @param format defines the format of the data
  14311. * @param invertY defines if data must be stored with Y axis inverted
  14312. * @param compression defines the compression used (null by default)
  14313. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14314. */
  14315. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14316. /**
  14317. * Creates a new raw cube texture
  14318. * @param data defines the array of data to use to create each face
  14319. * @param size defines the size of the textures
  14320. * @param format defines the format of the data
  14321. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14322. * @param generateMipMaps defines if the engine should generate the mip levels
  14323. * @param invertY defines if data must be stored with Y axis inverted
  14324. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14325. * @param compression defines the compression used (null by default)
  14326. * @returns the cube texture as an InternalTexture
  14327. */
  14328. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14329. /**
  14330. * Update a raw cube texture
  14331. * @param texture defines the texture to udpdate
  14332. * @param data defines the data to store
  14333. * @param format defines the data format
  14334. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14335. * @param invertY defines if data must be stored with Y axis inverted
  14336. */
  14337. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14338. /**
  14339. * Update a raw cube texture
  14340. * @param texture defines the texture to udpdate
  14341. * @param data defines the data to store
  14342. * @param format defines the data format
  14343. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14344. * @param invertY defines if data must be stored with Y axis inverted
  14345. * @param compression defines the compression used (null by default)
  14346. */
  14347. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14348. /**
  14349. * Update a raw cube texture
  14350. * @param texture defines the texture to udpdate
  14351. * @param data defines the data to store
  14352. * @param format defines the data format
  14353. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14354. * @param invertY defines if data must be stored with Y axis inverted
  14355. * @param compression defines the compression used (null by default)
  14356. * @param level defines which level of the texture to update
  14357. */
  14358. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14359. /**
  14360. * Creates a new raw cube texture from a specified url
  14361. * @param url defines the url where the data is located
  14362. * @param scene defines the current scene
  14363. * @param size defines the size of the textures
  14364. * @param format defines the format of the data
  14365. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14366. * @param noMipmap defines if the engine should avoid generating the mip levels
  14367. * @param callback defines a callback used to extract texture data from loaded data
  14368. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14369. * @param onLoad defines a callback called when texture is loaded
  14370. * @param onError defines a callback called if there is an error
  14371. * @returns the cube texture as an InternalTexture
  14372. */
  14373. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  14374. /**
  14375. * Creates a new raw cube texture from a specified url
  14376. * @param url defines the url where the data is located
  14377. * @param scene defines the current scene
  14378. * @param size defines the size of the textures
  14379. * @param format defines the format of the data
  14380. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14381. * @param noMipmap defines if the engine should avoid generating the mip levels
  14382. * @param callback defines a callback used to extract texture data from loaded data
  14383. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14384. * @param onLoad defines a callback called when texture is loaded
  14385. * @param onError defines a callback called if there is an error
  14386. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14387. * @param invertY defines if data must be stored with Y axis inverted
  14388. * @returns the cube texture as an InternalTexture
  14389. */
  14390. createRawCubeTextureFromUrl(url: string, scene: Nullable<Scene>, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  14391. /**
  14392. * Creates a new raw 3D texture
  14393. * @param data defines the data used to create the texture
  14394. * @param width defines the width of the texture
  14395. * @param height defines the height of the texture
  14396. * @param depth defines the depth of the texture
  14397. * @param format defines the format of the texture
  14398. * @param generateMipMaps defines if the engine must generate mip levels
  14399. * @param invertY defines if data must be stored with Y axis inverted
  14400. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14401. * @param compression defines the compressed used (can be null)
  14402. * @param textureType defines the compressed used (can be null)
  14403. * @returns a new raw 3D texture (stored in an InternalTexture)
  14404. */
  14405. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14406. /**
  14407. * Update a raw 3D texture
  14408. * @param texture defines the texture to update
  14409. * @param data defines the data to store
  14410. * @param format defines the data format
  14411. * @param invertY defines if data must be stored with Y axis inverted
  14412. */
  14413. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14414. /**
  14415. * Update a raw 3D texture
  14416. * @param texture defines the texture to update
  14417. * @param data defines the data to store
  14418. * @param format defines the data format
  14419. * @param invertY defines if data must be stored with Y axis inverted
  14420. * @param compression defines the used compression (can be null)
  14421. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14422. */
  14423. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14424. /**
  14425. * Creates a new raw 2D array texture
  14426. * @param data defines the data used to create the texture
  14427. * @param width defines the width of the texture
  14428. * @param height defines the height of the texture
  14429. * @param depth defines the number of layers of the texture
  14430. * @param format defines the format of the texture
  14431. * @param generateMipMaps defines if the engine must generate mip levels
  14432. * @param invertY defines if data must be stored with Y axis inverted
  14433. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14434. * @param compression defines the compressed used (can be null)
  14435. * @param textureType defines the compressed used (can be null)
  14436. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14437. */
  14438. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14439. /**
  14440. * Update a raw 2D array texture
  14441. * @param texture defines the texture to update
  14442. * @param data defines the data to store
  14443. * @param format defines the data format
  14444. * @param invertY defines if data must be stored with Y axis inverted
  14445. */
  14446. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14447. /**
  14448. * Update a raw 2D array texture
  14449. * @param texture defines the texture to update
  14450. * @param data defines the data to store
  14451. * @param format defines the data format
  14452. * @param invertY defines if data must be stored with Y axis inverted
  14453. * @param compression defines the used compression (can be null)
  14454. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14455. */
  14456. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14457. }
  14458. }
  14459. declare module BABYLON {
  14460. /**
  14461. * Raw texture can help creating a texture directly from an array of data.
  14462. * This can be super useful if you either get the data from an uncompressed source or
  14463. * if you wish to create your texture pixel by pixel.
  14464. */
  14465. export class RawTexture extends Texture {
  14466. /**
  14467. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14468. */
  14469. format: number;
  14470. /**
  14471. * Instantiates a new RawTexture.
  14472. * Raw texture can help creating a texture directly from an array of data.
  14473. * This can be super useful if you either get the data from an uncompressed source or
  14474. * if you wish to create your texture pixel by pixel.
  14475. * @param data define the array of data to use to create the texture
  14476. * @param width define the width of the texture
  14477. * @param height define the height of the texture
  14478. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14479. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14480. * @param generateMipMaps define whether mip maps should be generated or not
  14481. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14482. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14483. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14484. */
  14485. constructor(data: ArrayBufferView, width: number, height: number,
  14486. /**
  14487. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14488. */
  14489. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14490. /**
  14491. * Updates the texture underlying data.
  14492. * @param data Define the new data of the texture
  14493. */
  14494. update(data: ArrayBufferView): void;
  14495. /**
  14496. * Creates a luminance texture from some data.
  14497. * @param data Define the texture data
  14498. * @param width Define the width of the texture
  14499. * @param height Define the height of the texture
  14500. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14501. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14502. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14503. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14504. * @returns the luminance texture
  14505. */
  14506. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14507. /**
  14508. * Creates a luminance alpha texture from some data.
  14509. * @param data Define the texture data
  14510. * @param width Define the width of the texture
  14511. * @param height Define the height of the texture
  14512. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14513. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14514. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14515. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14516. * @returns the luminance alpha texture
  14517. */
  14518. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14519. /**
  14520. * Creates an alpha texture from some data.
  14521. * @param data Define the texture data
  14522. * @param width Define the width of the texture
  14523. * @param height Define the height of the texture
  14524. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14525. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14526. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14527. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14528. * @returns the alpha texture
  14529. */
  14530. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14531. /**
  14532. * Creates a RGB texture from some data.
  14533. * @param data Define the texture data
  14534. * @param width Define the width of the texture
  14535. * @param height Define the height of the texture
  14536. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14537. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14538. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14539. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14540. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14541. * @returns the RGB alpha texture
  14542. */
  14543. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14544. /**
  14545. * Creates a RGBA texture from some data.
  14546. * @param data Define the texture data
  14547. * @param width Define the width of the texture
  14548. * @param height Define the height of the texture
  14549. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14550. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14551. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14552. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14553. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14554. * @returns the RGBA texture
  14555. */
  14556. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14557. /**
  14558. * Creates a R texture from some data.
  14559. * @param data Define the texture data
  14560. * @param width Define the width of the texture
  14561. * @param height Define the height of the texture
  14562. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14563. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14564. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14565. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14566. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14567. * @returns the R texture
  14568. */
  14569. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14570. }
  14571. }
  14572. declare module BABYLON {
  14573. interface ThinEngine {
  14574. /**
  14575. * Update a dynamic index buffer
  14576. * @param indexBuffer defines the target index buffer
  14577. * @param indices defines the data to update
  14578. * @param offset defines the offset in the target index buffer where update should start
  14579. */
  14580. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14581. /**
  14582. * Updates a dynamic vertex buffer.
  14583. * @param vertexBuffer the vertex buffer to update
  14584. * @param data the data used to update the vertex buffer
  14585. * @param byteOffset the byte offset of the data
  14586. * @param byteLength the byte length of the data
  14587. */
  14588. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14589. }
  14590. }
  14591. declare module BABYLON {
  14592. interface AbstractScene {
  14593. /**
  14594. * The list of procedural textures added to the scene
  14595. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14596. */
  14597. proceduralTextures: Array<ProceduralTexture>;
  14598. }
  14599. /**
  14600. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14601. * in a given scene.
  14602. */
  14603. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14604. /**
  14605. * The component name helpfull to identify the component in the list of scene components.
  14606. */
  14607. readonly name: string;
  14608. /**
  14609. * The scene the component belongs to.
  14610. */
  14611. scene: Scene;
  14612. /**
  14613. * Creates a new instance of the component for the given scene
  14614. * @param scene Defines the scene to register the component in
  14615. */
  14616. constructor(scene: Scene);
  14617. /**
  14618. * Registers the component in a given scene
  14619. */
  14620. register(): void;
  14621. /**
  14622. * Rebuilds the elements related to this component in case of
  14623. * context lost for instance.
  14624. */
  14625. rebuild(): void;
  14626. /**
  14627. * Disposes the component and the associated ressources.
  14628. */
  14629. dispose(): void;
  14630. private _beforeClear;
  14631. }
  14632. }
  14633. declare module BABYLON {
  14634. interface ThinEngine {
  14635. /**
  14636. * Creates a new render target cube texture
  14637. * @param size defines the size of the texture
  14638. * @param options defines the options used to create the texture
  14639. * @returns a new render target cube texture stored in an InternalTexture
  14640. */
  14641. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14642. }
  14643. }
  14644. declare module BABYLON {
  14645. /** @hidden */
  14646. export var proceduralVertexShader: {
  14647. name: string;
  14648. shader: string;
  14649. };
  14650. }
  14651. declare module BABYLON {
  14652. /**
  14653. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  14654. * This is the base class of any Procedural texture and contains most of the shareable code.
  14655. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14656. */
  14657. export class ProceduralTexture extends Texture {
  14658. /**
  14659. * Define if the texture is enabled or not (disabled texture will not render)
  14660. */
  14661. isEnabled: boolean;
  14662. /**
  14663. * Define if the texture must be cleared before rendering (default is true)
  14664. */
  14665. autoClear: boolean;
  14666. /**
  14667. * Callback called when the texture is generated
  14668. */
  14669. onGenerated: () => void;
  14670. /**
  14671. * Event raised when the texture is generated
  14672. */
  14673. onGeneratedObservable: Observable<ProceduralTexture>;
  14674. /**
  14675. * Event raised before the texture is generated
  14676. */
  14677. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14678. /**
  14679. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14680. */
  14681. nodeMaterialSource: Nullable<NodeMaterial>;
  14682. /** @hidden */
  14683. _generateMipMaps: boolean;
  14684. /** @hidden **/
  14685. _effect: Effect;
  14686. /** @hidden */
  14687. _textures: {
  14688. [key: string]: Texture;
  14689. };
  14690. /** @hidden */
  14691. protected _fallbackTexture: Nullable<Texture>;
  14692. private _size;
  14693. private _textureType;
  14694. private _currentRefreshId;
  14695. private _frameId;
  14696. private _refreshRate;
  14697. private _vertexBuffers;
  14698. private _indexBuffer;
  14699. private _uniforms;
  14700. private _samplers;
  14701. private _fragment;
  14702. private _floats;
  14703. private _ints;
  14704. private _floatsArrays;
  14705. private _colors3;
  14706. private _colors4;
  14707. private _vectors2;
  14708. private _vectors3;
  14709. private _matrices;
  14710. private _fallbackTextureUsed;
  14711. private _fullEngine;
  14712. private _cachedDefines;
  14713. private _contentUpdateId;
  14714. private _contentData;
  14715. /**
  14716. * Instantiates a new procedural texture.
  14717. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  14718. * This is the base class of any Procedural texture and contains most of the shareable code.
  14719. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14720. * @param name Define the name of the texture
  14721. * @param size Define the size of the texture to create
  14722. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14723. * @param scene Define the scene the texture belongs to
  14724. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14725. * @param generateMipMaps Define if the texture should creates mip maps or not
  14726. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14727. * @param textureType The FBO internal texture type
  14728. */
  14729. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14730. /**
  14731. * The effect that is created when initializing the post process.
  14732. * @returns The created effect corresponding the the postprocess.
  14733. */
  14734. getEffect(): Effect;
  14735. /**
  14736. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14737. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  14738. */
  14739. getContent(): Nullable<Promise<ArrayBufferView>>;
  14740. private _createIndexBuffer;
  14741. /** @hidden */
  14742. _rebuild(): void;
  14743. /**
  14744. * Resets the texture in order to recreate its associated resources.
  14745. * This can be called in case of context loss
  14746. */
  14747. reset(): void;
  14748. protected _getDefines(): string;
  14749. /**
  14750. * Is the texture ready to be used ? (rendered at least once)
  14751. * @returns true if ready, otherwise, false.
  14752. */
  14753. isReady(): boolean;
  14754. /**
  14755. * Resets the refresh counter of the texture and start bak from scratch.
  14756. * Could be useful to regenerate the texture if it is setup to render only once.
  14757. */
  14758. resetRefreshCounter(): void;
  14759. /**
  14760. * Set the fragment shader to use in order to render the texture.
  14761. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14762. */
  14763. setFragment(fragment: any): void;
  14764. /**
  14765. * Define the refresh rate of the texture or the rendering frequency.
  14766. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14767. */
  14768. get refreshRate(): number;
  14769. set refreshRate(value: number);
  14770. /** @hidden */
  14771. _shouldRender(): boolean;
  14772. /**
  14773. * Get the size the texture is rendering at.
  14774. * @returns the size (on cube texture it is always squared)
  14775. */
  14776. getRenderSize(): RenderTargetTextureSize;
  14777. /**
  14778. * Resize the texture to new value.
  14779. * @param size Define the new size the texture should have
  14780. * @param generateMipMaps Define whether the new texture should create mip maps
  14781. */
  14782. resize(size: number, generateMipMaps: boolean): void;
  14783. private _checkUniform;
  14784. /**
  14785. * Set a texture in the shader program used to render.
  14786. * @param name Define the name of the uniform samplers as defined in the shader
  14787. * @param texture Define the texture to bind to this sampler
  14788. * @return the texture itself allowing "fluent" like uniform updates
  14789. */
  14790. setTexture(name: string, texture: Texture): ProceduralTexture;
  14791. /**
  14792. * Set a float in the shader.
  14793. * @param name Define the name of the uniform as defined in the shader
  14794. * @param value Define the value to give to the uniform
  14795. * @return the texture itself allowing "fluent" like uniform updates
  14796. */
  14797. setFloat(name: string, value: number): ProceduralTexture;
  14798. /**
  14799. * Set a int in the shader.
  14800. * @param name Define the name of the uniform as defined in the shader
  14801. * @param value Define the value to give to the uniform
  14802. * @return the texture itself allowing "fluent" like uniform updates
  14803. */
  14804. setInt(name: string, value: number): ProceduralTexture;
  14805. /**
  14806. * Set an array of floats in the shader.
  14807. * @param name Define the name of the uniform as defined in the shader
  14808. * @param value Define the value to give to the uniform
  14809. * @return the texture itself allowing "fluent" like uniform updates
  14810. */
  14811. setFloats(name: string, value: number[]): ProceduralTexture;
  14812. /**
  14813. * Set a vec3 in the shader from a Color3.
  14814. * @param name Define the name of the uniform as defined in the shader
  14815. * @param value Define the value to give to the uniform
  14816. * @return the texture itself allowing "fluent" like uniform updates
  14817. */
  14818. setColor3(name: string, value: Color3): ProceduralTexture;
  14819. /**
  14820. * Set a vec4 in the shader from a Color4.
  14821. * @param name Define the name of the uniform as defined in the shader
  14822. * @param value Define the value to give to the uniform
  14823. * @return the texture itself allowing "fluent" like uniform updates
  14824. */
  14825. setColor4(name: string, value: Color4): ProceduralTexture;
  14826. /**
  14827. * Set a vec2 in the shader from a Vector2.
  14828. * @param name Define the name of the uniform as defined in the shader
  14829. * @param value Define the value to give to the uniform
  14830. * @return the texture itself allowing "fluent" like uniform updates
  14831. */
  14832. setVector2(name: string, value: Vector2): ProceduralTexture;
  14833. /**
  14834. * Set a vec3 in the shader from a Vector3.
  14835. * @param name Define the name of the uniform as defined in the shader
  14836. * @param value Define the value to give to the uniform
  14837. * @return the texture itself allowing "fluent" like uniform updates
  14838. */
  14839. setVector3(name: string, value: Vector3): ProceduralTexture;
  14840. /**
  14841. * Set a mat4 in the shader from a MAtrix.
  14842. * @param name Define the name of the uniform as defined in the shader
  14843. * @param value Define the value to give to the uniform
  14844. * @return the texture itself allowing "fluent" like uniform updates
  14845. */
  14846. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14847. /**
  14848. * Render the texture to its associated render target.
  14849. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14850. */
  14851. render(useCameraPostProcess?: boolean): void;
  14852. /**
  14853. * Clone the texture.
  14854. * @returns the cloned texture
  14855. */
  14856. clone(): ProceduralTexture;
  14857. /**
  14858. * Dispose the texture and release its asoociated resources.
  14859. */
  14860. dispose(): void;
  14861. }
  14862. }
  14863. declare module BABYLON {
  14864. /**
  14865. * This represents the base class for particle system in Babylon.
  14866. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  14867. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14868. * @example https://doc.babylonjs.com/babylon101/particles
  14869. */
  14870. export class BaseParticleSystem {
  14871. /**
  14872. * Source color is added to the destination color without alpha affecting the result
  14873. */
  14874. static BLENDMODE_ONEONE: number;
  14875. /**
  14876. * Blend current color and particle color using particle’s alpha
  14877. */
  14878. static BLENDMODE_STANDARD: number;
  14879. /**
  14880. * Add current color and particle color multiplied by particle’s alpha
  14881. */
  14882. static BLENDMODE_ADD: number;
  14883. /**
  14884. * Multiply current color with particle color
  14885. */
  14886. static BLENDMODE_MULTIPLY: number;
  14887. /**
  14888. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14889. */
  14890. static BLENDMODE_MULTIPLYADD: number;
  14891. /**
  14892. * List of animations used by the particle system.
  14893. */
  14894. animations: Animation[];
  14895. /**
  14896. * Gets or sets the unique id of the particle system
  14897. */
  14898. uniqueId: number;
  14899. /**
  14900. * The id of the Particle system.
  14901. */
  14902. id: string;
  14903. /**
  14904. * The friendly name of the Particle system.
  14905. */
  14906. name: string;
  14907. /**
  14908. * Snippet ID if the particle system was created from the snippet server
  14909. */
  14910. snippetId: string;
  14911. /**
  14912. * The rendering group used by the Particle system to chose when to render.
  14913. */
  14914. renderingGroupId: number;
  14915. /**
  14916. * The emitter represents the Mesh or position we are attaching the particle system to.
  14917. */
  14918. emitter: Nullable<AbstractMesh | Vector3>;
  14919. /**
  14920. * The maximum number of particles to emit per frame
  14921. */
  14922. emitRate: number;
  14923. /**
  14924. * If you want to launch only a few particles at once, that can be done, as well.
  14925. */
  14926. manualEmitCount: number;
  14927. /**
  14928. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14929. */
  14930. updateSpeed: number;
  14931. /**
  14932. * The amount of time the particle system is running (depends of the overall update speed).
  14933. */
  14934. targetStopDuration: number;
  14935. /**
  14936. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14937. */
  14938. disposeOnStop: boolean;
  14939. /**
  14940. * Minimum power of emitting particles.
  14941. */
  14942. minEmitPower: number;
  14943. /**
  14944. * Maximum power of emitting particles.
  14945. */
  14946. maxEmitPower: number;
  14947. /**
  14948. * Minimum life time of emitting particles.
  14949. */
  14950. minLifeTime: number;
  14951. /**
  14952. * Maximum life time of emitting particles.
  14953. */
  14954. maxLifeTime: number;
  14955. /**
  14956. * Minimum Size of emitting particles.
  14957. */
  14958. minSize: number;
  14959. /**
  14960. * Maximum Size of emitting particles.
  14961. */
  14962. maxSize: number;
  14963. /**
  14964. * Minimum scale of emitting particles on X axis.
  14965. */
  14966. minScaleX: number;
  14967. /**
  14968. * Maximum scale of emitting particles on X axis.
  14969. */
  14970. maxScaleX: number;
  14971. /**
  14972. * Minimum scale of emitting particles on Y axis.
  14973. */
  14974. minScaleY: number;
  14975. /**
  14976. * Maximum scale of emitting particles on Y axis.
  14977. */
  14978. maxScaleY: number;
  14979. /**
  14980. * Gets or sets the minimal initial rotation in radians.
  14981. */
  14982. minInitialRotation: number;
  14983. /**
  14984. * Gets or sets the maximal initial rotation in radians.
  14985. */
  14986. maxInitialRotation: number;
  14987. /**
  14988. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14989. */
  14990. minAngularSpeed: number;
  14991. /**
  14992. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14993. */
  14994. maxAngularSpeed: number;
  14995. /**
  14996. * The texture used to render each particle. (this can be a spritesheet)
  14997. */
  14998. particleTexture: Nullable<BaseTexture>;
  14999. /**
  15000. * The layer mask we are rendering the particles through.
  15001. */
  15002. layerMask: number;
  15003. /**
  15004. * This can help using your own shader to render the particle system.
  15005. * The according effect will be created
  15006. */
  15007. customShader: any;
  15008. /**
  15009. * By default particle system starts as soon as they are created. This prevents the
  15010. * automatic start to happen and let you decide when to start emitting particles.
  15011. */
  15012. preventAutoStart: boolean;
  15013. private _noiseTexture;
  15014. /**
  15015. * Gets or sets a texture used to add random noise to particle positions
  15016. */
  15017. get noiseTexture(): Nullable<ProceduralTexture>;
  15018. set noiseTexture(value: Nullable<ProceduralTexture>);
  15019. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15020. noiseStrength: Vector3;
  15021. /**
  15022. * Callback triggered when the particle animation is ending.
  15023. */
  15024. onAnimationEnd: Nullable<() => void>;
  15025. /**
  15026. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15027. */
  15028. blendMode: number;
  15029. /**
  15030. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15031. * to override the particles.
  15032. */
  15033. forceDepthWrite: boolean;
  15034. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  15035. preWarmCycles: number;
  15036. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15037. preWarmStepOffset: number;
  15038. /**
  15039. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  15040. */
  15041. spriteCellChangeSpeed: number;
  15042. /**
  15043. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15044. */
  15045. startSpriteCellID: number;
  15046. /**
  15047. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15048. */
  15049. endSpriteCellID: number;
  15050. /**
  15051. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15052. */
  15053. spriteCellWidth: number;
  15054. /**
  15055. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15056. */
  15057. spriteCellHeight: number;
  15058. /**
  15059. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15060. */
  15061. spriteRandomStartCell: boolean;
  15062. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15063. translationPivot: Vector2;
  15064. /** @hidden */
  15065. protected _isAnimationSheetEnabled: boolean;
  15066. /**
  15067. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15068. */
  15069. beginAnimationOnStart: boolean;
  15070. /**
  15071. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15072. */
  15073. beginAnimationFrom: number;
  15074. /**
  15075. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15076. */
  15077. beginAnimationTo: number;
  15078. /**
  15079. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15080. */
  15081. beginAnimationLoop: boolean;
  15082. /**
  15083. * Gets or sets a world offset applied to all particles
  15084. */
  15085. worldOffset: Vector3;
  15086. /**
  15087. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15088. */
  15089. get isAnimationSheetEnabled(): boolean;
  15090. set isAnimationSheetEnabled(value: boolean);
  15091. /**
  15092. * Get hosting scene
  15093. * @returns the scene
  15094. */
  15095. getScene(): Nullable<Scene>;
  15096. /**
  15097. * You can use gravity if you want to give an orientation to your particles.
  15098. */
  15099. gravity: Vector3;
  15100. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15101. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15102. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15103. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15104. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15105. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15106. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15107. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15108. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15109. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15110. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15111. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15112. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15113. /**
  15114. * Defines the delay in milliseconds before starting the system (0 by default)
  15115. */
  15116. startDelay: number;
  15117. /**
  15118. * Gets the current list of drag gradients.
  15119. * You must use addDragGradient and removeDragGradient to udpate this list
  15120. * @returns the list of drag gradients
  15121. */
  15122. getDragGradients(): Nullable<Array<FactorGradient>>;
  15123. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15124. limitVelocityDamping: number;
  15125. /**
  15126. * Gets the current list of limit velocity gradients.
  15127. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15128. * @returns the list of limit velocity gradients
  15129. */
  15130. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15131. /**
  15132. * Gets the current list of color gradients.
  15133. * You must use addColorGradient and removeColorGradient to udpate this list
  15134. * @returns the list of color gradients
  15135. */
  15136. getColorGradients(): Nullable<Array<ColorGradient>>;
  15137. /**
  15138. * Gets the current list of size gradients.
  15139. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15140. * @returns the list of size gradients
  15141. */
  15142. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15143. /**
  15144. * Gets the current list of color remap gradients.
  15145. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15146. * @returns the list of color remap gradients
  15147. */
  15148. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15149. /**
  15150. * Gets the current list of alpha remap gradients.
  15151. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15152. * @returns the list of alpha remap gradients
  15153. */
  15154. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15155. /**
  15156. * Gets the current list of life time gradients.
  15157. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15158. * @returns the list of life time gradients
  15159. */
  15160. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15161. /**
  15162. * Gets the current list of angular speed gradients.
  15163. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15164. * @returns the list of angular speed gradients
  15165. */
  15166. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15167. /**
  15168. * Gets the current list of velocity gradients.
  15169. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15170. * @returns the list of velocity gradients
  15171. */
  15172. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15173. /**
  15174. * Gets the current list of start size gradients.
  15175. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15176. * @returns the list of start size gradients
  15177. */
  15178. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15179. /**
  15180. * Gets the current list of emit rate gradients.
  15181. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15182. * @returns the list of emit rate gradients
  15183. */
  15184. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15185. /**
  15186. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15187. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15188. */
  15189. get direction1(): Vector3;
  15190. set direction1(value: Vector3);
  15191. /**
  15192. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15193. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15194. */
  15195. get direction2(): Vector3;
  15196. set direction2(value: Vector3);
  15197. /**
  15198. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15199. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15200. */
  15201. get minEmitBox(): Vector3;
  15202. set minEmitBox(value: Vector3);
  15203. /**
  15204. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  15205. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15206. */
  15207. get maxEmitBox(): Vector3;
  15208. set maxEmitBox(value: Vector3);
  15209. /**
  15210. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15211. */
  15212. color1: Color4;
  15213. /**
  15214. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15215. */
  15216. color2: Color4;
  15217. /**
  15218. * Color the particle will have at the end of its lifetime
  15219. */
  15220. colorDead: Color4;
  15221. /**
  15222. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15223. */
  15224. textureMask: Color4;
  15225. /**
  15226. * The particle emitter type defines the emitter used by the particle system.
  15227. * It can be for example box, sphere, or cone...
  15228. */
  15229. particleEmitterType: IParticleEmitterType;
  15230. /** @hidden */
  15231. _isSubEmitter: boolean;
  15232. /**
  15233. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15234. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15235. */
  15236. billboardMode: number;
  15237. protected _isBillboardBased: boolean;
  15238. /**
  15239. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15240. */
  15241. get isBillboardBased(): boolean;
  15242. set isBillboardBased(value: boolean);
  15243. /**
  15244. * The scene the particle system belongs to.
  15245. */
  15246. protected _scene: Nullable<Scene>;
  15247. /**
  15248. * The engine the particle system belongs to.
  15249. */
  15250. protected _engine: ThinEngine;
  15251. /**
  15252. * Local cache of defines for image processing.
  15253. */
  15254. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15255. /**
  15256. * Default configuration related to image processing available in the standard Material.
  15257. */
  15258. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15259. /**
  15260. * Gets the image processing configuration used either in this material.
  15261. */
  15262. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15263. /**
  15264. * Sets the Default image processing configuration used either in the this material.
  15265. *
  15266. * If sets to null, the scene one is in use.
  15267. */
  15268. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15269. /**
  15270. * Attaches a new image processing configuration to the Standard Material.
  15271. * @param configuration
  15272. */
  15273. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15274. /** @hidden */
  15275. protected _reset(): void;
  15276. /** @hidden */
  15277. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15278. /**
  15279. * Instantiates a particle system.
  15280. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  15281. * @param name The name of the particle system
  15282. */
  15283. constructor(name: string);
  15284. /**
  15285. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15286. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15287. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15288. * @returns the emitter
  15289. */
  15290. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15291. /**
  15292. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15293. * @param radius The radius of the hemisphere to emit from
  15294. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15295. * @returns the emitter
  15296. */
  15297. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15298. /**
  15299. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15300. * @param radius The radius of the sphere to emit from
  15301. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15302. * @returns the emitter
  15303. */
  15304. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15305. /**
  15306. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15307. * @param radius The radius of the sphere to emit from
  15308. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15309. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15310. * @returns the emitter
  15311. */
  15312. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15313. /**
  15314. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15315. * @param radius The radius of the emission cylinder
  15316. * @param height The height of the emission cylinder
  15317. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15318. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15319. * @returns the emitter
  15320. */
  15321. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15322. /**
  15323. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15324. * @param radius The radius of the cylinder to emit from
  15325. * @param height The height of the emission cylinder
  15326. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15327. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15328. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15329. * @returns the emitter
  15330. */
  15331. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15332. /**
  15333. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15334. * @param radius The radius of the cone to emit from
  15335. * @param angle The base angle of the cone
  15336. * @returns the emitter
  15337. */
  15338. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15339. /**
  15340. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15341. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15342. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15343. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15344. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15345. * @returns the emitter
  15346. */
  15347. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15348. }
  15349. }
  15350. declare module BABYLON {
  15351. /**
  15352. * Type of sub emitter
  15353. */
  15354. export enum SubEmitterType {
  15355. /**
  15356. * Attached to the particle over it's lifetime
  15357. */
  15358. ATTACHED = 0,
  15359. /**
  15360. * Created when the particle dies
  15361. */
  15362. END = 1
  15363. }
  15364. /**
  15365. * Sub emitter class used to emit particles from an existing particle
  15366. */
  15367. export class SubEmitter {
  15368. /**
  15369. * the particle system to be used by the sub emitter
  15370. */
  15371. particleSystem: ParticleSystem;
  15372. /**
  15373. * Type of the submitter (Default: END)
  15374. */
  15375. type: SubEmitterType;
  15376. /**
  15377. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  15378. * Note: This only is supported when using an emitter of type Mesh
  15379. */
  15380. inheritDirection: boolean;
  15381. /**
  15382. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15383. */
  15384. inheritedVelocityAmount: number;
  15385. /**
  15386. * Creates a sub emitter
  15387. * @param particleSystem the particle system to be used by the sub emitter
  15388. */
  15389. constructor(
  15390. /**
  15391. * the particle system to be used by the sub emitter
  15392. */
  15393. particleSystem: ParticleSystem);
  15394. /**
  15395. * Clones the sub emitter
  15396. * @returns the cloned sub emitter
  15397. */
  15398. clone(): SubEmitter;
  15399. /**
  15400. * Serialize current object to a JSON object
  15401. * @returns the serialized object
  15402. */
  15403. serialize(): any;
  15404. /** @hidden */
  15405. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15406. /**
  15407. * Creates a new SubEmitter from a serialized JSON version
  15408. * @param serializationObject defines the JSON object to read from
  15409. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15410. * @param rootUrl defines the rootUrl for data loading
  15411. * @returns a new SubEmitter
  15412. */
  15413. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15414. /** Release associated resources */
  15415. dispose(): void;
  15416. }
  15417. }
  15418. declare module BABYLON {
  15419. /** @hidden */
  15420. export var clipPlaneFragmentDeclaration: {
  15421. name: string;
  15422. shader: string;
  15423. };
  15424. }
  15425. declare module BABYLON {
  15426. /** @hidden */
  15427. export var imageProcessingDeclaration: {
  15428. name: string;
  15429. shader: string;
  15430. };
  15431. }
  15432. declare module BABYLON {
  15433. /** @hidden */
  15434. export var imageProcessingFunctions: {
  15435. name: string;
  15436. shader: string;
  15437. };
  15438. }
  15439. declare module BABYLON {
  15440. /** @hidden */
  15441. export var clipPlaneFragment: {
  15442. name: string;
  15443. shader: string;
  15444. };
  15445. }
  15446. declare module BABYLON {
  15447. /** @hidden */
  15448. export var particlesPixelShader: {
  15449. name: string;
  15450. shader: string;
  15451. };
  15452. }
  15453. declare module BABYLON {
  15454. /** @hidden */
  15455. export var clipPlaneVertexDeclaration: {
  15456. name: string;
  15457. shader: string;
  15458. };
  15459. }
  15460. declare module BABYLON {
  15461. /** @hidden */
  15462. export var clipPlaneVertex: {
  15463. name: string;
  15464. shader: string;
  15465. };
  15466. }
  15467. declare module BABYLON {
  15468. /** @hidden */
  15469. export var particlesVertexShader: {
  15470. name: string;
  15471. shader: string;
  15472. };
  15473. }
  15474. declare module BABYLON {
  15475. /**
  15476. * Interface used to define entities containing multiple clip planes
  15477. */
  15478. export interface IClipPlanesHolder {
  15479. /**
  15480. * Gets or sets the active clipplane 1
  15481. */
  15482. clipPlane: Nullable<Plane>;
  15483. /**
  15484. * Gets or sets the active clipplane 2
  15485. */
  15486. clipPlane2: Nullable<Plane>;
  15487. /**
  15488. * Gets or sets the active clipplane 3
  15489. */
  15490. clipPlane3: Nullable<Plane>;
  15491. /**
  15492. * Gets or sets the active clipplane 4
  15493. */
  15494. clipPlane4: Nullable<Plane>;
  15495. /**
  15496. * Gets or sets the active clipplane 5
  15497. */
  15498. clipPlane5: Nullable<Plane>;
  15499. /**
  15500. * Gets or sets the active clipplane 6
  15501. */
  15502. clipPlane6: Nullable<Plane>;
  15503. }
  15504. }
  15505. declare module BABYLON {
  15506. /**
  15507. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15508. *
  15509. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15510. *
  15511. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15512. */
  15513. export class ThinMaterialHelper {
  15514. /**
  15515. * Binds the clip plane information from the holder to the effect.
  15516. * @param effect The effect we are binding the data to
  15517. * @param holder The entity containing the clip plane information
  15518. */
  15519. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15520. }
  15521. }
  15522. declare module BABYLON {
  15523. interface ThinEngine {
  15524. /**
  15525. * Sets alpha constants used by some alpha blending modes
  15526. * @param r defines the red component
  15527. * @param g defines the green component
  15528. * @param b defines the blue component
  15529. * @param a defines the alpha component
  15530. */
  15531. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15532. /**
  15533. * Sets the current alpha mode
  15534. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15535. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15536. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15537. */
  15538. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15539. /**
  15540. * Gets the current alpha mode
  15541. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15542. * @returns the current alpha mode
  15543. */
  15544. getAlphaMode(): number;
  15545. /**
  15546. * Sets the current alpha equation
  15547. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15548. */
  15549. setAlphaEquation(equation: number): void;
  15550. /**
  15551. * Gets the current alpha equation.
  15552. * @returns the current alpha equation
  15553. */
  15554. getAlphaEquation(): number;
  15555. }
  15556. }
  15557. declare module BABYLON {
  15558. /**
  15559. * This represents a particle system in Babylon.
  15560. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  15561. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15562. * @example https://doc.babylonjs.com/babylon101/particles
  15563. */
  15564. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15565. /**
  15566. * Billboard mode will only apply to Y axis
  15567. */
  15568. static readonly BILLBOARDMODE_Y: number;
  15569. /**
  15570. * Billboard mode will apply to all axes
  15571. */
  15572. static readonly BILLBOARDMODE_ALL: number;
  15573. /**
  15574. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15575. */
  15576. static readonly BILLBOARDMODE_STRETCHED: number;
  15577. /**
  15578. * This function can be defined to provide custom update for active particles.
  15579. * This function will be called instead of regular update (age, position, color, etc.).
  15580. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15581. */
  15582. updateFunction: (particles: Particle[]) => void;
  15583. private _emitterWorldMatrix;
  15584. /**
  15585. * This function can be defined to specify initial direction for every new particle.
  15586. * It by default use the emitterType defined function
  15587. */
  15588. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15589. /**
  15590. * This function can be defined to specify initial position for every new particle.
  15591. * It by default use the emitterType defined function
  15592. */
  15593. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15594. /**
  15595. * @hidden
  15596. */
  15597. _inheritedVelocityOffset: Vector3;
  15598. /**
  15599. * An event triggered when the system is disposed
  15600. */
  15601. onDisposeObservable: Observable<IParticleSystem>;
  15602. /**
  15603. * An event triggered when the system is stopped
  15604. */
  15605. onStoppedObservable: Observable<IParticleSystem>;
  15606. private _onDisposeObserver;
  15607. /**
  15608. * Sets a callback that will be triggered when the system is disposed
  15609. */
  15610. set onDispose(callback: () => void);
  15611. private _particles;
  15612. private _epsilon;
  15613. private _capacity;
  15614. private _stockParticles;
  15615. private _newPartsExcess;
  15616. private _vertexData;
  15617. private _vertexBuffer;
  15618. private _vertexBuffers;
  15619. private _spriteBuffer;
  15620. private _indexBuffer;
  15621. private _effect;
  15622. private _customEffect;
  15623. private _cachedDefines;
  15624. private _scaledColorStep;
  15625. private _colorDiff;
  15626. private _scaledDirection;
  15627. private _scaledGravity;
  15628. private _currentRenderId;
  15629. private _alive;
  15630. private _useInstancing;
  15631. private _vertexArrayObject;
  15632. private _started;
  15633. private _stopped;
  15634. private _actualFrame;
  15635. private _scaledUpdateSpeed;
  15636. private _vertexBufferSize;
  15637. /** @hidden */
  15638. _currentEmitRateGradient: Nullable<FactorGradient>;
  15639. /** @hidden */
  15640. _currentEmitRate1: number;
  15641. /** @hidden */
  15642. _currentEmitRate2: number;
  15643. /** @hidden */
  15644. _currentStartSizeGradient: Nullable<FactorGradient>;
  15645. /** @hidden */
  15646. _currentStartSize1: number;
  15647. /** @hidden */
  15648. _currentStartSize2: number;
  15649. private readonly _rawTextureWidth;
  15650. private _rampGradientsTexture;
  15651. private _useRampGradients;
  15652. /** Gets or sets a matrix to use to compute projection */
  15653. defaultProjectionMatrix: Matrix;
  15654. /** Gets or sets a matrix to use to compute view */
  15655. defaultViewMatrix: Matrix;
  15656. /** Gets or sets a boolean indicating that ramp gradients must be used
  15657. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15658. */
  15659. get useRampGradients(): boolean;
  15660. set useRampGradients(value: boolean);
  15661. /**
  15662. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  15663. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  15664. */
  15665. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15666. private _subEmitters;
  15667. /**
  15668. * @hidden
  15669. * If the particle systems emitter should be disposed when the particle system is disposed
  15670. */
  15671. _disposeEmitterOnDispose: boolean;
  15672. /**
  15673. * The current active Sub-systems, this property is used by the root particle system only.
  15674. */
  15675. activeSubSystems: Array<ParticleSystem>;
  15676. /**
  15677. * Specifies if the particles are updated in emitter local space or world space
  15678. */
  15679. isLocal: boolean;
  15680. private _rootParticleSystem;
  15681. /**
  15682. * Gets the current list of active particles
  15683. */
  15684. get particles(): Particle[];
  15685. /**
  15686. * Gets the number of particles active at the same time.
  15687. * @returns The number of active particles.
  15688. */
  15689. getActiveCount(): number;
  15690. /**
  15691. * Returns the string "ParticleSystem"
  15692. * @returns a string containing the class name
  15693. */
  15694. getClassName(): string;
  15695. /**
  15696. * Gets a boolean indicating that the system is stopping
  15697. * @returns true if the system is currently stopping
  15698. */
  15699. isStopping(): boolean;
  15700. /**
  15701. * Gets the custom effect used to render the particles
  15702. * @param blendMode Blend mode for which the effect should be retrieved
  15703. * @returns The effect
  15704. */
  15705. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15706. /**
  15707. * Sets the custom effect used to render the particles
  15708. * @param effect The effect to set
  15709. * @param blendMode Blend mode for which the effect should be set
  15710. */
  15711. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15712. /** @hidden */
  15713. private _onBeforeDrawParticlesObservable;
  15714. /**
  15715. * Observable that will be called just before the particles are drawn
  15716. */
  15717. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15718. /**
  15719. * Gets the name of the particle vertex shader
  15720. */
  15721. get vertexShaderName(): string;
  15722. /**
  15723. * Instantiates a particle system.
  15724. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  15725. * @param name The name of the particle system
  15726. * @param capacity The max number of particles alive at the same time
  15727. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15728. * @param customEffect a custom effect used to change the way particles are rendered by default
  15729. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15730. * @param epsilon Offset used to render the particles
  15731. */
  15732. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15733. private _addFactorGradient;
  15734. private _removeFactorGradient;
  15735. /**
  15736. * Adds a new life time gradient
  15737. * @param gradient defines the gradient to use (between 0 and 1)
  15738. * @param factor defines the life time factor to affect to the specified gradient
  15739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15740. * @returns the current particle system
  15741. */
  15742. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15743. /**
  15744. * Remove a specific life time gradient
  15745. * @param gradient defines the gradient to remove
  15746. * @returns the current particle system
  15747. */
  15748. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15749. /**
  15750. * Adds a new size gradient
  15751. * @param gradient defines the gradient to use (between 0 and 1)
  15752. * @param factor defines the size factor to affect to the specified gradient
  15753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15754. * @returns the current particle system
  15755. */
  15756. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15757. /**
  15758. * Remove a specific size gradient
  15759. * @param gradient defines the gradient to remove
  15760. * @returns the current particle system
  15761. */
  15762. removeSizeGradient(gradient: number): IParticleSystem;
  15763. /**
  15764. * Adds a new color remap gradient
  15765. * @param gradient defines the gradient to use (between 0 and 1)
  15766. * @param min defines the color remap minimal range
  15767. * @param max defines the color remap maximal range
  15768. * @returns the current particle system
  15769. */
  15770. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15771. /**
  15772. * Remove a specific color remap gradient
  15773. * @param gradient defines the gradient to remove
  15774. * @returns the current particle system
  15775. */
  15776. removeColorRemapGradient(gradient: number): IParticleSystem;
  15777. /**
  15778. * Adds a new alpha remap gradient
  15779. * @param gradient defines the gradient to use (between 0 and 1)
  15780. * @param min defines the alpha remap minimal range
  15781. * @param max defines the alpha remap maximal range
  15782. * @returns the current particle system
  15783. */
  15784. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15785. /**
  15786. * Remove a specific alpha remap gradient
  15787. * @param gradient defines the gradient to remove
  15788. * @returns the current particle system
  15789. */
  15790. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15791. /**
  15792. * Adds a new angular speed gradient
  15793. * @param gradient defines the gradient to use (between 0 and 1)
  15794. * @param factor defines the angular speed to affect to the specified gradient
  15795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15796. * @returns the current particle system
  15797. */
  15798. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15799. /**
  15800. * Remove a specific angular speed gradient
  15801. * @param gradient defines the gradient to remove
  15802. * @returns the current particle system
  15803. */
  15804. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15805. /**
  15806. * Adds a new velocity gradient
  15807. * @param gradient defines the gradient to use (between 0 and 1)
  15808. * @param factor defines the velocity to affect to the specified gradient
  15809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15810. * @returns the current particle system
  15811. */
  15812. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15813. /**
  15814. * Remove a specific velocity gradient
  15815. * @param gradient defines the gradient to remove
  15816. * @returns the current particle system
  15817. */
  15818. removeVelocityGradient(gradient: number): IParticleSystem;
  15819. /**
  15820. * Adds a new limit velocity gradient
  15821. * @param gradient defines the gradient to use (between 0 and 1)
  15822. * @param factor defines the limit velocity value to affect to the specified gradient
  15823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15824. * @returns the current particle system
  15825. */
  15826. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15827. /**
  15828. * Remove a specific limit velocity gradient
  15829. * @param gradient defines the gradient to remove
  15830. * @returns the current particle system
  15831. */
  15832. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15833. /**
  15834. * Adds a new drag gradient
  15835. * @param gradient defines the gradient to use (between 0 and 1)
  15836. * @param factor defines the drag value to affect to the specified gradient
  15837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15838. * @returns the current particle system
  15839. */
  15840. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15841. /**
  15842. * Remove a specific drag gradient
  15843. * @param gradient defines the gradient to remove
  15844. * @returns the current particle system
  15845. */
  15846. removeDragGradient(gradient: number): IParticleSystem;
  15847. /**
  15848. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15849. * @param gradient defines the gradient to use (between 0 and 1)
  15850. * @param factor defines the emit rate value to affect to the specified gradient
  15851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15852. * @returns the current particle system
  15853. */
  15854. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15855. /**
  15856. * Remove a specific emit rate gradient
  15857. * @param gradient defines the gradient to remove
  15858. * @returns the current particle system
  15859. */
  15860. removeEmitRateGradient(gradient: number): IParticleSystem;
  15861. /**
  15862. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15863. * @param gradient defines the gradient to use (between 0 and 1)
  15864. * @param factor defines the start size value to affect to the specified gradient
  15865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15866. * @returns the current particle system
  15867. */
  15868. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15869. /**
  15870. * Remove a specific start size gradient
  15871. * @param gradient defines the gradient to remove
  15872. * @returns the current particle system
  15873. */
  15874. removeStartSizeGradient(gradient: number): IParticleSystem;
  15875. private _createRampGradientTexture;
  15876. /**
  15877. * Gets the current list of ramp gradients.
  15878. * You must use addRampGradient and removeRampGradient to udpate this list
  15879. * @returns the list of ramp gradients
  15880. */
  15881. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15882. /** Force the system to rebuild all gradients that need to be resync */
  15883. forceRefreshGradients(): void;
  15884. private _syncRampGradientTexture;
  15885. /**
  15886. * Adds a new ramp gradient used to remap particle colors
  15887. * @param gradient defines the gradient to use (between 0 and 1)
  15888. * @param color defines the color to affect to the specified gradient
  15889. * @returns the current particle system
  15890. */
  15891. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15892. /**
  15893. * Remove a specific ramp gradient
  15894. * @param gradient defines the gradient to remove
  15895. * @returns the current particle system
  15896. */
  15897. removeRampGradient(gradient: number): ParticleSystem;
  15898. /**
  15899. * Adds a new color gradient
  15900. * @param gradient defines the gradient to use (between 0 and 1)
  15901. * @param color1 defines the color to affect to the specified gradient
  15902. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15903. * @returns this particle system
  15904. */
  15905. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15906. /**
  15907. * Remove a specific color gradient
  15908. * @param gradient defines the gradient to remove
  15909. * @returns this particle system
  15910. */
  15911. removeColorGradient(gradient: number): IParticleSystem;
  15912. private _fetchR;
  15913. protected _reset(): void;
  15914. private _resetEffect;
  15915. private _createVertexBuffers;
  15916. private _createIndexBuffer;
  15917. /**
  15918. * Gets the maximum number of particles active at the same time.
  15919. * @returns The max number of active particles.
  15920. */
  15921. getCapacity(): number;
  15922. /**
  15923. * Gets whether there are still active particles in the system.
  15924. * @returns True if it is alive, otherwise false.
  15925. */
  15926. isAlive(): boolean;
  15927. /**
  15928. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15929. * @returns True if it has been started, otherwise false.
  15930. */
  15931. isStarted(): boolean;
  15932. private _prepareSubEmitterInternalArray;
  15933. /**
  15934. * Starts the particle system and begins to emit
  15935. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15936. */
  15937. start(delay?: number): void;
  15938. /**
  15939. * Stops the particle system.
  15940. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  15941. */
  15942. stop(stopSubEmitters?: boolean): void;
  15943. /**
  15944. * Remove all active particles
  15945. */
  15946. reset(): void;
  15947. /**
  15948. * @hidden (for internal use only)
  15949. */
  15950. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15951. /**
  15952. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15953. * Its lifetime will start back at 0.
  15954. */
  15955. recycleParticle: (particle: Particle) => void;
  15956. private _stopSubEmitters;
  15957. private _createParticle;
  15958. private _removeFromRoot;
  15959. private _emitFromParticle;
  15960. private _update;
  15961. /** @hidden */
  15962. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15963. /** @hidden */
  15964. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15965. /**
  15966. * Fill the defines array according to the current settings of the particle system
  15967. * @param defines Array to be updated
  15968. * @param blendMode blend mode to take into account when updating the array
  15969. */
  15970. fillDefines(defines: Array<string>, blendMode: number): void;
  15971. /**
  15972. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15973. * @param uniforms Uniforms array to fill
  15974. * @param attributes Attributes array to fill
  15975. * @param samplers Samplers array to fill
  15976. */
  15977. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15978. /** @hidden */
  15979. private _getEffect;
  15980. /**
  15981. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15982. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15983. */
  15984. animate(preWarmOnly?: boolean): void;
  15985. private _appendParticleVertices;
  15986. /**
  15987. * Rebuilds the particle system.
  15988. */
  15989. rebuild(): void;
  15990. /**
  15991. * Is this system ready to be used/rendered
  15992. * @return true if the system is ready
  15993. */
  15994. isReady(): boolean;
  15995. private _render;
  15996. /**
  15997. * Renders the particle system in its current state.
  15998. * @returns the current number of particles
  15999. */
  16000. render(): number;
  16001. /**
  16002. * Disposes the particle system and free the associated resources
  16003. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16004. */
  16005. dispose(disposeTexture?: boolean): void;
  16006. /**
  16007. * Clones the particle system.
  16008. * @param name The name of the cloned object
  16009. * @param newEmitter The new emitter to use
  16010. * @returns the cloned particle system
  16011. */
  16012. clone(name: string, newEmitter: any): ParticleSystem;
  16013. /**
  16014. * Serializes the particle system to a JSON object
  16015. * @param serializeTexture defines if the texture must be serialized as well
  16016. * @returns the JSON object
  16017. */
  16018. serialize(serializeTexture?: boolean): any;
  16019. /** @hidden */
  16020. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16021. /** @hidden */
  16022. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16023. /**
  16024. * Parses a JSON object to create a particle system.
  16025. * @param parsedParticleSystem The JSON object to parse
  16026. * @param sceneOrEngine The scene or the engine to create the particle system in
  16027. * @param rootUrl The root url to use to load external dependencies like texture
  16028. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16029. * @returns the Parsed particle system
  16030. */
  16031. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16032. }
  16033. }
  16034. declare module BABYLON {
  16035. /**
  16036. * A particle represents one of the element emitted by a particle system.
  16037. * This is mainly define by its coordinates, direction, velocity and age.
  16038. */
  16039. export class Particle {
  16040. /**
  16041. * The particle system the particle belongs to.
  16042. */
  16043. particleSystem: ParticleSystem;
  16044. private static _Count;
  16045. /**
  16046. * Unique ID of the particle
  16047. */
  16048. id: number;
  16049. /**
  16050. * The world position of the particle in the scene.
  16051. */
  16052. position: Vector3;
  16053. /**
  16054. * The world direction of the particle in the scene.
  16055. */
  16056. direction: Vector3;
  16057. /**
  16058. * The color of the particle.
  16059. */
  16060. color: Color4;
  16061. /**
  16062. * The color change of the particle per step.
  16063. */
  16064. colorStep: Color4;
  16065. /**
  16066. * Defines how long will the life of the particle be.
  16067. */
  16068. lifeTime: number;
  16069. /**
  16070. * The current age of the particle.
  16071. */
  16072. age: number;
  16073. /**
  16074. * The current size of the particle.
  16075. */
  16076. size: number;
  16077. /**
  16078. * The current scale of the particle.
  16079. */
  16080. scale: Vector2;
  16081. /**
  16082. * The current angle of the particle.
  16083. */
  16084. angle: number;
  16085. /**
  16086. * Defines how fast is the angle changing.
  16087. */
  16088. angularSpeed: number;
  16089. /**
  16090. * Defines the cell index used by the particle to be rendered from a sprite.
  16091. */
  16092. cellIndex: number;
  16093. /**
  16094. * The information required to support color remapping
  16095. */
  16096. remapData: Vector4;
  16097. /** @hidden */
  16098. _randomCellOffset?: number;
  16099. /** @hidden */
  16100. _initialDirection: Nullable<Vector3>;
  16101. /** @hidden */
  16102. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16103. /** @hidden */
  16104. _initialStartSpriteCellID: number;
  16105. /** @hidden */
  16106. _initialEndSpriteCellID: number;
  16107. /** @hidden */
  16108. _currentColorGradient: Nullable<ColorGradient>;
  16109. /** @hidden */
  16110. _currentColor1: Color4;
  16111. /** @hidden */
  16112. _currentColor2: Color4;
  16113. /** @hidden */
  16114. _currentSizeGradient: Nullable<FactorGradient>;
  16115. /** @hidden */
  16116. _currentSize1: number;
  16117. /** @hidden */
  16118. _currentSize2: number;
  16119. /** @hidden */
  16120. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16121. /** @hidden */
  16122. _currentAngularSpeed1: number;
  16123. /** @hidden */
  16124. _currentAngularSpeed2: number;
  16125. /** @hidden */
  16126. _currentVelocityGradient: Nullable<FactorGradient>;
  16127. /** @hidden */
  16128. _currentVelocity1: number;
  16129. /** @hidden */
  16130. _currentVelocity2: number;
  16131. /** @hidden */
  16132. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16133. /** @hidden */
  16134. _currentLimitVelocity1: number;
  16135. /** @hidden */
  16136. _currentLimitVelocity2: number;
  16137. /** @hidden */
  16138. _currentDragGradient: Nullable<FactorGradient>;
  16139. /** @hidden */
  16140. _currentDrag1: number;
  16141. /** @hidden */
  16142. _currentDrag2: number;
  16143. /** @hidden */
  16144. _randomNoiseCoordinates1: Vector3;
  16145. /** @hidden */
  16146. _randomNoiseCoordinates2: Vector3;
  16147. /** @hidden */
  16148. _localPosition?: Vector3;
  16149. /**
  16150. * Creates a new instance Particle
  16151. * @param particleSystem the particle system the particle belongs to
  16152. */
  16153. constructor(
  16154. /**
  16155. * The particle system the particle belongs to.
  16156. */
  16157. particleSystem: ParticleSystem);
  16158. private updateCellInfoFromSystem;
  16159. /**
  16160. * Defines how the sprite cell index is updated for the particle
  16161. */
  16162. updateCellIndex(): void;
  16163. /** @hidden */
  16164. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16165. /** @hidden */
  16166. _inheritParticleInfoToSubEmitters(): void;
  16167. /** @hidden */
  16168. _reset(): void;
  16169. /**
  16170. * Copy the properties of particle to another one.
  16171. * @param other the particle to copy the information to.
  16172. */
  16173. copyTo(other: Particle): void;
  16174. }
  16175. }
  16176. declare module BABYLON {
  16177. /**
  16178. * Particle emitter represents a volume emitting particles.
  16179. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16180. */
  16181. export interface IParticleEmitterType {
  16182. /**
  16183. * Called by the particle System when the direction is computed for the created particle.
  16184. * @param worldMatrix is the world matrix of the particle system
  16185. * @param directionToUpdate is the direction vector to update with the result
  16186. * @param particle is the particle we are computed the direction for
  16187. * @param isLocal defines if the direction should be set in local space
  16188. */
  16189. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16190. /**
  16191. * Called by the particle System when the position is computed for the created particle.
  16192. * @param worldMatrix is the world matrix of the particle system
  16193. * @param positionToUpdate is the position vector to update with the result
  16194. * @param particle is the particle we are computed the position for
  16195. * @param isLocal defines if the position should be set in local space
  16196. */
  16197. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16198. /**
  16199. * Clones the current emitter and returns a copy of it
  16200. * @returns the new emitter
  16201. */
  16202. clone(): IParticleEmitterType;
  16203. /**
  16204. * Called by the GPUParticleSystem to setup the update shader
  16205. * @param effect defines the update shader
  16206. */
  16207. applyToShader(effect: Effect): void;
  16208. /**
  16209. * Returns a string to use to update the GPU particles update shader
  16210. * @returns the effect defines string
  16211. */
  16212. getEffectDefines(): string;
  16213. /**
  16214. * Returns a string representing the class name
  16215. * @returns a string containing the class name
  16216. */
  16217. getClassName(): string;
  16218. /**
  16219. * Serializes the particle system to a JSON object.
  16220. * @returns the JSON object
  16221. */
  16222. serialize(): any;
  16223. /**
  16224. * Parse properties from a JSON object
  16225. * @param serializationObject defines the JSON object
  16226. * @param scene defines the hosting scene
  16227. */
  16228. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16229. }
  16230. }
  16231. declare module BABYLON {
  16232. /**
  16233. * Particle emitter emitting particles from the inside of a box.
  16234. * It emits the particles randomly between 2 given directions.
  16235. */
  16236. export class BoxParticleEmitter implements IParticleEmitterType {
  16237. /**
  16238. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16239. */
  16240. direction1: Vector3;
  16241. /**
  16242. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16243. */
  16244. direction2: Vector3;
  16245. /**
  16246. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16247. */
  16248. minEmitBox: Vector3;
  16249. /**
  16250. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  16251. */
  16252. maxEmitBox: Vector3;
  16253. /**
  16254. * Creates a new instance BoxParticleEmitter
  16255. */
  16256. constructor();
  16257. /**
  16258. * Called by the particle System when the direction is computed for the created particle.
  16259. * @param worldMatrix is the world matrix of the particle system
  16260. * @param directionToUpdate is the direction vector to update with the result
  16261. * @param particle is the particle we are computed the direction for
  16262. * @param isLocal defines if the direction should be set in local space
  16263. */
  16264. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16265. /**
  16266. * Called by the particle System when the position is computed for the created particle.
  16267. * @param worldMatrix is the world matrix of the particle system
  16268. * @param positionToUpdate is the position vector to update with the result
  16269. * @param particle is the particle we are computed the position for
  16270. * @param isLocal defines if the position should be set in local space
  16271. */
  16272. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16273. /**
  16274. * Clones the current emitter and returns a copy of it
  16275. * @returns the new emitter
  16276. */
  16277. clone(): BoxParticleEmitter;
  16278. /**
  16279. * Called by the GPUParticleSystem to setup the update shader
  16280. * @param effect defines the update shader
  16281. */
  16282. applyToShader(effect: Effect): void;
  16283. /**
  16284. * Returns a string to use to update the GPU particles update shader
  16285. * @returns a string containng the defines string
  16286. */
  16287. getEffectDefines(): string;
  16288. /**
  16289. * Returns the string "BoxParticleEmitter"
  16290. * @returns a string containing the class name
  16291. */
  16292. getClassName(): string;
  16293. /**
  16294. * Serializes the particle system to a JSON object.
  16295. * @returns the JSON object
  16296. */
  16297. serialize(): any;
  16298. /**
  16299. * Parse properties from a JSON object
  16300. * @param serializationObject defines the JSON object
  16301. */
  16302. parse(serializationObject: any): void;
  16303. }
  16304. }
  16305. declare module BABYLON {
  16306. /**
  16307. * Particle emitter emitting particles from the inside of a cone.
  16308. * It emits the particles alongside the cone volume from the base to the particle.
  16309. * The emission direction might be randomized.
  16310. */
  16311. export class ConeParticleEmitter implements IParticleEmitterType {
  16312. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16313. directionRandomizer: number;
  16314. private _radius;
  16315. private _angle;
  16316. private _height;
  16317. /**
  16318. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16319. */
  16320. radiusRange: number;
  16321. /**
  16322. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16323. */
  16324. heightRange: number;
  16325. /**
  16326. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16327. */
  16328. emitFromSpawnPointOnly: boolean;
  16329. /**
  16330. * Gets or sets the radius of the emission cone
  16331. */
  16332. get radius(): number;
  16333. set radius(value: number);
  16334. /**
  16335. * Gets or sets the angle of the emission cone
  16336. */
  16337. get angle(): number;
  16338. set angle(value: number);
  16339. private _buildHeight;
  16340. /**
  16341. * Creates a new instance ConeParticleEmitter
  16342. * @param radius the radius of the emission cone (1 by default)
  16343. * @param angle the cone base angle (PI by default)
  16344. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16345. */
  16346. constructor(radius?: number, angle?: number,
  16347. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16348. directionRandomizer?: number);
  16349. /**
  16350. * Called by the particle System when the direction is computed for the created particle.
  16351. * @param worldMatrix is the world matrix of the particle system
  16352. * @param directionToUpdate is the direction vector to update with the result
  16353. * @param particle is the particle we are computed the direction for
  16354. * @param isLocal defines if the direction should be set in local space
  16355. */
  16356. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16357. /**
  16358. * Called by the particle System when the position is computed for the created particle.
  16359. * @param worldMatrix is the world matrix of the particle system
  16360. * @param positionToUpdate is the position vector to update with the result
  16361. * @param particle is the particle we are computed the position for
  16362. * @param isLocal defines if the position should be set in local space
  16363. */
  16364. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16365. /**
  16366. * Clones the current emitter and returns a copy of it
  16367. * @returns the new emitter
  16368. */
  16369. clone(): ConeParticleEmitter;
  16370. /**
  16371. * Called by the GPUParticleSystem to setup the update shader
  16372. * @param effect defines the update shader
  16373. */
  16374. applyToShader(effect: Effect): void;
  16375. /**
  16376. * Returns a string to use to update the GPU particles update shader
  16377. * @returns a string containng the defines string
  16378. */
  16379. getEffectDefines(): string;
  16380. /**
  16381. * Returns the string "ConeParticleEmitter"
  16382. * @returns a string containing the class name
  16383. */
  16384. getClassName(): string;
  16385. /**
  16386. * Serializes the particle system to a JSON object.
  16387. * @returns the JSON object
  16388. */
  16389. serialize(): any;
  16390. /**
  16391. * Parse properties from a JSON object
  16392. * @param serializationObject defines the JSON object
  16393. */
  16394. parse(serializationObject: any): void;
  16395. }
  16396. }
  16397. declare module BABYLON {
  16398. /**
  16399. * Particle emitter emitting particles from the inside of a cylinder.
  16400. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16401. */
  16402. export class CylinderParticleEmitter implements IParticleEmitterType {
  16403. /**
  16404. * The radius of the emission cylinder.
  16405. */
  16406. radius: number;
  16407. /**
  16408. * The height of the emission cylinder.
  16409. */
  16410. height: number;
  16411. /**
  16412. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16413. */
  16414. radiusRange: number;
  16415. /**
  16416. * How much to randomize the particle direction [0-1].
  16417. */
  16418. directionRandomizer: number;
  16419. /**
  16420. * Creates a new instance CylinderParticleEmitter
  16421. * @param radius the radius of the emission cylinder (1 by default)
  16422. * @param height the height of the emission cylinder (1 by default)
  16423. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16424. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16425. */
  16426. constructor(
  16427. /**
  16428. * The radius of the emission cylinder.
  16429. */
  16430. radius?: number,
  16431. /**
  16432. * The height of the emission cylinder.
  16433. */
  16434. height?: number,
  16435. /**
  16436. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16437. */
  16438. radiusRange?: number,
  16439. /**
  16440. * How much to randomize the particle direction [0-1].
  16441. */
  16442. directionRandomizer?: number);
  16443. /**
  16444. * Called by the particle System when the direction is computed for the created particle.
  16445. * @param worldMatrix is the world matrix of the particle system
  16446. * @param directionToUpdate is the direction vector to update with the result
  16447. * @param particle is the particle we are computed the direction for
  16448. * @param isLocal defines if the direction should be set in local space
  16449. */
  16450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16451. /**
  16452. * Called by the particle System when the position is computed for the created particle.
  16453. * @param worldMatrix is the world matrix of the particle system
  16454. * @param positionToUpdate is the position vector to update with the result
  16455. * @param particle is the particle we are computed the position for
  16456. * @param isLocal defines if the position should be set in local space
  16457. */
  16458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16459. /**
  16460. * Clones the current emitter and returns a copy of it
  16461. * @returns the new emitter
  16462. */
  16463. clone(): CylinderParticleEmitter;
  16464. /**
  16465. * Called by the GPUParticleSystem to setup the update shader
  16466. * @param effect defines the update shader
  16467. */
  16468. applyToShader(effect: Effect): void;
  16469. /**
  16470. * Returns a string to use to update the GPU particles update shader
  16471. * @returns a string containng the defines string
  16472. */
  16473. getEffectDefines(): string;
  16474. /**
  16475. * Returns the string "CylinderParticleEmitter"
  16476. * @returns a string containing the class name
  16477. */
  16478. getClassName(): string;
  16479. /**
  16480. * Serializes the particle system to a JSON object.
  16481. * @returns the JSON object
  16482. */
  16483. serialize(): any;
  16484. /**
  16485. * Parse properties from a JSON object
  16486. * @param serializationObject defines the JSON object
  16487. */
  16488. parse(serializationObject: any): void;
  16489. }
  16490. /**
  16491. * Particle emitter emitting particles from the inside of a cylinder.
  16492. * It emits the particles randomly between two vectors.
  16493. */
  16494. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16495. /**
  16496. * The min limit of the emission direction.
  16497. */
  16498. direction1: Vector3;
  16499. /**
  16500. * The max limit of the emission direction.
  16501. */
  16502. direction2: Vector3;
  16503. /**
  16504. * Creates a new instance CylinderDirectedParticleEmitter
  16505. * @param radius the radius of the emission cylinder (1 by default)
  16506. * @param height the height of the emission cylinder (1 by default)
  16507. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16508. * @param direction1 the min limit of the emission direction (up vector by default)
  16509. * @param direction2 the max limit of the emission direction (up vector by default)
  16510. */
  16511. constructor(radius?: number, height?: number, radiusRange?: number,
  16512. /**
  16513. * The min limit of the emission direction.
  16514. */
  16515. direction1?: Vector3,
  16516. /**
  16517. * The max limit of the emission direction.
  16518. */
  16519. direction2?: Vector3);
  16520. /**
  16521. * Called by the particle System when the direction is computed for the created particle.
  16522. * @param worldMatrix is the world matrix of the particle system
  16523. * @param directionToUpdate is the direction vector to update with the result
  16524. * @param particle is the particle we are computed the direction for
  16525. */
  16526. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16527. /**
  16528. * Clones the current emitter and returns a copy of it
  16529. * @returns the new emitter
  16530. */
  16531. clone(): CylinderDirectedParticleEmitter;
  16532. /**
  16533. * Called by the GPUParticleSystem to setup the update shader
  16534. * @param effect defines the update shader
  16535. */
  16536. applyToShader(effect: Effect): void;
  16537. /**
  16538. * Returns a string to use to update the GPU particles update shader
  16539. * @returns a string containng the defines string
  16540. */
  16541. getEffectDefines(): string;
  16542. /**
  16543. * Returns the string "CylinderDirectedParticleEmitter"
  16544. * @returns a string containing the class name
  16545. */
  16546. getClassName(): string;
  16547. /**
  16548. * Serializes the particle system to a JSON object.
  16549. * @returns the JSON object
  16550. */
  16551. serialize(): any;
  16552. /**
  16553. * Parse properties from a JSON object
  16554. * @param serializationObject defines the JSON object
  16555. */
  16556. parse(serializationObject: any): void;
  16557. }
  16558. }
  16559. declare module BABYLON {
  16560. /**
  16561. * Particle emitter emitting particles from the inside of a hemisphere.
  16562. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16563. */
  16564. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16565. /**
  16566. * The radius of the emission hemisphere.
  16567. */
  16568. radius: number;
  16569. /**
  16570. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16571. */
  16572. radiusRange: number;
  16573. /**
  16574. * How much to randomize the particle direction [0-1].
  16575. */
  16576. directionRandomizer: number;
  16577. /**
  16578. * Creates a new instance HemisphericParticleEmitter
  16579. * @param radius the radius of the emission hemisphere (1 by default)
  16580. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16581. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16582. */
  16583. constructor(
  16584. /**
  16585. * The radius of the emission hemisphere.
  16586. */
  16587. radius?: number,
  16588. /**
  16589. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16590. */
  16591. radiusRange?: number,
  16592. /**
  16593. * How much to randomize the particle direction [0-1].
  16594. */
  16595. directionRandomizer?: number);
  16596. /**
  16597. * Called by the particle System when the direction is computed for the created particle.
  16598. * @param worldMatrix is the world matrix of the particle system
  16599. * @param directionToUpdate is the direction vector to update with the result
  16600. * @param particle is the particle we are computed the direction for
  16601. * @param isLocal defines if the direction should be set in local space
  16602. */
  16603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16604. /**
  16605. * Called by the particle System when the position is computed for the created particle.
  16606. * @param worldMatrix is the world matrix of the particle system
  16607. * @param positionToUpdate is the position vector to update with the result
  16608. * @param particle is the particle we are computed the position for
  16609. * @param isLocal defines if the position should be set in local space
  16610. */
  16611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16612. /**
  16613. * Clones the current emitter and returns a copy of it
  16614. * @returns the new emitter
  16615. */
  16616. clone(): HemisphericParticleEmitter;
  16617. /**
  16618. * Called by the GPUParticleSystem to setup the update shader
  16619. * @param effect defines the update shader
  16620. */
  16621. applyToShader(effect: Effect): void;
  16622. /**
  16623. * Returns a string to use to update the GPU particles update shader
  16624. * @returns a string containng the defines string
  16625. */
  16626. getEffectDefines(): string;
  16627. /**
  16628. * Returns the string "HemisphericParticleEmitter"
  16629. * @returns a string containing the class name
  16630. */
  16631. getClassName(): string;
  16632. /**
  16633. * Serializes the particle system to a JSON object.
  16634. * @returns the JSON object
  16635. */
  16636. serialize(): any;
  16637. /**
  16638. * Parse properties from a JSON object
  16639. * @param serializationObject defines the JSON object
  16640. */
  16641. parse(serializationObject: any): void;
  16642. }
  16643. }
  16644. declare module BABYLON {
  16645. /**
  16646. * Particle emitter emitting particles from a point.
  16647. * It emits the particles randomly between 2 given directions.
  16648. */
  16649. export class PointParticleEmitter implements IParticleEmitterType {
  16650. /**
  16651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16652. */
  16653. direction1: Vector3;
  16654. /**
  16655. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16656. */
  16657. direction2: Vector3;
  16658. /**
  16659. * Creates a new instance PointParticleEmitter
  16660. */
  16661. constructor();
  16662. /**
  16663. * Called by the particle System when the direction is computed for the created particle.
  16664. * @param worldMatrix is the world matrix of the particle system
  16665. * @param directionToUpdate is the direction vector to update with the result
  16666. * @param particle is the particle we are computed the direction for
  16667. * @param isLocal defines if the direction should be set in local space
  16668. */
  16669. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16670. /**
  16671. * Called by the particle System when the position is computed for the created particle.
  16672. * @param worldMatrix is the world matrix of the particle system
  16673. * @param positionToUpdate is the position vector to update with the result
  16674. * @param particle is the particle we are computed the position for
  16675. * @param isLocal defines if the position should be set in local space
  16676. */
  16677. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16678. /**
  16679. * Clones the current emitter and returns a copy of it
  16680. * @returns the new emitter
  16681. */
  16682. clone(): PointParticleEmitter;
  16683. /**
  16684. * Called by the GPUParticleSystem to setup the update shader
  16685. * @param effect defines the update shader
  16686. */
  16687. applyToShader(effect: Effect): void;
  16688. /**
  16689. * Returns a string to use to update the GPU particles update shader
  16690. * @returns a string containng the defines string
  16691. */
  16692. getEffectDefines(): string;
  16693. /**
  16694. * Returns the string "PointParticleEmitter"
  16695. * @returns a string containing the class name
  16696. */
  16697. getClassName(): string;
  16698. /**
  16699. * Serializes the particle system to a JSON object.
  16700. * @returns the JSON object
  16701. */
  16702. serialize(): any;
  16703. /**
  16704. * Parse properties from a JSON object
  16705. * @param serializationObject defines the JSON object
  16706. */
  16707. parse(serializationObject: any): void;
  16708. }
  16709. }
  16710. declare module BABYLON {
  16711. /**
  16712. * Particle emitter emitting particles from the inside of a sphere.
  16713. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16714. */
  16715. export class SphereParticleEmitter implements IParticleEmitterType {
  16716. /**
  16717. * The radius of the emission sphere.
  16718. */
  16719. radius: number;
  16720. /**
  16721. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16722. */
  16723. radiusRange: number;
  16724. /**
  16725. * How much to randomize the particle direction [0-1].
  16726. */
  16727. directionRandomizer: number;
  16728. /**
  16729. * Creates a new instance SphereParticleEmitter
  16730. * @param radius the radius of the emission sphere (1 by default)
  16731. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16732. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16733. */
  16734. constructor(
  16735. /**
  16736. * The radius of the emission sphere.
  16737. */
  16738. radius?: number,
  16739. /**
  16740. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16741. */
  16742. radiusRange?: number,
  16743. /**
  16744. * How much to randomize the particle direction [0-1].
  16745. */
  16746. directionRandomizer?: number);
  16747. /**
  16748. * Called by the particle System when the direction is computed for the created particle.
  16749. * @param worldMatrix is the world matrix of the particle system
  16750. * @param directionToUpdate is the direction vector to update with the result
  16751. * @param particle is the particle we are computed the direction for
  16752. * @param isLocal defines if the direction should be set in local space
  16753. */
  16754. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16755. /**
  16756. * Called by the particle System when the position is computed for the created particle.
  16757. * @param worldMatrix is the world matrix of the particle system
  16758. * @param positionToUpdate is the position vector to update with the result
  16759. * @param particle is the particle we are computed the position for
  16760. * @param isLocal defines if the position should be set in local space
  16761. */
  16762. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16763. /**
  16764. * Clones the current emitter and returns a copy of it
  16765. * @returns the new emitter
  16766. */
  16767. clone(): SphereParticleEmitter;
  16768. /**
  16769. * Called by the GPUParticleSystem to setup the update shader
  16770. * @param effect defines the update shader
  16771. */
  16772. applyToShader(effect: Effect): void;
  16773. /**
  16774. * Returns a string to use to update the GPU particles update shader
  16775. * @returns a string containng the defines string
  16776. */
  16777. getEffectDefines(): string;
  16778. /**
  16779. * Returns the string "SphereParticleEmitter"
  16780. * @returns a string containing the class name
  16781. */
  16782. getClassName(): string;
  16783. /**
  16784. * Serializes the particle system to a JSON object.
  16785. * @returns the JSON object
  16786. */
  16787. serialize(): any;
  16788. /**
  16789. * Parse properties from a JSON object
  16790. * @param serializationObject defines the JSON object
  16791. */
  16792. parse(serializationObject: any): void;
  16793. }
  16794. /**
  16795. * Particle emitter emitting particles from the inside of a sphere.
  16796. * It emits the particles randomly between two vectors.
  16797. */
  16798. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16799. /**
  16800. * The min limit of the emission direction.
  16801. */
  16802. direction1: Vector3;
  16803. /**
  16804. * The max limit of the emission direction.
  16805. */
  16806. direction2: Vector3;
  16807. /**
  16808. * Creates a new instance SphereDirectedParticleEmitter
  16809. * @param radius the radius of the emission sphere (1 by default)
  16810. * @param direction1 the min limit of the emission direction (up vector by default)
  16811. * @param direction2 the max limit of the emission direction (up vector by default)
  16812. */
  16813. constructor(radius?: number,
  16814. /**
  16815. * The min limit of the emission direction.
  16816. */
  16817. direction1?: Vector3,
  16818. /**
  16819. * The max limit of the emission direction.
  16820. */
  16821. direction2?: Vector3);
  16822. /**
  16823. * Called by the particle System when the direction is computed for the created particle.
  16824. * @param worldMatrix is the world matrix of the particle system
  16825. * @param directionToUpdate is the direction vector to update with the result
  16826. * @param particle is the particle we are computed the direction for
  16827. */
  16828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16829. /**
  16830. * Clones the current emitter and returns a copy of it
  16831. * @returns the new emitter
  16832. */
  16833. clone(): SphereDirectedParticleEmitter;
  16834. /**
  16835. * Called by the GPUParticleSystem to setup the update shader
  16836. * @param effect defines the update shader
  16837. */
  16838. applyToShader(effect: Effect): void;
  16839. /**
  16840. * Returns a string to use to update the GPU particles update shader
  16841. * @returns a string containng the defines string
  16842. */
  16843. getEffectDefines(): string;
  16844. /**
  16845. * Returns the string "SphereDirectedParticleEmitter"
  16846. * @returns a string containing the class name
  16847. */
  16848. getClassName(): string;
  16849. /**
  16850. * Serializes the particle system to a JSON object.
  16851. * @returns the JSON object
  16852. */
  16853. serialize(): any;
  16854. /**
  16855. * Parse properties from a JSON object
  16856. * @param serializationObject defines the JSON object
  16857. */
  16858. parse(serializationObject: any): void;
  16859. }
  16860. }
  16861. declare module BABYLON {
  16862. /**
  16863. * Particle emitter emitting particles from a custom list of positions.
  16864. */
  16865. export class CustomParticleEmitter implements IParticleEmitterType {
  16866. /**
  16867. * Gets or sets the position generator that will create the inital position of each particle.
  16868. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16869. */
  16870. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16871. /**
  16872. * Gets or sets the destination generator that will create the final destination of each particle.
  16873. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16874. */
  16875. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16876. /**
  16877. * Creates a new instance CustomParticleEmitter
  16878. */
  16879. constructor();
  16880. /**
  16881. * Called by the particle System when the direction is computed for the created particle.
  16882. * @param worldMatrix is the world matrix of the particle system
  16883. * @param directionToUpdate is the direction vector to update with the result
  16884. * @param particle is the particle we are computed the direction for
  16885. * @param isLocal defines if the direction should be set in local space
  16886. */
  16887. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16888. /**
  16889. * Called by the particle System when the position is computed for the created particle.
  16890. * @param worldMatrix is the world matrix of the particle system
  16891. * @param positionToUpdate is the position vector to update with the result
  16892. * @param particle is the particle we are computed the position for
  16893. * @param isLocal defines if the position should be set in local space
  16894. */
  16895. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16896. /**
  16897. * Clones the current emitter and returns a copy of it
  16898. * @returns the new emitter
  16899. */
  16900. clone(): CustomParticleEmitter;
  16901. /**
  16902. * Called by the GPUParticleSystem to setup the update shader
  16903. * @param effect defines the update shader
  16904. */
  16905. applyToShader(effect: Effect): void;
  16906. /**
  16907. * Returns a string to use to update the GPU particles update shader
  16908. * @returns a string containng the defines string
  16909. */
  16910. getEffectDefines(): string;
  16911. /**
  16912. * Returns the string "PointParticleEmitter"
  16913. * @returns a string containing the class name
  16914. */
  16915. getClassName(): string;
  16916. /**
  16917. * Serializes the particle system to a JSON object.
  16918. * @returns the JSON object
  16919. */
  16920. serialize(): any;
  16921. /**
  16922. * Parse properties from a JSON object
  16923. * @param serializationObject defines the JSON object
  16924. */
  16925. parse(serializationObject: any): void;
  16926. }
  16927. }
  16928. declare module BABYLON {
  16929. /**
  16930. * Particle emitter emitting particles from the inside of a box.
  16931. * It emits the particles randomly between 2 given directions.
  16932. */
  16933. export class MeshParticleEmitter implements IParticleEmitterType {
  16934. private _indices;
  16935. private _positions;
  16936. private _normals;
  16937. private _storedNormal;
  16938. private _mesh;
  16939. /**
  16940. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16941. */
  16942. direction1: Vector3;
  16943. /**
  16944. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16945. */
  16946. direction2: Vector3;
  16947. /**
  16948. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16949. */
  16950. useMeshNormalsForDirection: boolean;
  16951. /** Defines the mesh to use as source */
  16952. get mesh(): Nullable<AbstractMesh>;
  16953. set mesh(value: Nullable<AbstractMesh>);
  16954. /**
  16955. * Creates a new instance MeshParticleEmitter
  16956. * @param mesh defines the mesh to use as source
  16957. */
  16958. constructor(mesh?: Nullable<AbstractMesh>);
  16959. /**
  16960. * Called by the particle System when the direction is computed for the created particle.
  16961. * @param worldMatrix is the world matrix of the particle system
  16962. * @param directionToUpdate is the direction vector to update with the result
  16963. * @param particle is the particle we are computed the direction for
  16964. * @param isLocal defines if the direction should be set in local space
  16965. */
  16966. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16967. /**
  16968. * Called by the particle System when the position is computed for the created particle.
  16969. * @param worldMatrix is the world matrix of the particle system
  16970. * @param positionToUpdate is the position vector to update with the result
  16971. * @param particle is the particle we are computed the position for
  16972. * @param isLocal defines if the position should be set in local space
  16973. */
  16974. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16975. /**
  16976. * Clones the current emitter and returns a copy of it
  16977. * @returns the new emitter
  16978. */
  16979. clone(): MeshParticleEmitter;
  16980. /**
  16981. * Called by the GPUParticleSystem to setup the update shader
  16982. * @param effect defines the update shader
  16983. */
  16984. applyToShader(effect: Effect): void;
  16985. /**
  16986. * Returns a string to use to update the GPU particles update shader
  16987. * @returns a string containng the defines string
  16988. */
  16989. getEffectDefines(): string;
  16990. /**
  16991. * Returns the string "BoxParticleEmitter"
  16992. * @returns a string containing the class name
  16993. */
  16994. getClassName(): string;
  16995. /**
  16996. * Serializes the particle system to a JSON object.
  16997. * @returns the JSON object
  16998. */
  16999. serialize(): any;
  17000. /**
  17001. * Parse properties from a JSON object
  17002. * @param serializationObject defines the JSON object
  17003. * @param scene defines the hosting scene
  17004. */
  17005. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17006. }
  17007. }
  17008. declare module BABYLON {
  17009. /**
  17010. * Interface representing a particle system in Babylon.js.
  17011. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17012. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17013. */
  17014. export interface IParticleSystem {
  17015. /**
  17016. * List of animations used by the particle system.
  17017. */
  17018. animations: Animation[];
  17019. /**
  17020. * The id of the Particle system.
  17021. */
  17022. id: string;
  17023. /**
  17024. * The name of the Particle system.
  17025. */
  17026. name: string;
  17027. /**
  17028. * The emitter represents the Mesh or position we are attaching the particle system to.
  17029. */
  17030. emitter: Nullable<AbstractMesh | Vector3>;
  17031. /**
  17032. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17033. */
  17034. isBillboardBased: boolean;
  17035. /**
  17036. * The rendering group used by the Particle system to chose when to render.
  17037. */
  17038. renderingGroupId: number;
  17039. /**
  17040. * The layer mask we are rendering the particles through.
  17041. */
  17042. layerMask: number;
  17043. /**
  17044. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17045. */
  17046. updateSpeed: number;
  17047. /**
  17048. * The amount of time the particle system is running (depends of the overall update speed).
  17049. */
  17050. targetStopDuration: number;
  17051. /**
  17052. * The texture used to render each particle. (this can be a spritesheet)
  17053. */
  17054. particleTexture: Nullable<BaseTexture>;
  17055. /**
  17056. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17057. */
  17058. blendMode: number;
  17059. /**
  17060. * Minimum life time of emitting particles.
  17061. */
  17062. minLifeTime: number;
  17063. /**
  17064. * Maximum life time of emitting particles.
  17065. */
  17066. maxLifeTime: number;
  17067. /**
  17068. * Minimum Size of emitting particles.
  17069. */
  17070. minSize: number;
  17071. /**
  17072. * Maximum Size of emitting particles.
  17073. */
  17074. maxSize: number;
  17075. /**
  17076. * Minimum scale of emitting particles on X axis.
  17077. */
  17078. minScaleX: number;
  17079. /**
  17080. * Maximum scale of emitting particles on X axis.
  17081. */
  17082. maxScaleX: number;
  17083. /**
  17084. * Minimum scale of emitting particles on Y axis.
  17085. */
  17086. minScaleY: number;
  17087. /**
  17088. * Maximum scale of emitting particles on Y axis.
  17089. */
  17090. maxScaleY: number;
  17091. /**
  17092. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17093. */
  17094. color1: Color4;
  17095. /**
  17096. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17097. */
  17098. color2: Color4;
  17099. /**
  17100. * Color the particle will have at the end of its lifetime.
  17101. */
  17102. colorDead: Color4;
  17103. /**
  17104. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17105. */
  17106. emitRate: number;
  17107. /**
  17108. * You can use gravity if you want to give an orientation to your particles.
  17109. */
  17110. gravity: Vector3;
  17111. /**
  17112. * Minimum power of emitting particles.
  17113. */
  17114. minEmitPower: number;
  17115. /**
  17116. * Maximum power of emitting particles.
  17117. */
  17118. maxEmitPower: number;
  17119. /**
  17120. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17121. */
  17122. minAngularSpeed: number;
  17123. /**
  17124. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17125. */
  17126. maxAngularSpeed: number;
  17127. /**
  17128. * Gets or sets the minimal initial rotation in radians.
  17129. */
  17130. minInitialRotation: number;
  17131. /**
  17132. * Gets or sets the maximal initial rotation in radians.
  17133. */
  17134. maxInitialRotation: number;
  17135. /**
  17136. * The particle emitter type defines the emitter used by the particle system.
  17137. * It can be for example box, sphere, or cone...
  17138. */
  17139. particleEmitterType: Nullable<IParticleEmitterType>;
  17140. /**
  17141. * Defines the delay in milliseconds before starting the system (0 by default)
  17142. */
  17143. startDelay: number;
  17144. /**
  17145. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  17146. */
  17147. preWarmCycles: number;
  17148. /**
  17149. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17150. */
  17151. preWarmStepOffset: number;
  17152. /**
  17153. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  17154. */
  17155. spriteCellChangeSpeed: number;
  17156. /**
  17157. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17158. */
  17159. startSpriteCellID: number;
  17160. /**
  17161. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17162. */
  17163. endSpriteCellID: number;
  17164. /**
  17165. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17166. */
  17167. spriteCellWidth: number;
  17168. /**
  17169. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17170. */
  17171. spriteCellHeight: number;
  17172. /**
  17173. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17174. */
  17175. spriteRandomStartCell: boolean;
  17176. /**
  17177. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17178. */
  17179. isAnimationSheetEnabled: boolean;
  17180. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17181. translationPivot: Vector2;
  17182. /**
  17183. * Gets or sets a texture used to add random noise to particle positions
  17184. */
  17185. noiseTexture: Nullable<BaseTexture>;
  17186. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17187. noiseStrength: Vector3;
  17188. /**
  17189. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17190. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17191. */
  17192. billboardMode: number;
  17193. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17194. limitVelocityDamping: number;
  17195. /**
  17196. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17197. */
  17198. beginAnimationOnStart: boolean;
  17199. /**
  17200. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17201. */
  17202. beginAnimationFrom: number;
  17203. /**
  17204. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17205. */
  17206. beginAnimationTo: number;
  17207. /**
  17208. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17209. */
  17210. beginAnimationLoop: boolean;
  17211. /**
  17212. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17213. */
  17214. disposeOnStop: boolean;
  17215. /**
  17216. * Specifies if the particles are updated in emitter local space or world space
  17217. */
  17218. isLocal: boolean;
  17219. /** Snippet ID if the particle system was created from the snippet server */
  17220. snippetId: string;
  17221. /** Gets or sets a matrix to use to compute projection */
  17222. defaultProjectionMatrix: Matrix;
  17223. /**
  17224. * Gets the maximum number of particles active at the same time.
  17225. * @returns The max number of active particles.
  17226. */
  17227. getCapacity(): number;
  17228. /**
  17229. * Gets the number of particles active at the same time.
  17230. * @returns The number of active particles.
  17231. */
  17232. getActiveCount(): number;
  17233. /**
  17234. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17235. * @returns True if it has been started, otherwise false.
  17236. */
  17237. isStarted(): boolean;
  17238. /**
  17239. * Animates the particle system for this frame.
  17240. */
  17241. animate(): void;
  17242. /**
  17243. * Renders the particle system in its current state.
  17244. * @returns the current number of particles
  17245. */
  17246. render(): number;
  17247. /**
  17248. * Dispose the particle system and frees its associated resources.
  17249. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17250. */
  17251. dispose(disposeTexture?: boolean): void;
  17252. /**
  17253. * An event triggered when the system is disposed
  17254. */
  17255. onDisposeObservable: Observable<IParticleSystem>;
  17256. /**
  17257. * An event triggered when the system is stopped
  17258. */
  17259. onStoppedObservable: Observable<IParticleSystem>;
  17260. /**
  17261. * Clones the particle system.
  17262. * @param name The name of the cloned object
  17263. * @param newEmitter The new emitter to use
  17264. * @returns the cloned particle system
  17265. */
  17266. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17267. /**
  17268. * Serializes the particle system to a JSON object
  17269. * @param serializeTexture defines if the texture must be serialized as well
  17270. * @returns the JSON object
  17271. */
  17272. serialize(serializeTexture: boolean): any;
  17273. /**
  17274. * Rebuild the particle system
  17275. */
  17276. rebuild(): void;
  17277. /** Force the system to rebuild all gradients that need to be resync */
  17278. forceRefreshGradients(): void;
  17279. /**
  17280. * Starts the particle system and begins to emit
  17281. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17282. */
  17283. start(delay?: number): void;
  17284. /**
  17285. * Stops the particle system.
  17286. */
  17287. stop(): void;
  17288. /**
  17289. * Remove all active particles
  17290. */
  17291. reset(): void;
  17292. /**
  17293. * Gets a boolean indicating that the system is stopping
  17294. * @returns true if the system is currently stopping
  17295. */
  17296. isStopping(): boolean;
  17297. /**
  17298. * Is this system ready to be used/rendered
  17299. * @return true if the system is ready
  17300. */
  17301. isReady(): boolean;
  17302. /**
  17303. * Returns the string "ParticleSystem"
  17304. * @returns a string containing the class name
  17305. */
  17306. getClassName(): string;
  17307. /**
  17308. * Gets the custom effect used to render the particles
  17309. * @param blendMode Blend mode for which the effect should be retrieved
  17310. * @returns The effect
  17311. */
  17312. getCustomEffect(blendMode: number): Nullable<Effect>;
  17313. /**
  17314. * Sets the custom effect used to render the particles
  17315. * @param effect The effect to set
  17316. * @param blendMode Blend mode for which the effect should be set
  17317. */
  17318. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17319. /**
  17320. * Fill the defines array according to the current settings of the particle system
  17321. * @param defines Array to be updated
  17322. * @param blendMode blend mode to take into account when updating the array
  17323. */
  17324. fillDefines(defines: Array<string>, blendMode: number): void;
  17325. /**
  17326. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17327. * @param uniforms Uniforms array to fill
  17328. * @param attributes Attributes array to fill
  17329. * @param samplers Samplers array to fill
  17330. */
  17331. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17332. /**
  17333. * Observable that will be called just before the particles are drawn
  17334. */
  17335. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17336. /**
  17337. * Gets the name of the particle vertex shader
  17338. */
  17339. vertexShaderName: string;
  17340. /**
  17341. * Adds a new color gradient
  17342. * @param gradient defines the gradient to use (between 0 and 1)
  17343. * @param color1 defines the color to affect to the specified gradient
  17344. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17345. * @returns the current particle system
  17346. */
  17347. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17348. /**
  17349. * Remove a specific color gradient
  17350. * @param gradient defines the gradient to remove
  17351. * @returns the current particle system
  17352. */
  17353. removeColorGradient(gradient: number): IParticleSystem;
  17354. /**
  17355. * Adds a new size gradient
  17356. * @param gradient defines the gradient to use (between 0 and 1)
  17357. * @param factor defines the size factor to affect to the specified gradient
  17358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17359. * @returns the current particle system
  17360. */
  17361. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17362. /**
  17363. * Remove a specific size gradient
  17364. * @param gradient defines the gradient to remove
  17365. * @returns the current particle system
  17366. */
  17367. removeSizeGradient(gradient: number): IParticleSystem;
  17368. /**
  17369. * Gets the current list of color gradients.
  17370. * You must use addColorGradient and removeColorGradient to udpate this list
  17371. * @returns the list of color gradients
  17372. */
  17373. getColorGradients(): Nullable<Array<ColorGradient>>;
  17374. /**
  17375. * Gets the current list of size gradients.
  17376. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17377. * @returns the list of size gradients
  17378. */
  17379. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17380. /**
  17381. * Gets the current list of angular speed gradients.
  17382. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17383. * @returns the list of angular speed gradients
  17384. */
  17385. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17386. /**
  17387. * Adds a new angular speed gradient
  17388. * @param gradient defines the gradient to use (between 0 and 1)
  17389. * @param factor defines the angular speed to affect to the specified gradient
  17390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17391. * @returns the current particle system
  17392. */
  17393. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17394. /**
  17395. * Remove a specific angular speed gradient
  17396. * @param gradient defines the gradient to remove
  17397. * @returns the current particle system
  17398. */
  17399. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17400. /**
  17401. * Gets the current list of velocity gradients.
  17402. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17403. * @returns the list of velocity gradients
  17404. */
  17405. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17406. /**
  17407. * Adds a new velocity gradient
  17408. * @param gradient defines the gradient to use (between 0 and 1)
  17409. * @param factor defines the velocity to affect to the specified gradient
  17410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17411. * @returns the current particle system
  17412. */
  17413. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17414. /**
  17415. * Remove a specific velocity gradient
  17416. * @param gradient defines the gradient to remove
  17417. * @returns the current particle system
  17418. */
  17419. removeVelocityGradient(gradient: number): IParticleSystem;
  17420. /**
  17421. * Gets the current list of limit velocity gradients.
  17422. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17423. * @returns the list of limit velocity gradients
  17424. */
  17425. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17426. /**
  17427. * Adds a new limit velocity gradient
  17428. * @param gradient defines the gradient to use (between 0 and 1)
  17429. * @param factor defines the limit velocity to affect to the specified gradient
  17430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17431. * @returns the current particle system
  17432. */
  17433. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17434. /**
  17435. * Remove a specific limit velocity gradient
  17436. * @param gradient defines the gradient to remove
  17437. * @returns the current particle system
  17438. */
  17439. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17440. /**
  17441. * Adds a new drag gradient
  17442. * @param gradient defines the gradient to use (between 0 and 1)
  17443. * @param factor defines the drag to affect to the specified gradient
  17444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17445. * @returns the current particle system
  17446. */
  17447. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17448. /**
  17449. * Remove a specific drag gradient
  17450. * @param gradient defines the gradient to remove
  17451. * @returns the current particle system
  17452. */
  17453. removeDragGradient(gradient: number): IParticleSystem;
  17454. /**
  17455. * Gets the current list of drag gradients.
  17456. * You must use addDragGradient and removeDragGradient to udpate this list
  17457. * @returns the list of drag gradients
  17458. */
  17459. getDragGradients(): Nullable<Array<FactorGradient>>;
  17460. /**
  17461. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17462. * @param gradient defines the gradient to use (between 0 and 1)
  17463. * @param factor defines the emit rate to affect to the specified gradient
  17464. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17465. * @returns the current particle system
  17466. */
  17467. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17468. /**
  17469. * Remove a specific emit rate gradient
  17470. * @param gradient defines the gradient to remove
  17471. * @returns the current particle system
  17472. */
  17473. removeEmitRateGradient(gradient: number): IParticleSystem;
  17474. /**
  17475. * Gets the current list of emit rate gradients.
  17476. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17477. * @returns the list of emit rate gradients
  17478. */
  17479. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17480. /**
  17481. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17482. * @param gradient defines the gradient to use (between 0 and 1)
  17483. * @param factor defines the start size to affect to the specified gradient
  17484. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17485. * @returns the current particle system
  17486. */
  17487. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17488. /**
  17489. * Remove a specific start size gradient
  17490. * @param gradient defines the gradient to remove
  17491. * @returns the current particle system
  17492. */
  17493. removeStartSizeGradient(gradient: number): IParticleSystem;
  17494. /**
  17495. * Gets the current list of start size gradients.
  17496. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17497. * @returns the list of start size gradients
  17498. */
  17499. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17500. /**
  17501. * Adds a new life time gradient
  17502. * @param gradient defines the gradient to use (between 0 and 1)
  17503. * @param factor defines the life time factor to affect to the specified gradient
  17504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17505. * @returns the current particle system
  17506. */
  17507. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17508. /**
  17509. * Remove a specific life time gradient
  17510. * @param gradient defines the gradient to remove
  17511. * @returns the current particle system
  17512. */
  17513. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17514. /**
  17515. * Gets the current list of life time gradients.
  17516. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17517. * @returns the list of life time gradients
  17518. */
  17519. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17520. /**
  17521. * Gets the current list of color gradients.
  17522. * You must use addColorGradient and removeColorGradient to udpate this list
  17523. * @returns the list of color gradients
  17524. */
  17525. getColorGradients(): Nullable<Array<ColorGradient>>;
  17526. /**
  17527. * Adds a new ramp gradient used to remap particle colors
  17528. * @param gradient defines the gradient to use (between 0 and 1)
  17529. * @param color defines the color to affect to the specified gradient
  17530. * @returns the current particle system
  17531. */
  17532. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17533. /**
  17534. * Gets the current list of ramp gradients.
  17535. * You must use addRampGradient and removeRampGradient to udpate this list
  17536. * @returns the list of ramp gradients
  17537. */
  17538. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17539. /** Gets or sets a boolean indicating that ramp gradients must be used
  17540. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17541. */
  17542. useRampGradients: boolean;
  17543. /**
  17544. * Adds a new color remap gradient
  17545. * @param gradient defines the gradient to use (between 0 and 1)
  17546. * @param min defines the color remap minimal range
  17547. * @param max defines the color remap maximal range
  17548. * @returns the current particle system
  17549. */
  17550. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17551. /**
  17552. * Gets the current list of color remap gradients.
  17553. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17554. * @returns the list of color remap gradients
  17555. */
  17556. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17557. /**
  17558. * Adds a new alpha remap gradient
  17559. * @param gradient defines the gradient to use (between 0 and 1)
  17560. * @param min defines the alpha remap minimal range
  17561. * @param max defines the alpha remap maximal range
  17562. * @returns the current particle system
  17563. */
  17564. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17565. /**
  17566. * Gets the current list of alpha remap gradients.
  17567. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17568. * @returns the list of alpha remap gradients
  17569. */
  17570. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17571. /**
  17572. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17573. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17574. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17575. * @returns the emitter
  17576. */
  17577. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17578. /**
  17579. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17580. * @param radius The radius of the hemisphere to emit from
  17581. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17582. * @returns the emitter
  17583. */
  17584. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17585. /**
  17586. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17587. * @param radius The radius of the sphere to emit from
  17588. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17589. * @returns the emitter
  17590. */
  17591. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17592. /**
  17593. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17594. * @param radius The radius of the sphere to emit from
  17595. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17596. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17597. * @returns the emitter
  17598. */
  17599. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17600. /**
  17601. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17602. * @param radius The radius of the emission cylinder
  17603. * @param height The height of the emission cylinder
  17604. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17605. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17606. * @returns the emitter
  17607. */
  17608. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17609. /**
  17610. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17611. * @param radius The radius of the cylinder to emit from
  17612. * @param height The height of the emission cylinder
  17613. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17614. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17615. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17616. * @returns the emitter
  17617. */
  17618. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17619. /**
  17620. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17621. * @param radius The radius of the cone to emit from
  17622. * @param angle The base angle of the cone
  17623. * @returns the emitter
  17624. */
  17625. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17626. /**
  17627. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17628. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17629. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17630. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17631. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17632. * @returns the emitter
  17633. */
  17634. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17635. /**
  17636. * Get hosting scene
  17637. * @returns the scene
  17638. */
  17639. getScene(): Nullable<Scene>;
  17640. }
  17641. }
  17642. declare module BABYLON {
  17643. /**
  17644. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17645. */
  17646. export class ColorSplitterBlock extends NodeMaterialBlock {
  17647. /**
  17648. * Create a new ColorSplitterBlock
  17649. * @param name defines the block name
  17650. */
  17651. constructor(name: string);
  17652. /**
  17653. * Gets the current class name
  17654. * @returns the class name
  17655. */
  17656. getClassName(): string;
  17657. /**
  17658. * Gets the rgba component (input)
  17659. */
  17660. get rgba(): NodeMaterialConnectionPoint;
  17661. /**
  17662. * Gets the rgb component (input)
  17663. */
  17664. get rgbIn(): NodeMaterialConnectionPoint;
  17665. /**
  17666. * Gets the rgb component (output)
  17667. */
  17668. get rgbOut(): NodeMaterialConnectionPoint;
  17669. /**
  17670. * Gets the r component (output)
  17671. */
  17672. get r(): NodeMaterialConnectionPoint;
  17673. /**
  17674. * Gets the g component (output)
  17675. */
  17676. get g(): NodeMaterialConnectionPoint;
  17677. /**
  17678. * Gets the b component (output)
  17679. */
  17680. get b(): NodeMaterialConnectionPoint;
  17681. /**
  17682. * Gets the a component (output)
  17683. */
  17684. get a(): NodeMaterialConnectionPoint;
  17685. protected _inputRename(name: string): string;
  17686. protected _outputRename(name: string): string;
  17687. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17688. }
  17689. }
  17690. declare module BABYLON {
  17691. /**
  17692. * Operations supported by the Trigonometry block
  17693. */
  17694. export enum TrigonometryBlockOperations {
  17695. /** Cos */
  17696. Cos = 0,
  17697. /** Sin */
  17698. Sin = 1,
  17699. /** Abs */
  17700. Abs = 2,
  17701. /** Exp */
  17702. Exp = 3,
  17703. /** Exp2 */
  17704. Exp2 = 4,
  17705. /** Round */
  17706. Round = 5,
  17707. /** Floor */
  17708. Floor = 6,
  17709. /** Ceiling */
  17710. Ceiling = 7,
  17711. /** Square root */
  17712. Sqrt = 8,
  17713. /** Log */
  17714. Log = 9,
  17715. /** Tangent */
  17716. Tan = 10,
  17717. /** Arc tangent */
  17718. ArcTan = 11,
  17719. /** Arc cosinus */
  17720. ArcCos = 12,
  17721. /** Arc sinus */
  17722. ArcSin = 13,
  17723. /** Fraction */
  17724. Fract = 14,
  17725. /** Sign */
  17726. Sign = 15,
  17727. /** To radians (from degrees) */
  17728. Radians = 16,
  17729. /** To degrees (from radians) */
  17730. Degrees = 17
  17731. }
  17732. /**
  17733. * Block used to apply trigonometry operation to floats
  17734. */
  17735. export class TrigonometryBlock extends NodeMaterialBlock {
  17736. /**
  17737. * Gets or sets the operation applied by the block
  17738. */
  17739. operation: TrigonometryBlockOperations;
  17740. /**
  17741. * Creates a new TrigonometryBlock
  17742. * @param name defines the block name
  17743. */
  17744. constructor(name: string);
  17745. /**
  17746. * Gets the current class name
  17747. * @returns the class name
  17748. */
  17749. getClassName(): string;
  17750. /**
  17751. * Gets the input component
  17752. */
  17753. get input(): NodeMaterialConnectionPoint;
  17754. /**
  17755. * Gets the output component
  17756. */
  17757. get output(): NodeMaterialConnectionPoint;
  17758. protected _buildBlock(state: NodeMaterialBuildState): this;
  17759. serialize(): any;
  17760. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17761. protected _dumpPropertiesCode(): string;
  17762. }
  17763. }
  17764. declare module BABYLON {
  17765. /**
  17766. * Interface used to configure the node material editor
  17767. */
  17768. export interface INodeMaterialEditorOptions {
  17769. /** Define the URl to load node editor script */
  17770. editorURL?: string;
  17771. }
  17772. /** @hidden */
  17773. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17774. NORMAL: boolean;
  17775. TANGENT: boolean;
  17776. UV1: boolean;
  17777. /** BONES */
  17778. NUM_BONE_INFLUENCERS: number;
  17779. BonesPerMesh: number;
  17780. BONETEXTURE: boolean;
  17781. /** MORPH TARGETS */
  17782. MORPHTARGETS: boolean;
  17783. MORPHTARGETS_NORMAL: boolean;
  17784. MORPHTARGETS_TANGENT: boolean;
  17785. MORPHTARGETS_UV: boolean;
  17786. NUM_MORPH_INFLUENCERS: number;
  17787. /** IMAGE PROCESSING */
  17788. IMAGEPROCESSING: boolean;
  17789. VIGNETTE: boolean;
  17790. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17791. VIGNETTEBLENDMODEOPAQUE: boolean;
  17792. TONEMAPPING: boolean;
  17793. TONEMAPPING_ACES: boolean;
  17794. CONTRAST: boolean;
  17795. EXPOSURE: boolean;
  17796. COLORCURVES: boolean;
  17797. COLORGRADING: boolean;
  17798. COLORGRADING3D: boolean;
  17799. SAMPLER3DGREENDEPTH: boolean;
  17800. SAMPLER3DBGRMAP: boolean;
  17801. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17802. /** MISC. */
  17803. BUMPDIRECTUV: number;
  17804. constructor();
  17805. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17806. }
  17807. /**
  17808. * Class used to configure NodeMaterial
  17809. */
  17810. export interface INodeMaterialOptions {
  17811. /**
  17812. * Defines if blocks should emit comments
  17813. */
  17814. emitComments: boolean;
  17815. }
  17816. /**
  17817. * Class used to create a node based material built by assembling shader blocks
  17818. */
  17819. export class NodeMaterial extends PushMaterial {
  17820. private static _BuildIdGenerator;
  17821. private _options;
  17822. private _vertexCompilationState;
  17823. private _fragmentCompilationState;
  17824. private _sharedData;
  17825. private _buildId;
  17826. private _buildWasSuccessful;
  17827. private _cachedWorldViewMatrix;
  17828. private _cachedWorldViewProjectionMatrix;
  17829. private _optimizers;
  17830. private _animationFrame;
  17831. /** Define the Url to load node editor script */
  17832. static EditorURL: string;
  17833. /** Define the Url to load snippets */
  17834. static SnippetUrl: string;
  17835. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17836. static IgnoreTexturesAtLoadTime: boolean;
  17837. private BJSNODEMATERIALEDITOR;
  17838. /** Get the inspector from bundle or global */
  17839. private _getGlobalNodeMaterialEditor;
  17840. /**
  17841. * Snippet ID if the material was created from the snippet server
  17842. */
  17843. snippetId: string;
  17844. /**
  17845. * Gets or sets data used by visual editor
  17846. * @see https://nme.babylonjs.com
  17847. */
  17848. editorData: any;
  17849. /**
  17850. * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
  17851. */
  17852. ignoreAlpha: boolean;
  17853. /**
  17854. * Defines the maximum number of lights that can be used in the material
  17855. */
  17856. maxSimultaneousLights: number;
  17857. /**
  17858. * Observable raised when the material is built
  17859. */
  17860. onBuildObservable: Observable<NodeMaterial>;
  17861. /**
  17862. * Gets or sets the root nodes of the material vertex shader
  17863. */
  17864. _vertexOutputNodes: NodeMaterialBlock[];
  17865. /**
  17866. * Gets or sets the root nodes of the material fragment (pixel) shader
  17867. */
  17868. _fragmentOutputNodes: NodeMaterialBlock[];
  17869. /** Gets or sets options to control the node material overall behavior */
  17870. get options(): INodeMaterialOptions;
  17871. set options(options: INodeMaterialOptions);
  17872. /**
  17873. * Default configuration related to image processing available in the standard Material.
  17874. */
  17875. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17876. /**
  17877. * Gets the image processing configuration used either in this material.
  17878. */
  17879. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17880. /**
  17881. * Sets the Default image processing configuration used either in the this material.
  17882. *
  17883. * If sets to null, the scene one is in use.
  17884. */
  17885. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17886. /**
  17887. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17888. */
  17889. attachedBlocks: NodeMaterialBlock[];
  17890. /**
  17891. * Specifies the mode of the node material
  17892. * @hidden
  17893. */
  17894. _mode: NodeMaterialModes;
  17895. /**
  17896. * Gets the mode property
  17897. */
  17898. get mode(): NodeMaterialModes;
  17899. /**
  17900. * A free comment about the material
  17901. */
  17902. comment: string;
  17903. /**
  17904. * Create a new node based material
  17905. * @param name defines the material name
  17906. * @param scene defines the hosting scene
  17907. * @param options defines creation option
  17908. */
  17909. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17910. /**
  17911. * Gets the current class name of the material e.g. "NodeMaterial"
  17912. * @returns the class name
  17913. */
  17914. getClassName(): string;
  17915. /**
  17916. * Keep track of the image processing observer to allow dispose and replace.
  17917. */
  17918. private _imageProcessingObserver;
  17919. /**
  17920. * Attaches a new image processing configuration to the Standard Material.
  17921. * @param configuration
  17922. */
  17923. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17924. /**
  17925. * Get a block by its name
  17926. * @param name defines the name of the block to retrieve
  17927. * @returns the required block or null if not found
  17928. */
  17929. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17930. /**
  17931. * Get a block by its name
  17932. * @param predicate defines the predicate used to find the good candidate
  17933. * @returns the required block or null if not found
  17934. */
  17935. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17936. /**
  17937. * Get an input block by its name
  17938. * @param predicate defines the predicate used to find the good candidate
  17939. * @returns the required input block or null if not found
  17940. */
  17941. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17942. /**
  17943. * Gets the list of input blocks attached to this material
  17944. * @returns an array of InputBlocks
  17945. */
  17946. getInputBlocks(): InputBlock[];
  17947. /**
  17948. * Adds a new optimizer to the list of optimizers
  17949. * @param optimizer defines the optimizers to add
  17950. * @returns the current material
  17951. */
  17952. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17953. /**
  17954. * Remove an optimizer from the list of optimizers
  17955. * @param optimizer defines the optimizers to remove
  17956. * @returns the current material
  17957. */
  17958. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17959. /**
  17960. * Add a new block to the list of output nodes
  17961. * @param node defines the node to add
  17962. * @returns the current material
  17963. */
  17964. addOutputNode(node: NodeMaterialBlock): this;
  17965. /**
  17966. * Remove a block from the list of root nodes
  17967. * @param node defines the node to remove
  17968. * @returns the current material
  17969. */
  17970. removeOutputNode(node: NodeMaterialBlock): this;
  17971. private _addVertexOutputNode;
  17972. private _removeVertexOutputNode;
  17973. private _addFragmentOutputNode;
  17974. private _removeFragmentOutputNode;
  17975. /**
  17976. * Specifies if the material will require alpha blending
  17977. * @returns a boolean specifying if alpha blending is needed
  17978. */
  17979. needAlphaBlending(): boolean;
  17980. /**
  17981. * Specifies if this material should be rendered in alpha test mode
  17982. * @returns a boolean specifying if an alpha test is needed.
  17983. */
  17984. needAlphaTesting(): boolean;
  17985. private _initializeBlock;
  17986. private _resetDualBlocks;
  17987. /**
  17988. * Remove a block from the current node material
  17989. * @param block defines the block to remove
  17990. */
  17991. removeBlock(block: NodeMaterialBlock): void;
  17992. /**
  17993. * Build the material and generates the inner effect
  17994. * @param verbose defines if the build should log activity
  17995. */
  17996. build(verbose?: boolean): void;
  17997. /**
  17998. * Runs an otpimization phase to try to improve the shader code
  17999. */
  18000. optimize(): void;
  18001. private _prepareDefinesForAttributes;
  18002. /**
  18003. * Create a post process from the material
  18004. * @param camera The camera to apply the render pass to.
  18005. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18007. * @param engine The engine which the post process will be applied. (default: current engine)
  18008. * @param reusable If the post process can be reused on the same frame. (default: false)
  18009. * @param textureType Type of textures used when performing the post process. (default: 0)
  18010. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18011. * @returns the post process created
  18012. */
  18013. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18014. /**
  18015. * Create the post process effect from the material
  18016. * @param postProcess The post process to create the effect for
  18017. */
  18018. createEffectForPostProcess(postProcess: PostProcess): void;
  18019. private _createEffectForPostProcess;
  18020. /**
  18021. * Create a new procedural texture based on this node material
  18022. * @param size defines the size of the texture
  18023. * @param scene defines the hosting scene
  18024. * @returns the new procedural texture attached to this node material
  18025. */
  18026. createProceduralTexture(size: number | {
  18027. width: number;
  18028. height: number;
  18029. layers?: number;
  18030. }, scene: Scene): Nullable<ProceduralTexture>;
  18031. private _createEffectForParticles;
  18032. private _checkInternals;
  18033. /**
  18034. * Create the effect to be used as the custom effect for a particle system
  18035. * @param particleSystem Particle system to create the effect for
  18036. * @param onCompiled defines a function to call when the effect creation is successful
  18037. * @param onError defines a function to call when the effect creation has failed
  18038. */
  18039. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18040. private _processDefines;
  18041. /**
  18042. * Get if the submesh is ready to be used and all its information available.
  18043. * Child classes can use it to update shaders
  18044. * @param mesh defines the mesh to check
  18045. * @param subMesh defines which submesh to check
  18046. * @param useInstances specifies that instances should be used
  18047. * @returns a boolean indicating that the submesh is ready or not
  18048. */
  18049. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18050. /**
  18051. * Get a string representing the shaders built by the current node graph
  18052. */
  18053. get compiledShaders(): string;
  18054. /**
  18055. * Binds the world matrix to the material
  18056. * @param world defines the world transformation matrix
  18057. */
  18058. bindOnlyWorldMatrix(world: Matrix): void;
  18059. /**
  18060. * Binds the submesh to this material by preparing the effect and shader to draw
  18061. * @param world defines the world transformation matrix
  18062. * @param mesh defines the mesh containing the submesh
  18063. * @param subMesh defines the submesh to bind the material to
  18064. */
  18065. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18066. /**
  18067. * Gets the active textures from the material
  18068. * @returns an array of textures
  18069. */
  18070. getActiveTextures(): BaseTexture[];
  18071. /**
  18072. * Gets the list of texture blocks
  18073. * @returns an array of texture blocks
  18074. */
  18075. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18076. /**
  18077. * Specifies if the material uses a texture
  18078. * @param texture defines the texture to check against the material
  18079. * @returns a boolean specifying if the material uses the texture
  18080. */
  18081. hasTexture(texture: BaseTexture): boolean;
  18082. /**
  18083. * Disposes the material
  18084. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18085. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18086. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18087. */
  18088. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18089. /** Creates the node editor window. */
  18090. private _createNodeEditor;
  18091. /**
  18092. * Launch the node material editor
  18093. * @param config Define the configuration of the editor
  18094. * @return a promise fulfilled when the node editor is visible
  18095. */
  18096. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18097. /**
  18098. * Clear the current material
  18099. */
  18100. clear(): void;
  18101. /**
  18102. * Clear the current material and set it to a default state
  18103. */
  18104. setToDefault(): void;
  18105. /**
  18106. * Clear the current material and set it to a default state for post process
  18107. */
  18108. setToDefaultPostProcess(): void;
  18109. /**
  18110. * Clear the current material and set it to a default state for procedural texture
  18111. */
  18112. setToDefaultProceduralTexture(): void;
  18113. /**
  18114. * Clear the current material and set it to a default state for particle
  18115. */
  18116. setToDefaultParticle(): void;
  18117. /**
  18118. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18119. * @param url defines the url to load from
  18120. * @returns a promise that will fullfil when the material is fully loaded
  18121. */
  18122. loadAsync(url: string): Promise<void>;
  18123. private _gatherBlocks;
  18124. /**
  18125. * Generate a string containing the code declaration required to create an equivalent of this material
  18126. * @returns a string
  18127. */
  18128. generateCode(): string;
  18129. /**
  18130. * Serializes this material in a JSON representation
  18131. * @returns the serialized material object
  18132. */
  18133. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18134. private _restoreConnections;
  18135. /**
  18136. * Clear the current graph and load a new one from a serialization object
  18137. * @param source defines the JSON representation of the material
  18138. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18139. * @param merge defines whether or not the source must be merged or replace the current content
  18140. */
  18141. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18142. /**
  18143. * Makes a duplicate of the current material.
  18144. * @param name - name to use for the new material.
  18145. */
  18146. clone(name: string): NodeMaterial;
  18147. /**
  18148. * Creates a node material from parsed material data
  18149. * @param source defines the JSON representation of the material
  18150. * @param scene defines the hosting scene
  18151. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18152. * @returns a new node material
  18153. */
  18154. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18155. /**
  18156. * Creates a node material from a snippet saved in a remote file
  18157. * @param name defines the name of the material to create
  18158. * @param url defines the url to load from
  18159. * @param scene defines the hosting scene
  18160. * @returns a promise that will resolve to the new node material
  18161. */
  18162. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18163. /**
  18164. * Creates a node material from a snippet saved by the node material editor
  18165. * @param snippetId defines the snippet to load
  18166. * @param scene defines the hosting scene
  18167. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18168. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18169. * @returns a promise that will resolve to the new node material
  18170. */
  18171. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18172. /**
  18173. * Creates a new node material set to default basic configuration
  18174. * @param name defines the name of the material
  18175. * @param scene defines the hosting scene
  18176. * @returns a new NodeMaterial
  18177. */
  18178. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18179. }
  18180. }
  18181. declare module BABYLON {
  18182. interface ThinEngine {
  18183. /**
  18184. * Unbind a list of render target textures from the webGL context
  18185. * This is used only when drawBuffer extension or webGL2 are active
  18186. * @param textures defines the render target textures to unbind
  18187. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18188. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18189. */
  18190. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18191. /**
  18192. * Create a multi render target texture
  18193. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18194. * @param size defines the size of the texture
  18195. * @param options defines the creation options
  18196. * @returns the cube texture as an InternalTexture
  18197. */
  18198. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18199. /**
  18200. * Update the sample count for a given multiple render target texture
  18201. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18202. * @param textures defines the textures to update
  18203. * @param samples defines the sample count to set
  18204. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18205. */
  18206. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18207. /**
  18208. * Select a subsets of attachments to draw to.
  18209. * @param attachments gl attachments
  18210. */
  18211. bindAttachments(attachments: number[]): void;
  18212. /**
  18213. * Creates a layout object to draw/clear on specific textures in a MRT
  18214. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18215. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18216. */
  18217. buildTextureLayout(textureStatus: boolean[]): number[];
  18218. /**
  18219. * Restores the webgl state to only draw on the main color attachment
  18220. */
  18221. restoreSingleAttachment(): void;
  18222. }
  18223. }
  18224. declare module BABYLON {
  18225. /**
  18226. * Creation options of the multi render target texture.
  18227. */
  18228. export interface IMultiRenderTargetOptions {
  18229. /**
  18230. * Define if the texture needs to create mip maps after render.
  18231. */
  18232. generateMipMaps?: boolean;
  18233. /**
  18234. * Define the types of all the draw buffers we want to create
  18235. */
  18236. types?: number[];
  18237. /**
  18238. * Define the sampling modes of all the draw buffers we want to create
  18239. */
  18240. samplingModes?: number[];
  18241. /**
  18242. * Define if a depth buffer is required
  18243. */
  18244. generateDepthBuffer?: boolean;
  18245. /**
  18246. * Define if a stencil buffer is required
  18247. */
  18248. generateStencilBuffer?: boolean;
  18249. /**
  18250. * Define if a depth texture is required instead of a depth buffer
  18251. */
  18252. generateDepthTexture?: boolean;
  18253. /**
  18254. * Define the number of desired draw buffers
  18255. */
  18256. textureCount?: number;
  18257. /**
  18258. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18259. */
  18260. doNotChangeAspectRatio?: boolean;
  18261. /**
  18262. * Define the default type of the buffers we are creating
  18263. */
  18264. defaultType?: number;
  18265. }
  18266. /**
  18267. * A multi render target, like a render target provides the ability to render to a texture.
  18268. * Unlike the render target, it can render to several draw buffers in one draw.
  18269. * This is specially interesting in deferred rendering or for any effects requiring more than
  18270. * just one color from a single pass.
  18271. */
  18272. export class MultiRenderTarget extends RenderTargetTexture {
  18273. private _internalTextures;
  18274. private _textures;
  18275. private _multiRenderTargetOptions;
  18276. private _count;
  18277. /**
  18278. * Get if draw buffers are currently supported by the used hardware and browser.
  18279. */
  18280. get isSupported(): boolean;
  18281. /**
  18282. * Get the list of textures generated by the multi render target.
  18283. */
  18284. get textures(): Texture[];
  18285. /**
  18286. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18287. */
  18288. get count(): number;
  18289. /**
  18290. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18291. */
  18292. get depthTexture(): Texture;
  18293. /**
  18294. * Set the wrapping mode on U of all the textures we are rendering to.
  18295. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18296. */
  18297. set wrapU(wrap: number);
  18298. /**
  18299. * Set the wrapping mode on V of all the textures we are rendering to.
  18300. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18301. */
  18302. set wrapV(wrap: number);
  18303. /**
  18304. * Instantiate a new multi render target texture.
  18305. * A multi render target, like a render target provides the ability to render to a texture.
  18306. * Unlike the render target, it can render to several draw buffers in one draw.
  18307. * This is specially interesting in deferred rendering or for any effects requiring more than
  18308. * just one color from a single pass.
  18309. * @param name Define the name of the texture
  18310. * @param size Define the size of the buffers to render to
  18311. * @param count Define the number of target we are rendering into
  18312. * @param scene Define the scene the texture belongs to
  18313. * @param options Define the options used to create the multi render target
  18314. */
  18315. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18316. private _initTypes;
  18317. /** @hidden */
  18318. _rebuild(forceFullRebuild?: boolean): void;
  18319. private _createInternalTextures;
  18320. private _createTextures;
  18321. /**
  18322. * Replaces a texture within the MRT.
  18323. * @param texture The new texture to insert in the MRT
  18324. * @param index The index of the texture to replace
  18325. */
  18326. replaceTexture(texture: Texture, index: number): void;
  18327. /**
  18328. * Define the number of samples used if MSAA is enabled.
  18329. */
  18330. get samples(): number;
  18331. set samples(value: number);
  18332. /**
  18333. * Resize all the textures in the multi render target.
  18334. * Be careful as it will recreate all the data in the new texture.
  18335. * @param size Define the new size
  18336. */
  18337. resize(size: any): void;
  18338. /**
  18339. * Changes the number of render targets in this MRT
  18340. * Be careful as it will recreate all the data in the new texture.
  18341. * @param count new texture count
  18342. * @param options Specifies texture types and sampling modes for new textures
  18343. */
  18344. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18345. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18346. /**
  18347. * Dispose the render targets and their associated resources
  18348. */
  18349. dispose(): void;
  18350. /**
  18351. * Release all the underlying texture used as draw buffers.
  18352. */
  18353. releaseInternalTextures(): void;
  18354. }
  18355. }
  18356. declare module BABYLON {
  18357. /** @hidden */
  18358. export var imageProcessingPixelShader: {
  18359. name: string;
  18360. shader: string;
  18361. };
  18362. }
  18363. declare module BABYLON {
  18364. /**
  18365. * ImageProcessingPostProcess
  18366. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18367. */
  18368. export class ImageProcessingPostProcess extends PostProcess {
  18369. /**
  18370. * Default configuration related to image processing available in the PBR Material.
  18371. */
  18372. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18373. /**
  18374. * Gets the image processing configuration used either in this material.
  18375. */
  18376. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18377. /**
  18378. * Sets the Default image processing configuration used either in the this material.
  18379. *
  18380. * If sets to null, the scene one is in use.
  18381. */
  18382. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18383. /**
  18384. * Keep track of the image processing observer to allow dispose and replace.
  18385. */
  18386. private _imageProcessingObserver;
  18387. /**
  18388. * Attaches a new image processing configuration to the PBR Material.
  18389. * @param configuration
  18390. */
  18391. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18392. /**
  18393. * If the post process is supported.
  18394. */
  18395. get isSupported(): boolean;
  18396. /**
  18397. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18398. */
  18399. get colorCurves(): Nullable<ColorCurves>;
  18400. /**
  18401. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18402. */
  18403. set colorCurves(value: Nullable<ColorCurves>);
  18404. /**
  18405. * Gets wether the color curves effect is enabled.
  18406. */
  18407. get colorCurvesEnabled(): boolean;
  18408. /**
  18409. * Sets wether the color curves effect is enabled.
  18410. */
  18411. set colorCurvesEnabled(value: boolean);
  18412. /**
  18413. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18414. */
  18415. get colorGradingTexture(): Nullable<BaseTexture>;
  18416. /**
  18417. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18418. */
  18419. set colorGradingTexture(value: Nullable<BaseTexture>);
  18420. /**
  18421. * Gets wether the color grading effect is enabled.
  18422. */
  18423. get colorGradingEnabled(): boolean;
  18424. /**
  18425. * Gets wether the color grading effect is enabled.
  18426. */
  18427. set colorGradingEnabled(value: boolean);
  18428. /**
  18429. * Gets exposure used in the effect.
  18430. */
  18431. get exposure(): number;
  18432. /**
  18433. * Sets exposure used in the effect.
  18434. */
  18435. set exposure(value: number);
  18436. /**
  18437. * Gets wether tonemapping is enabled or not.
  18438. */
  18439. get toneMappingEnabled(): boolean;
  18440. /**
  18441. * Sets wether tonemapping is enabled or not
  18442. */
  18443. set toneMappingEnabled(value: boolean);
  18444. /**
  18445. * Gets the type of tone mapping effect.
  18446. */
  18447. get toneMappingType(): number;
  18448. /**
  18449. * Sets the type of tone mapping effect.
  18450. */
  18451. set toneMappingType(value: number);
  18452. /**
  18453. * Gets contrast used in the effect.
  18454. */
  18455. get contrast(): number;
  18456. /**
  18457. * Sets contrast used in the effect.
  18458. */
  18459. set contrast(value: number);
  18460. /**
  18461. * Gets Vignette stretch size.
  18462. */
  18463. get vignetteStretch(): number;
  18464. /**
  18465. * Sets Vignette stretch size.
  18466. */
  18467. set vignetteStretch(value: number);
  18468. /**
  18469. * Gets Vignette centre X Offset.
  18470. */
  18471. get vignetteCentreX(): number;
  18472. /**
  18473. * Sets Vignette centre X Offset.
  18474. */
  18475. set vignetteCentreX(value: number);
  18476. /**
  18477. * Gets Vignette centre Y Offset.
  18478. */
  18479. get vignetteCentreY(): number;
  18480. /**
  18481. * Sets Vignette centre Y Offset.
  18482. */
  18483. set vignetteCentreY(value: number);
  18484. /**
  18485. * Gets Vignette weight or intensity of the vignette effect.
  18486. */
  18487. get vignetteWeight(): number;
  18488. /**
  18489. * Sets Vignette weight or intensity of the vignette effect.
  18490. */
  18491. set vignetteWeight(value: number);
  18492. /**
  18493. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18494. * if vignetteEnabled is set to true.
  18495. */
  18496. get vignetteColor(): Color4;
  18497. /**
  18498. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18499. * if vignetteEnabled is set to true.
  18500. */
  18501. set vignetteColor(value: Color4);
  18502. /**
  18503. * Gets Camera field of view used by the Vignette effect.
  18504. */
  18505. get vignetteCameraFov(): number;
  18506. /**
  18507. * Sets Camera field of view used by the Vignette effect.
  18508. */
  18509. set vignetteCameraFov(value: number);
  18510. /**
  18511. * Gets the vignette blend mode allowing different kind of effect.
  18512. */
  18513. get vignetteBlendMode(): number;
  18514. /**
  18515. * Sets the vignette blend mode allowing different kind of effect.
  18516. */
  18517. set vignetteBlendMode(value: number);
  18518. /**
  18519. * Gets wether the vignette effect is enabled.
  18520. */
  18521. get vignetteEnabled(): boolean;
  18522. /**
  18523. * Sets wether the vignette effect is enabled.
  18524. */
  18525. set vignetteEnabled(value: boolean);
  18526. private _fromLinearSpace;
  18527. /**
  18528. * Gets wether the input of the processing is in Gamma or Linear Space.
  18529. */
  18530. get fromLinearSpace(): boolean;
  18531. /**
  18532. * Sets wether the input of the processing is in Gamma or Linear Space.
  18533. */
  18534. set fromLinearSpace(value: boolean);
  18535. /**
  18536. * Defines cache preventing GC.
  18537. */
  18538. private _defines;
  18539. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18540. /**
  18541. * "ImageProcessingPostProcess"
  18542. * @returns "ImageProcessingPostProcess"
  18543. */
  18544. getClassName(): string;
  18545. /**
  18546. * @hidden
  18547. */
  18548. _updateParameters(): void;
  18549. dispose(camera?: Camera): void;
  18550. }
  18551. }
  18552. declare module BABYLON {
  18553. /**
  18554. * Interface for defining prepass effects in the prepass post-process pipeline
  18555. */
  18556. export interface PrePassEffectConfiguration {
  18557. /**
  18558. * Name of the effect
  18559. */
  18560. name: string;
  18561. /**
  18562. * Post process to attach for this effect
  18563. */
  18564. postProcess?: PostProcess;
  18565. /**
  18566. * Textures required in the MRT
  18567. */
  18568. texturesRequired: number[];
  18569. /**
  18570. * Is the effect enabled
  18571. */
  18572. enabled: boolean;
  18573. /**
  18574. * Disposes the effect configuration
  18575. */
  18576. dispose?: () => void;
  18577. /**
  18578. * Creates the associated post process
  18579. */
  18580. createPostProcess?: () => PostProcess;
  18581. }
  18582. }
  18583. declare module BABYLON {
  18584. /**
  18585. * Options to be used when creating a FresnelParameters.
  18586. */
  18587. export type IFresnelParametersCreationOptions = {
  18588. /**
  18589. * Define the color used on edges (grazing angle)
  18590. */
  18591. leftColor?: Color3;
  18592. /**
  18593. * Define the color used on center
  18594. */
  18595. rightColor?: Color3;
  18596. /**
  18597. * Define bias applied to computed fresnel term
  18598. */
  18599. bias?: number;
  18600. /**
  18601. * Defined the power exponent applied to fresnel term
  18602. */
  18603. power?: number;
  18604. /**
  18605. * Define if the fresnel effect is enable or not.
  18606. */
  18607. isEnabled?: boolean;
  18608. };
  18609. /**
  18610. * Serialized format for FresnelParameters.
  18611. */
  18612. export type IFresnelParametersSerialized = {
  18613. /**
  18614. * Define the color used on edges (grazing angle) [as an array]
  18615. */
  18616. leftColor: number[];
  18617. /**
  18618. * Define the color used on center [as an array]
  18619. */
  18620. rightColor: number[];
  18621. /**
  18622. * Define bias applied to computed fresnel term
  18623. */
  18624. bias: number;
  18625. /**
  18626. * Defined the power exponent applied to fresnel term
  18627. */
  18628. power?: number;
  18629. /**
  18630. * Define if the fresnel effect is enable or not.
  18631. */
  18632. isEnabled: boolean;
  18633. };
  18634. /**
  18635. * This represents all the required information to add a fresnel effect on a material:
  18636. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18637. */
  18638. export class FresnelParameters {
  18639. private _isEnabled;
  18640. /**
  18641. * Define if the fresnel effect is enable or not.
  18642. */
  18643. get isEnabled(): boolean;
  18644. set isEnabled(value: boolean);
  18645. /**
  18646. * Define the color used on edges (grazing angle)
  18647. */
  18648. leftColor: Color3;
  18649. /**
  18650. * Define the color used on center
  18651. */
  18652. rightColor: Color3;
  18653. /**
  18654. * Define bias applied to computed fresnel term
  18655. */
  18656. bias: number;
  18657. /**
  18658. * Defined the power exponent applied to fresnel term
  18659. */
  18660. power: number;
  18661. /**
  18662. * Creates a new FresnelParameters object.
  18663. *
  18664. * @param options provide your own settings to optionally to override defaults
  18665. */
  18666. constructor(options?: IFresnelParametersCreationOptions);
  18667. /**
  18668. * Clones the current fresnel and its valuues
  18669. * @returns a clone fresnel configuration
  18670. */
  18671. clone(): FresnelParameters;
  18672. /**
  18673. * Determines equality between FresnelParameters objects
  18674. * @param otherFresnelParameters defines the second operand
  18675. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18676. */
  18677. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18678. /**
  18679. * Serializes the current fresnel parameters to a JSON representation.
  18680. * @return the JSON serialization
  18681. */
  18682. serialize(): IFresnelParametersSerialized;
  18683. /**
  18684. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18685. * @param parsedFresnelParameters Define the JSON representation
  18686. * @returns the parsed parameters
  18687. */
  18688. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18689. }
  18690. }
  18691. declare module BABYLON {
  18692. /**
  18693. * This groups all the flags used to control the materials channel.
  18694. */
  18695. export class MaterialFlags {
  18696. private static _DiffuseTextureEnabled;
  18697. /**
  18698. * Are diffuse textures enabled in the application.
  18699. */
  18700. static get DiffuseTextureEnabled(): boolean;
  18701. static set DiffuseTextureEnabled(value: boolean);
  18702. private static _DetailTextureEnabled;
  18703. /**
  18704. * Are detail textures enabled in the application.
  18705. */
  18706. static get DetailTextureEnabled(): boolean;
  18707. static set DetailTextureEnabled(value: boolean);
  18708. private static _AmbientTextureEnabled;
  18709. /**
  18710. * Are ambient textures enabled in the application.
  18711. */
  18712. static get AmbientTextureEnabled(): boolean;
  18713. static set AmbientTextureEnabled(value: boolean);
  18714. private static _OpacityTextureEnabled;
  18715. /**
  18716. * Are opacity textures enabled in the application.
  18717. */
  18718. static get OpacityTextureEnabled(): boolean;
  18719. static set OpacityTextureEnabled(value: boolean);
  18720. private static _ReflectionTextureEnabled;
  18721. /**
  18722. * Are reflection textures enabled in the application.
  18723. */
  18724. static get ReflectionTextureEnabled(): boolean;
  18725. static set ReflectionTextureEnabled(value: boolean);
  18726. private static _EmissiveTextureEnabled;
  18727. /**
  18728. * Are emissive textures enabled in the application.
  18729. */
  18730. static get EmissiveTextureEnabled(): boolean;
  18731. static set EmissiveTextureEnabled(value: boolean);
  18732. private static _SpecularTextureEnabled;
  18733. /**
  18734. * Are specular textures enabled in the application.
  18735. */
  18736. static get SpecularTextureEnabled(): boolean;
  18737. static set SpecularTextureEnabled(value: boolean);
  18738. private static _BumpTextureEnabled;
  18739. /**
  18740. * Are bump textures enabled in the application.
  18741. */
  18742. static get BumpTextureEnabled(): boolean;
  18743. static set BumpTextureEnabled(value: boolean);
  18744. private static _LightmapTextureEnabled;
  18745. /**
  18746. * Are lightmap textures enabled in the application.
  18747. */
  18748. static get LightmapTextureEnabled(): boolean;
  18749. static set LightmapTextureEnabled(value: boolean);
  18750. private static _RefractionTextureEnabled;
  18751. /**
  18752. * Are refraction textures enabled in the application.
  18753. */
  18754. static get RefractionTextureEnabled(): boolean;
  18755. static set RefractionTextureEnabled(value: boolean);
  18756. private static _ColorGradingTextureEnabled;
  18757. /**
  18758. * Are color grading textures enabled in the application.
  18759. */
  18760. static get ColorGradingTextureEnabled(): boolean;
  18761. static set ColorGradingTextureEnabled(value: boolean);
  18762. private static _FresnelEnabled;
  18763. /**
  18764. * Are fresnels enabled in the application.
  18765. */
  18766. static get FresnelEnabled(): boolean;
  18767. static set FresnelEnabled(value: boolean);
  18768. private static _ClearCoatTextureEnabled;
  18769. /**
  18770. * Are clear coat textures enabled in the application.
  18771. */
  18772. static get ClearCoatTextureEnabled(): boolean;
  18773. static set ClearCoatTextureEnabled(value: boolean);
  18774. private static _ClearCoatBumpTextureEnabled;
  18775. /**
  18776. * Are clear coat bump textures enabled in the application.
  18777. */
  18778. static get ClearCoatBumpTextureEnabled(): boolean;
  18779. static set ClearCoatBumpTextureEnabled(value: boolean);
  18780. private static _ClearCoatTintTextureEnabled;
  18781. /**
  18782. * Are clear coat tint textures enabled in the application.
  18783. */
  18784. static get ClearCoatTintTextureEnabled(): boolean;
  18785. static set ClearCoatTintTextureEnabled(value: boolean);
  18786. private static _SheenTextureEnabled;
  18787. /**
  18788. * Are sheen textures enabled in the application.
  18789. */
  18790. static get SheenTextureEnabled(): boolean;
  18791. static set SheenTextureEnabled(value: boolean);
  18792. private static _AnisotropicTextureEnabled;
  18793. /**
  18794. * Are anisotropic textures enabled in the application.
  18795. */
  18796. static get AnisotropicTextureEnabled(): boolean;
  18797. static set AnisotropicTextureEnabled(value: boolean);
  18798. private static _ThicknessTextureEnabled;
  18799. /**
  18800. * Are thickness textures enabled in the application.
  18801. */
  18802. static get ThicknessTextureEnabled(): boolean;
  18803. static set ThicknessTextureEnabled(value: boolean);
  18804. }
  18805. }
  18806. declare module BABYLON {
  18807. /** @hidden */
  18808. export var defaultFragmentDeclaration: {
  18809. name: string;
  18810. shader: string;
  18811. };
  18812. }
  18813. declare module BABYLON {
  18814. /** @hidden */
  18815. export var sceneUboDeclaration: {
  18816. name: string;
  18817. shader: string;
  18818. };
  18819. }
  18820. declare module BABYLON {
  18821. /** @hidden */
  18822. export var meshUboDeclaration: {
  18823. name: string;
  18824. shader: string;
  18825. };
  18826. }
  18827. declare module BABYLON {
  18828. /** @hidden */
  18829. export var defaultUboDeclaration: {
  18830. name: string;
  18831. shader: string;
  18832. };
  18833. }
  18834. declare module BABYLON {
  18835. /** @hidden */
  18836. export var prePassDeclaration: {
  18837. name: string;
  18838. shader: string;
  18839. };
  18840. }
  18841. declare module BABYLON {
  18842. /** @hidden */
  18843. export var lightFragmentDeclaration: {
  18844. name: string;
  18845. shader: string;
  18846. };
  18847. }
  18848. declare module BABYLON {
  18849. /** @hidden */
  18850. export var lightUboDeclaration: {
  18851. name: string;
  18852. shader: string;
  18853. };
  18854. }
  18855. declare module BABYLON {
  18856. /** @hidden */
  18857. export var lightsFragmentFunctions: {
  18858. name: string;
  18859. shader: string;
  18860. };
  18861. }
  18862. declare module BABYLON {
  18863. /** @hidden */
  18864. export var shadowsFragmentFunctions: {
  18865. name: string;
  18866. shader: string;
  18867. };
  18868. }
  18869. declare module BABYLON {
  18870. /** @hidden */
  18871. export var fresnelFunction: {
  18872. name: string;
  18873. shader: string;
  18874. };
  18875. }
  18876. declare module BABYLON {
  18877. /** @hidden */
  18878. export var bumpFragmentMainFunctions: {
  18879. name: string;
  18880. shader: string;
  18881. };
  18882. }
  18883. declare module BABYLON {
  18884. /** @hidden */
  18885. export var bumpFragmentFunctions: {
  18886. name: string;
  18887. shader: string;
  18888. };
  18889. }
  18890. declare module BABYLON {
  18891. /** @hidden */
  18892. export var logDepthDeclaration: {
  18893. name: string;
  18894. shader: string;
  18895. };
  18896. }
  18897. declare module BABYLON {
  18898. /** @hidden */
  18899. export var fogFragmentDeclaration: {
  18900. name: string;
  18901. shader: string;
  18902. };
  18903. }
  18904. declare module BABYLON {
  18905. /** @hidden */
  18906. export var bumpFragment: {
  18907. name: string;
  18908. shader: string;
  18909. };
  18910. }
  18911. declare module BABYLON {
  18912. /** @hidden */
  18913. export var depthPrePass: {
  18914. name: string;
  18915. shader: string;
  18916. };
  18917. }
  18918. declare module BABYLON {
  18919. /** @hidden */
  18920. export var lightFragment: {
  18921. name: string;
  18922. shader: string;
  18923. };
  18924. }
  18925. declare module BABYLON {
  18926. /** @hidden */
  18927. export var logDepthFragment: {
  18928. name: string;
  18929. shader: string;
  18930. };
  18931. }
  18932. declare module BABYLON {
  18933. /** @hidden */
  18934. export var fogFragment: {
  18935. name: string;
  18936. shader: string;
  18937. };
  18938. }
  18939. declare module BABYLON {
  18940. /** @hidden */
  18941. export var defaultPixelShader: {
  18942. name: string;
  18943. shader: string;
  18944. };
  18945. }
  18946. declare module BABYLON {
  18947. /** @hidden */
  18948. export var defaultVertexDeclaration: {
  18949. name: string;
  18950. shader: string;
  18951. };
  18952. }
  18953. declare module BABYLON {
  18954. /** @hidden */
  18955. export var bonesDeclaration: {
  18956. name: string;
  18957. shader: string;
  18958. };
  18959. }
  18960. declare module BABYLON {
  18961. /** @hidden */
  18962. export var prePassVertexDeclaration: {
  18963. name: string;
  18964. shader: string;
  18965. };
  18966. }
  18967. declare module BABYLON {
  18968. /** @hidden */
  18969. export var bumpVertexDeclaration: {
  18970. name: string;
  18971. shader: string;
  18972. };
  18973. }
  18974. declare module BABYLON {
  18975. /** @hidden */
  18976. export var fogVertexDeclaration: {
  18977. name: string;
  18978. shader: string;
  18979. };
  18980. }
  18981. declare module BABYLON {
  18982. /** @hidden */
  18983. export var lightVxFragmentDeclaration: {
  18984. name: string;
  18985. shader: string;
  18986. };
  18987. }
  18988. declare module BABYLON {
  18989. /** @hidden */
  18990. export var lightVxUboDeclaration: {
  18991. name: string;
  18992. shader: string;
  18993. };
  18994. }
  18995. declare module BABYLON {
  18996. /** @hidden */
  18997. export var morphTargetsVertexGlobalDeclaration: {
  18998. name: string;
  18999. shader: string;
  19000. };
  19001. }
  19002. declare module BABYLON {
  19003. /** @hidden */
  19004. export var morphTargetsVertexDeclaration: {
  19005. name: string;
  19006. shader: string;
  19007. };
  19008. }
  19009. declare module BABYLON {
  19010. /** @hidden */
  19011. export var morphTargetsVertex: {
  19012. name: string;
  19013. shader: string;
  19014. };
  19015. }
  19016. declare module BABYLON {
  19017. /** @hidden */
  19018. export var instancesVertex: {
  19019. name: string;
  19020. shader: string;
  19021. };
  19022. }
  19023. declare module BABYLON {
  19024. /** @hidden */
  19025. export var bonesVertex: {
  19026. name: string;
  19027. shader: string;
  19028. };
  19029. }
  19030. declare module BABYLON {
  19031. /** @hidden */
  19032. export var prePassVertex: {
  19033. name: string;
  19034. shader: string;
  19035. };
  19036. }
  19037. declare module BABYLON {
  19038. /** @hidden */
  19039. export var bumpVertex: {
  19040. name: string;
  19041. shader: string;
  19042. };
  19043. }
  19044. declare module BABYLON {
  19045. /** @hidden */
  19046. export var fogVertex: {
  19047. name: string;
  19048. shader: string;
  19049. };
  19050. }
  19051. declare module BABYLON {
  19052. /** @hidden */
  19053. export var shadowsVertex: {
  19054. name: string;
  19055. shader: string;
  19056. };
  19057. }
  19058. declare module BABYLON {
  19059. /** @hidden */
  19060. export var pointCloudVertex: {
  19061. name: string;
  19062. shader: string;
  19063. };
  19064. }
  19065. declare module BABYLON {
  19066. /** @hidden */
  19067. export var logDepthVertex: {
  19068. name: string;
  19069. shader: string;
  19070. };
  19071. }
  19072. declare module BABYLON {
  19073. /** @hidden */
  19074. export var defaultVertexShader: {
  19075. name: string;
  19076. shader: string;
  19077. };
  19078. }
  19079. declare module BABYLON {
  19080. /**
  19081. * @hidden
  19082. */
  19083. export interface IMaterialDetailMapDefines {
  19084. DETAIL: boolean;
  19085. DETAILDIRECTUV: number;
  19086. DETAIL_NORMALBLENDMETHOD: number;
  19087. /** @hidden */
  19088. _areTexturesDirty: boolean;
  19089. }
  19090. /**
  19091. * Define the code related to the detail map parameters of a material
  19092. *
  19093. * Inspired from:
  19094. * 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
  19095. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19096. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19097. */
  19098. export class DetailMapConfiguration {
  19099. private _texture;
  19100. /**
  19101. * The detail texture of the material.
  19102. */
  19103. texture: Nullable<BaseTexture>;
  19104. /**
  19105. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19106. * Bigger values mean stronger blending
  19107. */
  19108. diffuseBlendLevel: number;
  19109. /**
  19110. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19111. * Bigger values mean stronger blending. Only used with PBR materials
  19112. */
  19113. roughnessBlendLevel: number;
  19114. /**
  19115. * Defines how strong the bump effect from the detail map is
  19116. * Bigger values mean stronger effect
  19117. */
  19118. bumpLevel: number;
  19119. private _normalBlendMethod;
  19120. /**
  19121. * The method used to blend the bump and detail normals together
  19122. */
  19123. normalBlendMethod: number;
  19124. private _isEnabled;
  19125. /**
  19126. * Enable or disable the detail map on this material
  19127. */
  19128. isEnabled: boolean;
  19129. /** @hidden */
  19130. private _internalMarkAllSubMeshesAsTexturesDirty;
  19131. /** @hidden */
  19132. _markAllSubMeshesAsTexturesDirty(): void;
  19133. /**
  19134. * Instantiate a new detail map
  19135. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19136. */
  19137. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19138. /**
  19139. * Gets whether the submesh is ready to be used or not.
  19140. * @param defines the list of "defines" to update.
  19141. * @param scene defines the scene the material belongs to.
  19142. * @returns - boolean indicating that the submesh is ready or not.
  19143. */
  19144. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19145. /**
  19146. * Update the defines for detail map usage
  19147. * @param defines the list of "defines" to update.
  19148. * @param scene defines the scene the material belongs to.
  19149. */
  19150. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19151. /**
  19152. * Binds the material data.
  19153. * @param uniformBuffer defines the Uniform buffer to fill in.
  19154. * @param scene defines the scene the material belongs to.
  19155. * @param isFrozen defines whether the material is frozen or not.
  19156. */
  19157. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19158. /**
  19159. * Checks to see if a texture is used in the material.
  19160. * @param texture - Base texture to use.
  19161. * @returns - Boolean specifying if a texture is used in the material.
  19162. */
  19163. hasTexture(texture: BaseTexture): boolean;
  19164. /**
  19165. * Returns an array of the actively used textures.
  19166. * @param activeTextures Array of BaseTextures
  19167. */
  19168. getActiveTextures(activeTextures: BaseTexture[]): void;
  19169. /**
  19170. * Returns the animatable textures.
  19171. * @param animatables Array of animatable textures.
  19172. */
  19173. getAnimatables(animatables: IAnimatable[]): void;
  19174. /**
  19175. * Disposes the resources of the material.
  19176. * @param forceDisposeTextures - Forces the disposal of all textures.
  19177. */
  19178. dispose(forceDisposeTextures?: boolean): void;
  19179. /**
  19180. * Get the current class name useful for serialization or dynamic coding.
  19181. * @returns "DetailMap"
  19182. */
  19183. getClassName(): string;
  19184. /**
  19185. * Add the required uniforms to the current list.
  19186. * @param uniforms defines the current uniform list.
  19187. */
  19188. static AddUniforms(uniforms: string[]): void;
  19189. /**
  19190. * Add the required samplers to the current list.
  19191. * @param samplers defines the current sampler list.
  19192. */
  19193. static AddSamplers(samplers: string[]): void;
  19194. /**
  19195. * Add the required uniforms to the current buffer.
  19196. * @param uniformBuffer defines the current uniform buffer.
  19197. */
  19198. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19199. /**
  19200. * Makes a duplicate of the current instance into another one.
  19201. * @param detailMap define the instance where to copy the info
  19202. */
  19203. copyTo(detailMap: DetailMapConfiguration): void;
  19204. /**
  19205. * Serializes this detail map instance
  19206. * @returns - An object with the serialized instance.
  19207. */
  19208. serialize(): any;
  19209. /**
  19210. * Parses a detail map setting from a serialized object.
  19211. * @param source - Serialized object.
  19212. * @param scene Defines the scene we are parsing for
  19213. * @param rootUrl Defines the rootUrl to load from
  19214. */
  19215. parse(source: any, scene: Scene, rootUrl: string): void;
  19216. }
  19217. }
  19218. declare module BABYLON {
  19219. /** @hidden */
  19220. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19221. MAINUV1: boolean;
  19222. MAINUV2: boolean;
  19223. DIFFUSE: boolean;
  19224. DIFFUSEDIRECTUV: number;
  19225. DETAIL: boolean;
  19226. DETAILDIRECTUV: number;
  19227. DETAIL_NORMALBLENDMETHOD: number;
  19228. AMBIENT: boolean;
  19229. AMBIENTDIRECTUV: number;
  19230. OPACITY: boolean;
  19231. OPACITYDIRECTUV: number;
  19232. OPACITYRGB: boolean;
  19233. REFLECTION: boolean;
  19234. EMISSIVE: boolean;
  19235. EMISSIVEDIRECTUV: number;
  19236. SPECULAR: boolean;
  19237. SPECULARDIRECTUV: number;
  19238. BUMP: boolean;
  19239. BUMPDIRECTUV: number;
  19240. PARALLAX: boolean;
  19241. PARALLAXOCCLUSION: boolean;
  19242. SPECULAROVERALPHA: boolean;
  19243. CLIPPLANE: boolean;
  19244. CLIPPLANE2: boolean;
  19245. CLIPPLANE3: boolean;
  19246. CLIPPLANE4: boolean;
  19247. CLIPPLANE5: boolean;
  19248. CLIPPLANE6: boolean;
  19249. ALPHATEST: boolean;
  19250. DEPTHPREPASS: boolean;
  19251. ALPHAFROMDIFFUSE: boolean;
  19252. POINTSIZE: boolean;
  19253. FOG: boolean;
  19254. SPECULARTERM: boolean;
  19255. DIFFUSEFRESNEL: boolean;
  19256. OPACITYFRESNEL: boolean;
  19257. REFLECTIONFRESNEL: boolean;
  19258. REFRACTIONFRESNEL: boolean;
  19259. EMISSIVEFRESNEL: boolean;
  19260. FRESNEL: boolean;
  19261. NORMAL: boolean;
  19262. UV1: boolean;
  19263. UV2: boolean;
  19264. VERTEXCOLOR: boolean;
  19265. VERTEXALPHA: boolean;
  19266. NUM_BONE_INFLUENCERS: number;
  19267. BonesPerMesh: number;
  19268. BONETEXTURE: boolean;
  19269. BONES_VELOCITY_ENABLED: boolean;
  19270. INSTANCES: boolean;
  19271. THIN_INSTANCES: boolean;
  19272. GLOSSINESS: boolean;
  19273. ROUGHNESS: boolean;
  19274. EMISSIVEASILLUMINATION: boolean;
  19275. LINKEMISSIVEWITHDIFFUSE: boolean;
  19276. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19277. LIGHTMAP: boolean;
  19278. LIGHTMAPDIRECTUV: number;
  19279. OBJECTSPACE_NORMALMAP: boolean;
  19280. USELIGHTMAPASSHADOWMAP: boolean;
  19281. REFLECTIONMAP_3D: boolean;
  19282. REFLECTIONMAP_SPHERICAL: boolean;
  19283. REFLECTIONMAP_PLANAR: boolean;
  19284. REFLECTIONMAP_CUBIC: boolean;
  19285. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19286. REFLECTIONMAP_PROJECTION: boolean;
  19287. REFLECTIONMAP_SKYBOX: boolean;
  19288. REFLECTIONMAP_EXPLICIT: boolean;
  19289. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19290. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19291. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19292. INVERTCUBICMAP: boolean;
  19293. LOGARITHMICDEPTH: boolean;
  19294. REFRACTION: boolean;
  19295. REFRACTIONMAP_3D: boolean;
  19296. REFLECTIONOVERALPHA: boolean;
  19297. TWOSIDEDLIGHTING: boolean;
  19298. SHADOWFLOAT: boolean;
  19299. MORPHTARGETS: boolean;
  19300. MORPHTARGETS_NORMAL: boolean;
  19301. MORPHTARGETS_TANGENT: boolean;
  19302. MORPHTARGETS_UV: boolean;
  19303. NUM_MORPH_INFLUENCERS: number;
  19304. NONUNIFORMSCALING: boolean;
  19305. PREMULTIPLYALPHA: boolean;
  19306. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19307. ALPHABLEND: boolean;
  19308. PREPASS: boolean;
  19309. PREPASS_IRRADIANCE: boolean;
  19310. PREPASS_IRRADIANCE_INDEX: number;
  19311. PREPASS_ALBEDO: boolean;
  19312. PREPASS_ALBEDO_INDEX: number;
  19313. PREPASS_DEPTHNORMAL: boolean;
  19314. PREPASS_DEPTHNORMAL_INDEX: number;
  19315. PREPASS_POSITION: boolean;
  19316. PREPASS_POSITION_INDEX: number;
  19317. PREPASS_VELOCITY: boolean;
  19318. PREPASS_VELOCITY_INDEX: number;
  19319. PREPASS_REFLECTIVITY: boolean;
  19320. PREPASS_REFLECTIVITY_INDEX: number;
  19321. SCENE_MRT_COUNT: number;
  19322. RGBDLIGHTMAP: boolean;
  19323. RGBDREFLECTION: boolean;
  19324. RGBDREFRACTION: boolean;
  19325. IMAGEPROCESSING: boolean;
  19326. VIGNETTE: boolean;
  19327. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19328. VIGNETTEBLENDMODEOPAQUE: boolean;
  19329. TONEMAPPING: boolean;
  19330. TONEMAPPING_ACES: boolean;
  19331. CONTRAST: boolean;
  19332. COLORCURVES: boolean;
  19333. COLORGRADING: boolean;
  19334. COLORGRADING3D: boolean;
  19335. SAMPLER3DGREENDEPTH: boolean;
  19336. SAMPLER3DBGRMAP: boolean;
  19337. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19338. MULTIVIEW: boolean;
  19339. /**
  19340. * If the reflection texture on this material is in linear color space
  19341. * @hidden
  19342. */
  19343. IS_REFLECTION_LINEAR: boolean;
  19344. /**
  19345. * If the refraction texture on this material is in linear color space
  19346. * @hidden
  19347. */
  19348. IS_REFRACTION_LINEAR: boolean;
  19349. EXPOSURE: boolean;
  19350. constructor();
  19351. setReflectionMode(modeToEnable: string): void;
  19352. }
  19353. /**
  19354. * This is the default material used in Babylon. It is the best trade off between quality
  19355. * and performances.
  19356. * @see https://doc.babylonjs.com/babylon101/materials
  19357. */
  19358. export class StandardMaterial extends PushMaterial {
  19359. private _diffuseTexture;
  19360. /**
  19361. * The basic texture of the material as viewed under a light.
  19362. */
  19363. diffuseTexture: Nullable<BaseTexture>;
  19364. private _ambientTexture;
  19365. /**
  19366. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19367. */
  19368. ambientTexture: Nullable<BaseTexture>;
  19369. private _opacityTexture;
  19370. /**
  19371. * Define the transparency of the material from a texture.
  19372. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19373. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19374. */
  19375. opacityTexture: Nullable<BaseTexture>;
  19376. private _reflectionTexture;
  19377. /**
  19378. * Define the texture used to display the reflection.
  19379. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19380. */
  19381. reflectionTexture: Nullable<BaseTexture>;
  19382. private _emissiveTexture;
  19383. /**
  19384. * Define texture of the material as if self lit.
  19385. * This will be mixed in the final result even in the absence of light.
  19386. */
  19387. emissiveTexture: Nullable<BaseTexture>;
  19388. private _specularTexture;
  19389. /**
  19390. * Define how the color and intensity of the highlight given by the light in the material.
  19391. */
  19392. specularTexture: Nullable<BaseTexture>;
  19393. private _bumpTexture;
  19394. /**
  19395. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19396. * 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.
  19397. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19398. */
  19399. bumpTexture: Nullable<BaseTexture>;
  19400. private _lightmapTexture;
  19401. /**
  19402. * Complex lighting can be computationally expensive to compute at runtime.
  19403. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19404. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19405. */
  19406. lightmapTexture: Nullable<BaseTexture>;
  19407. private _refractionTexture;
  19408. /**
  19409. * Define the texture used to display the refraction.
  19410. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19411. */
  19412. refractionTexture: Nullable<BaseTexture>;
  19413. /**
  19414. * The color of the material lit by the environmental background lighting.
  19415. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19416. */
  19417. ambientColor: Color3;
  19418. /**
  19419. * The basic color of the material as viewed under a light.
  19420. */
  19421. diffuseColor: Color3;
  19422. /**
  19423. * Define how the color and intensity of the highlight given by the light in the material.
  19424. */
  19425. specularColor: Color3;
  19426. /**
  19427. * Define the color of the material as if self lit.
  19428. * This will be mixed in the final result even in the absence of light.
  19429. */
  19430. emissiveColor: Color3;
  19431. /**
  19432. * Defines how sharp are the highlights in the material.
  19433. * The bigger the value the sharper giving a more glossy feeling to the result.
  19434. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19435. */
  19436. specularPower: number;
  19437. private _useAlphaFromDiffuseTexture;
  19438. /**
  19439. * Does the transparency come from the diffuse texture alpha channel.
  19440. */
  19441. useAlphaFromDiffuseTexture: boolean;
  19442. private _useEmissiveAsIllumination;
  19443. /**
  19444. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19445. */
  19446. useEmissiveAsIllumination: boolean;
  19447. private _linkEmissiveWithDiffuse;
  19448. /**
  19449. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19450. * the emissive level when the final color is close to one.
  19451. */
  19452. linkEmissiveWithDiffuse: boolean;
  19453. private _useSpecularOverAlpha;
  19454. /**
  19455. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19456. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19457. */
  19458. useSpecularOverAlpha: boolean;
  19459. private _useReflectionOverAlpha;
  19460. /**
  19461. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19462. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19463. */
  19464. useReflectionOverAlpha: boolean;
  19465. private _disableLighting;
  19466. /**
  19467. * Does lights from the scene impacts this material.
  19468. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19469. */
  19470. disableLighting: boolean;
  19471. private _useObjectSpaceNormalMap;
  19472. /**
  19473. * Allows using an object space normal map (instead of tangent space).
  19474. */
  19475. useObjectSpaceNormalMap: boolean;
  19476. private _useParallax;
  19477. /**
  19478. * Is parallax enabled or not.
  19479. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19480. */
  19481. useParallax: boolean;
  19482. private _useParallaxOcclusion;
  19483. /**
  19484. * Is parallax occlusion enabled or not.
  19485. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19486. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19487. */
  19488. useParallaxOcclusion: boolean;
  19489. /**
  19490. * 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.
  19491. */
  19492. parallaxScaleBias: number;
  19493. private _roughness;
  19494. /**
  19495. * Helps to define how blurry the reflections should appears in the material.
  19496. */
  19497. roughness: number;
  19498. /**
  19499. * In case of refraction, define the value of the index of refraction.
  19500. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19501. */
  19502. indexOfRefraction: number;
  19503. /**
  19504. * Invert the refraction texture alongside the y axis.
  19505. * It can be useful with procedural textures or probe for instance.
  19506. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19507. */
  19508. invertRefractionY: boolean;
  19509. /**
  19510. * Defines the alpha limits in alpha test mode.
  19511. */
  19512. alphaCutOff: number;
  19513. private _useLightmapAsShadowmap;
  19514. /**
  19515. * In case of light mapping, define whether the map contains light or shadow informations.
  19516. */
  19517. useLightmapAsShadowmap: boolean;
  19518. private _diffuseFresnelParameters;
  19519. /**
  19520. * Define the diffuse fresnel parameters of the material.
  19521. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19522. */
  19523. diffuseFresnelParameters: FresnelParameters;
  19524. private _opacityFresnelParameters;
  19525. /**
  19526. * Define the opacity fresnel parameters of the material.
  19527. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19528. */
  19529. opacityFresnelParameters: FresnelParameters;
  19530. private _reflectionFresnelParameters;
  19531. /**
  19532. * Define the reflection fresnel parameters of the material.
  19533. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19534. */
  19535. reflectionFresnelParameters: FresnelParameters;
  19536. private _refractionFresnelParameters;
  19537. /**
  19538. * Define the refraction fresnel parameters of the material.
  19539. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19540. */
  19541. refractionFresnelParameters: FresnelParameters;
  19542. private _emissiveFresnelParameters;
  19543. /**
  19544. * Define the emissive fresnel parameters of the material.
  19545. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19546. */
  19547. emissiveFresnelParameters: FresnelParameters;
  19548. private _useReflectionFresnelFromSpecular;
  19549. /**
  19550. * If true automatically deducts the fresnels values from the material specularity.
  19551. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19552. */
  19553. useReflectionFresnelFromSpecular: boolean;
  19554. private _useGlossinessFromSpecularMapAlpha;
  19555. /**
  19556. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19557. */
  19558. useGlossinessFromSpecularMapAlpha: boolean;
  19559. private _maxSimultaneousLights;
  19560. /**
  19561. * Defines the maximum number of lights that can be used in the material
  19562. */
  19563. maxSimultaneousLights: number;
  19564. private _invertNormalMapX;
  19565. /**
  19566. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19567. */
  19568. invertNormalMapX: boolean;
  19569. private _invertNormalMapY;
  19570. /**
  19571. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19572. */
  19573. invertNormalMapY: boolean;
  19574. private _twoSidedLighting;
  19575. /**
  19576. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19577. */
  19578. twoSidedLighting: boolean;
  19579. /**
  19580. * Default configuration related to image processing available in the standard Material.
  19581. */
  19582. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19583. /**
  19584. * Gets the image processing configuration used either in this material.
  19585. */
  19586. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19587. /**
  19588. * Sets the Default image processing configuration used either in the this material.
  19589. *
  19590. * If sets to null, the scene one is in use.
  19591. */
  19592. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19593. /**
  19594. * Keep track of the image processing observer to allow dispose and replace.
  19595. */
  19596. private _imageProcessingObserver;
  19597. /**
  19598. * Attaches a new image processing configuration to the Standard Material.
  19599. * @param configuration
  19600. */
  19601. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19602. /**
  19603. * Defines additionnal PrePass parameters for the material.
  19604. */
  19605. readonly prePassConfiguration: PrePassConfiguration;
  19606. /**
  19607. * Gets wether the color curves effect is enabled.
  19608. */
  19609. get cameraColorCurvesEnabled(): boolean;
  19610. /**
  19611. * Sets wether the color curves effect is enabled.
  19612. */
  19613. set cameraColorCurvesEnabled(value: boolean);
  19614. /**
  19615. * Gets wether the color grading effect is enabled.
  19616. */
  19617. get cameraColorGradingEnabled(): boolean;
  19618. /**
  19619. * Gets wether the color grading effect is enabled.
  19620. */
  19621. set cameraColorGradingEnabled(value: boolean);
  19622. /**
  19623. * Gets wether tonemapping is enabled or not.
  19624. */
  19625. get cameraToneMappingEnabled(): boolean;
  19626. /**
  19627. * Sets wether tonemapping is enabled or not
  19628. */
  19629. set cameraToneMappingEnabled(value: boolean);
  19630. /**
  19631. * The camera exposure used on this material.
  19632. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19633. * This corresponds to a photographic exposure.
  19634. */
  19635. get cameraExposure(): number;
  19636. /**
  19637. * The camera exposure used on this material.
  19638. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19639. * This corresponds to a photographic exposure.
  19640. */
  19641. set cameraExposure(value: number);
  19642. /**
  19643. * Gets The camera contrast used on this material.
  19644. */
  19645. get cameraContrast(): number;
  19646. /**
  19647. * Sets The camera contrast used on this material.
  19648. */
  19649. set cameraContrast(value: number);
  19650. /**
  19651. * Gets the Color Grading 2D Lookup Texture.
  19652. */
  19653. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19654. /**
  19655. * Sets the Color Grading 2D Lookup Texture.
  19656. */
  19657. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19658. /**
  19659. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19660. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19661. * 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;
  19662. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19663. */
  19664. get cameraColorCurves(): Nullable<ColorCurves>;
  19665. /**
  19666. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19667. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19668. * 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;
  19669. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19670. */
  19671. set cameraColorCurves(value: Nullable<ColorCurves>);
  19672. /**
  19673. * Can this material render to several textures at once
  19674. */
  19675. get canRenderToMRT(): boolean;
  19676. /**
  19677. * Defines the detail map parameters for the material.
  19678. */
  19679. readonly detailMap: DetailMapConfiguration;
  19680. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19681. protected _worldViewProjectionMatrix: Matrix;
  19682. protected _globalAmbientColor: Color3;
  19683. protected _useLogarithmicDepth: boolean;
  19684. protected _rebuildInParallel: boolean;
  19685. /**
  19686. * Instantiates a new standard material.
  19687. * This is the default material used in Babylon. It is the best trade off between quality
  19688. * and performances.
  19689. * @see https://doc.babylonjs.com/babylon101/materials
  19690. * @param name Define the name of the material in the scene
  19691. * @param scene Define the scene the material belong to
  19692. */
  19693. constructor(name: string, scene: Scene);
  19694. /**
  19695. * Gets a boolean indicating that current material needs to register RTT
  19696. */
  19697. get hasRenderTargetTextures(): boolean;
  19698. /**
  19699. * Gets the current class name of the material e.g. "StandardMaterial"
  19700. * Mainly use in serialization.
  19701. * @returns the class name
  19702. */
  19703. getClassName(): string;
  19704. /**
  19705. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19706. * You can try switching to logarithmic depth.
  19707. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19708. */
  19709. get useLogarithmicDepth(): boolean;
  19710. set useLogarithmicDepth(value: boolean);
  19711. /**
  19712. * Specifies if the material will require alpha blending
  19713. * @returns a boolean specifying if alpha blending is needed
  19714. */
  19715. needAlphaBlending(): boolean;
  19716. /**
  19717. * Specifies if this material should be rendered in alpha test mode
  19718. * @returns a boolean specifying if an alpha test is needed.
  19719. */
  19720. needAlphaTesting(): boolean;
  19721. /**
  19722. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19723. */
  19724. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19725. /**
  19726. * Specifies whether or not there is a usable alpha channel for transparency.
  19727. */
  19728. protected _hasAlphaChannel(): boolean;
  19729. /**
  19730. * Get the texture used for alpha test purpose.
  19731. * @returns the diffuse texture in case of the standard material.
  19732. */
  19733. getAlphaTestTexture(): Nullable<BaseTexture>;
  19734. /**
  19735. * Get if the submesh is ready to be used and all its information available.
  19736. * Child classes can use it to update shaders
  19737. * @param mesh defines the mesh to check
  19738. * @param subMesh defines which submesh to check
  19739. * @param useInstances specifies that instances should be used
  19740. * @returns a boolean indicating that the submesh is ready or not
  19741. */
  19742. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19743. /**
  19744. * Builds the material UBO layouts.
  19745. * Used internally during the effect preparation.
  19746. */
  19747. buildUniformLayout(): void;
  19748. /**
  19749. * Unbinds the material from the mesh
  19750. */
  19751. unbind(): void;
  19752. /**
  19753. * Binds the submesh to this material by preparing the effect and shader to draw
  19754. * @param world defines the world transformation matrix
  19755. * @param mesh defines the mesh containing the submesh
  19756. * @param subMesh defines the submesh to bind the material to
  19757. */
  19758. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19759. /**
  19760. * Get the list of animatables in the material.
  19761. * @returns the list of animatables object used in the material
  19762. */
  19763. getAnimatables(): IAnimatable[];
  19764. /**
  19765. * Gets the active textures from the material
  19766. * @returns an array of textures
  19767. */
  19768. getActiveTextures(): BaseTexture[];
  19769. /**
  19770. * Specifies if the material uses a texture
  19771. * @param texture defines the texture to check against the material
  19772. * @returns a boolean specifying if the material uses the texture
  19773. */
  19774. hasTexture(texture: BaseTexture): boolean;
  19775. /**
  19776. * Disposes the material
  19777. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19778. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19779. */
  19780. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19781. /**
  19782. * Makes a duplicate of the material, and gives it a new name
  19783. * @param name defines the new name for the duplicated material
  19784. * @returns the cloned material
  19785. */
  19786. clone(name: string): StandardMaterial;
  19787. /**
  19788. * Serializes this material in a JSON representation
  19789. * @returns the serialized material object
  19790. */
  19791. serialize(): any;
  19792. /**
  19793. * Creates a standard material from parsed material data
  19794. * @param source defines the JSON representation of the material
  19795. * @param scene defines the hosting scene
  19796. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19797. * @returns a new standard material
  19798. */
  19799. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19800. /**
  19801. * Are diffuse textures enabled in the application.
  19802. */
  19803. static get DiffuseTextureEnabled(): boolean;
  19804. static set DiffuseTextureEnabled(value: boolean);
  19805. /**
  19806. * Are detail textures enabled in the application.
  19807. */
  19808. static get DetailTextureEnabled(): boolean;
  19809. static set DetailTextureEnabled(value: boolean);
  19810. /**
  19811. * Are ambient textures enabled in the application.
  19812. */
  19813. static get AmbientTextureEnabled(): boolean;
  19814. static set AmbientTextureEnabled(value: boolean);
  19815. /**
  19816. * Are opacity textures enabled in the application.
  19817. */
  19818. static get OpacityTextureEnabled(): boolean;
  19819. static set OpacityTextureEnabled(value: boolean);
  19820. /**
  19821. * Are reflection textures enabled in the application.
  19822. */
  19823. static get ReflectionTextureEnabled(): boolean;
  19824. static set ReflectionTextureEnabled(value: boolean);
  19825. /**
  19826. * Are emissive textures enabled in the application.
  19827. */
  19828. static get EmissiveTextureEnabled(): boolean;
  19829. static set EmissiveTextureEnabled(value: boolean);
  19830. /**
  19831. * Are specular textures enabled in the application.
  19832. */
  19833. static get SpecularTextureEnabled(): boolean;
  19834. static set SpecularTextureEnabled(value: boolean);
  19835. /**
  19836. * Are bump textures enabled in the application.
  19837. */
  19838. static get BumpTextureEnabled(): boolean;
  19839. static set BumpTextureEnabled(value: boolean);
  19840. /**
  19841. * Are lightmap textures enabled in the application.
  19842. */
  19843. static get LightmapTextureEnabled(): boolean;
  19844. static set LightmapTextureEnabled(value: boolean);
  19845. /**
  19846. * Are refraction textures enabled in the application.
  19847. */
  19848. static get RefractionTextureEnabled(): boolean;
  19849. static set RefractionTextureEnabled(value: boolean);
  19850. /**
  19851. * Are color grading textures enabled in the application.
  19852. */
  19853. static get ColorGradingTextureEnabled(): boolean;
  19854. static set ColorGradingTextureEnabled(value: boolean);
  19855. /**
  19856. * Are fresnels enabled in the application.
  19857. */
  19858. static get FresnelEnabled(): boolean;
  19859. static set FresnelEnabled(value: boolean);
  19860. }
  19861. }
  19862. declare module BABYLON {
  19863. /** @hidden */
  19864. export var rgbdDecodePixelShader: {
  19865. name: string;
  19866. shader: string;
  19867. };
  19868. }
  19869. declare module BABYLON {
  19870. /** @hidden */
  19871. export var passPixelShader: {
  19872. name: string;
  19873. shader: string;
  19874. };
  19875. }
  19876. declare module BABYLON {
  19877. /** @hidden */
  19878. export var passCubePixelShader: {
  19879. name: string;
  19880. shader: string;
  19881. };
  19882. }
  19883. declare module BABYLON {
  19884. /**
  19885. * PassPostProcess which produces an output the same as it's input
  19886. */
  19887. export class PassPostProcess extends PostProcess {
  19888. /**
  19889. * Gets a string identifying the name of the class
  19890. * @returns "PassPostProcess" string
  19891. */
  19892. getClassName(): string;
  19893. /**
  19894. * Creates the PassPostProcess
  19895. * @param name The name of the effect.
  19896. * @param options The required width/height ratio to downsize to before computing the render pass.
  19897. * @param camera The camera to apply the render pass to.
  19898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19899. * @param engine The engine which the post process will be applied. (default: current engine)
  19900. * @param reusable If the post process can be reused on the same frame. (default: false)
  19901. * @param textureType The type of texture to be used when performing the post processing.
  19902. * @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)
  19903. */
  19904. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19905. /** @hidden */
  19906. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  19907. }
  19908. /**
  19909. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  19910. */
  19911. export class PassCubePostProcess extends PostProcess {
  19912. private _face;
  19913. /**
  19914. * Gets or sets the cube face to display.
  19915. * * 0 is +X
  19916. * * 1 is -X
  19917. * * 2 is +Y
  19918. * * 3 is -Y
  19919. * * 4 is +Z
  19920. * * 5 is -Z
  19921. */
  19922. get face(): number;
  19923. set face(value: number);
  19924. /**
  19925. * Gets a string identifying the name of the class
  19926. * @returns "PassCubePostProcess" string
  19927. */
  19928. getClassName(): string;
  19929. /**
  19930. * Creates the PassCubePostProcess
  19931. * @param name The name of the effect.
  19932. * @param options The required width/height ratio to downsize to before computing the render pass.
  19933. * @param camera The camera to apply the render pass to.
  19934. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19935. * @param engine The engine which the post process will be applied. (default: current engine)
  19936. * @param reusable If the post process can be reused on the same frame. (default: false)
  19937. * @param textureType The type of texture to be used when performing the post processing.
  19938. * @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)
  19939. */
  19940. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19941. /** @hidden */
  19942. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  19943. }
  19944. }
  19945. declare module BABYLON {
  19946. /**
  19947. * Class used to host texture specific utilities
  19948. */
  19949. export class TextureTools {
  19950. /**
  19951. * Uses the GPU to create a copy texture rescaled at a given size
  19952. * @param texture Texture to copy from
  19953. * @param width defines the desired width
  19954. * @param height defines the desired height
  19955. * @param useBilinearMode defines if bilinear mode has to be used
  19956. * @return the generated texture
  19957. */
  19958. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  19959. /**
  19960. * Apply a post process to a texture
  19961. * @param postProcessName name of the fragment post process
  19962. * @param internalTexture the texture to encode
  19963. * @param scene the scene hosting the texture
  19964. * @param type type of the output texture. If not provided, use the one from internalTexture
  19965. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  19966. * @param format format of the output texture. If not provided, use the one from internalTexture
  19967. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  19968. */
  19969. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  19970. }
  19971. }
  19972. declare module BABYLON {
  19973. /**
  19974. * Class used to host RGBD texture specific utilities
  19975. */
  19976. export class RGBDTextureTools {
  19977. /**
  19978. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19979. * @param texture the texture to expand.
  19980. */
  19981. static ExpandRGBDTexture(texture: Texture): void;
  19982. /**
  19983. * Encode the texture to RGBD if possible.
  19984. * @param internalTexture the texture to encode
  19985. * @param scene the scene hosting the texture
  19986. * @param outputTextureType type of the texture in which the encoding is performed
  19987. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  19988. */
  19989. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  19990. }
  19991. }
  19992. declare module BABYLON {
  19993. /**
  19994. * Class used to host texture specific utilities
  19995. */
  19996. export class BRDFTextureTools {
  19997. /**
  19998. * Prevents texture cache collision
  19999. */
  20000. private static _instanceNumber;
  20001. /**
  20002. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20003. * @param scene defines the hosting scene
  20004. * @returns the environment BRDF texture
  20005. */
  20006. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20007. private static _environmentBRDFBase64Texture;
  20008. }
  20009. }
  20010. declare module BABYLON {
  20011. /**
  20012. * @hidden
  20013. */
  20014. export interface IMaterialClearCoatDefines {
  20015. CLEARCOAT: boolean;
  20016. CLEARCOAT_DEFAULTIOR: boolean;
  20017. CLEARCOAT_TEXTURE: boolean;
  20018. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20019. CLEARCOAT_TEXTUREDIRECTUV: number;
  20020. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20021. CLEARCOAT_BUMP: boolean;
  20022. CLEARCOAT_BUMPDIRECTUV: number;
  20023. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20024. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20025. CLEARCOAT_REMAP_F0: boolean;
  20026. CLEARCOAT_TINT: boolean;
  20027. CLEARCOAT_TINT_TEXTURE: boolean;
  20028. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20029. /** @hidden */
  20030. _areTexturesDirty: boolean;
  20031. }
  20032. /**
  20033. * Define the code related to the clear coat parameters of the pbr material.
  20034. */
  20035. export class PBRClearCoatConfiguration {
  20036. /**
  20037. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20038. * The default fits with a polyurethane material.
  20039. * @hidden
  20040. */
  20041. static readonly _DefaultIndexOfRefraction: number;
  20042. private _isEnabled;
  20043. /**
  20044. * Defines if the clear coat is enabled in the material.
  20045. */
  20046. isEnabled: boolean;
  20047. /**
  20048. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20049. */
  20050. intensity: number;
  20051. /**
  20052. * Defines the clear coat layer roughness.
  20053. */
  20054. roughness: number;
  20055. private _indexOfRefraction;
  20056. /**
  20057. * Defines the index of refraction of the clear coat.
  20058. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20059. * The default fits with a polyurethane material.
  20060. * Changing the default value is more performance intensive.
  20061. */
  20062. indexOfRefraction: number;
  20063. private _texture;
  20064. /**
  20065. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20066. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20067. * if textureRoughness is not empty, else no texture roughness is used
  20068. */
  20069. texture: Nullable<BaseTexture>;
  20070. private _useRoughnessFromMainTexture;
  20071. /**
  20072. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20073. * If false, the green channel from textureRoughness is used for roughness
  20074. */
  20075. useRoughnessFromMainTexture: boolean;
  20076. private _textureRoughness;
  20077. /**
  20078. * Stores the clear coat roughness in a texture (green channel)
  20079. * Not used if useRoughnessFromMainTexture is true
  20080. */
  20081. textureRoughness: Nullable<BaseTexture>;
  20082. private _remapF0OnInterfaceChange;
  20083. /**
  20084. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20085. */
  20086. remapF0OnInterfaceChange: boolean;
  20087. private _bumpTexture;
  20088. /**
  20089. * Define the clear coat specific bump texture.
  20090. */
  20091. bumpTexture: Nullable<BaseTexture>;
  20092. private _isTintEnabled;
  20093. /**
  20094. * Defines if the clear coat tint is enabled in the material.
  20095. */
  20096. isTintEnabled: boolean;
  20097. /**
  20098. * Defines the clear coat tint of the material.
  20099. * This is only use if tint is enabled
  20100. */
  20101. tintColor: Color3;
  20102. /**
  20103. * Defines the distance at which the tint color should be found in the
  20104. * clear coat media.
  20105. * This is only use if tint is enabled
  20106. */
  20107. tintColorAtDistance: number;
  20108. /**
  20109. * Defines the clear coat layer thickness.
  20110. * This is only use if tint is enabled
  20111. */
  20112. tintThickness: number;
  20113. private _tintTexture;
  20114. /**
  20115. * Stores the clear tint values in a texture.
  20116. * rgb is tint
  20117. * a is a thickness factor
  20118. */
  20119. tintTexture: Nullable<BaseTexture>;
  20120. /** @hidden */
  20121. private _internalMarkAllSubMeshesAsTexturesDirty;
  20122. /** @hidden */
  20123. _markAllSubMeshesAsTexturesDirty(): void;
  20124. /**
  20125. * Instantiate a new istance of clear coat configuration.
  20126. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20127. */
  20128. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20129. /**
  20130. * Gets wehter the submesh is ready to be used or not.
  20131. * @param defines the list of "defines" to update.
  20132. * @param scene defines the scene the material belongs to.
  20133. * @param engine defines the engine the material belongs to.
  20134. * @param disableBumpMap defines wether the material disables bump or not.
  20135. * @returns - boolean indicating that the submesh is ready or not.
  20136. */
  20137. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20138. /**
  20139. * Checks to see if a texture is used in the material.
  20140. * @param defines the list of "defines" to update.
  20141. * @param scene defines the scene to the material belongs to.
  20142. */
  20143. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20144. /**
  20145. * Binds the material data.
  20146. * @param uniformBuffer defines the Uniform buffer to fill in.
  20147. * @param scene defines the scene the material belongs to.
  20148. * @param engine defines the engine the material belongs to.
  20149. * @param disableBumpMap defines wether the material disables bump or not.
  20150. * @param isFrozen defines wether the material is frozen or not.
  20151. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20152. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20153. * @param subMesh the submesh to bind data for
  20154. */
  20155. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20156. /**
  20157. * Checks to see if a texture is used in the material.
  20158. * @param texture - Base texture to use.
  20159. * @returns - Boolean specifying if a texture is used in the material.
  20160. */
  20161. hasTexture(texture: BaseTexture): boolean;
  20162. /**
  20163. * Returns an array of the actively used textures.
  20164. * @param activeTextures Array of BaseTextures
  20165. */
  20166. getActiveTextures(activeTextures: BaseTexture[]): void;
  20167. /**
  20168. * Returns the animatable textures.
  20169. * @param animatables Array of animatable textures.
  20170. */
  20171. getAnimatables(animatables: IAnimatable[]): void;
  20172. /**
  20173. * Disposes the resources of the material.
  20174. * @param forceDisposeTextures - Forces the disposal of all textures.
  20175. */
  20176. dispose(forceDisposeTextures?: boolean): void;
  20177. /**
  20178. * Get the current class name of the texture useful for serialization or dynamic coding.
  20179. * @returns "PBRClearCoatConfiguration"
  20180. */
  20181. getClassName(): string;
  20182. /**
  20183. * Add fallbacks to the effect fallbacks list.
  20184. * @param defines defines the Base texture to use.
  20185. * @param fallbacks defines the current fallback list.
  20186. * @param currentRank defines the current fallback rank.
  20187. * @returns the new fallback rank.
  20188. */
  20189. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20190. /**
  20191. * Add the required uniforms to the current list.
  20192. * @param uniforms defines the current uniform list.
  20193. */
  20194. static AddUniforms(uniforms: string[]): void;
  20195. /**
  20196. * Add the required samplers to the current list.
  20197. * @param samplers defines the current sampler list.
  20198. */
  20199. static AddSamplers(samplers: string[]): void;
  20200. /**
  20201. * Add the required uniforms to the current buffer.
  20202. * @param uniformBuffer defines the current uniform buffer.
  20203. */
  20204. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20205. /**
  20206. * Makes a duplicate of the current configuration into another one.
  20207. * @param clearCoatConfiguration define the config where to copy the info
  20208. */
  20209. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20210. /**
  20211. * Serializes this clear coat configuration.
  20212. * @returns - An object with the serialized config.
  20213. */
  20214. serialize(): any;
  20215. /**
  20216. * Parses a anisotropy Configuration from a serialized object.
  20217. * @param source - Serialized object.
  20218. * @param scene Defines the scene we are parsing for
  20219. * @param rootUrl Defines the rootUrl to load from
  20220. */
  20221. parse(source: any, scene: Scene, rootUrl: string): void;
  20222. }
  20223. }
  20224. declare module BABYLON {
  20225. /**
  20226. * @hidden
  20227. */
  20228. export interface IMaterialAnisotropicDefines {
  20229. ANISOTROPIC: boolean;
  20230. ANISOTROPIC_TEXTURE: boolean;
  20231. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20232. MAINUV1: boolean;
  20233. _areTexturesDirty: boolean;
  20234. _needUVs: boolean;
  20235. }
  20236. /**
  20237. * Define the code related to the anisotropic parameters of the pbr material.
  20238. */
  20239. export class PBRAnisotropicConfiguration {
  20240. private _isEnabled;
  20241. /**
  20242. * Defines if the anisotropy is enabled in the material.
  20243. */
  20244. isEnabled: boolean;
  20245. /**
  20246. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20247. */
  20248. intensity: number;
  20249. /**
  20250. * Defines if the effect is along the tangents, bitangents or in between.
  20251. * By default, the effect is "strectching" the highlights along the tangents.
  20252. */
  20253. direction: Vector2;
  20254. private _texture;
  20255. /**
  20256. * Stores the anisotropy values in a texture.
  20257. * rg is direction (like normal from -1 to 1)
  20258. * b is a intensity
  20259. */
  20260. texture: Nullable<BaseTexture>;
  20261. /** @hidden */
  20262. private _internalMarkAllSubMeshesAsTexturesDirty;
  20263. /** @hidden */
  20264. _markAllSubMeshesAsTexturesDirty(): void;
  20265. /**
  20266. * Instantiate a new istance of anisotropy configuration.
  20267. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20268. */
  20269. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20270. /**
  20271. * Specifies that the submesh is ready to be used.
  20272. * @param defines the list of "defines" to update.
  20273. * @param scene defines the scene the material belongs to.
  20274. * @returns - boolean indicating that the submesh is ready or not.
  20275. */
  20276. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20277. /**
  20278. * Checks to see if a texture is used in the material.
  20279. * @param defines the list of "defines" to update.
  20280. * @param mesh the mesh we are preparing the defines for.
  20281. * @param scene defines the scene the material belongs to.
  20282. */
  20283. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20284. /**
  20285. * Binds the material data.
  20286. * @param uniformBuffer defines the Uniform buffer to fill in.
  20287. * @param scene defines the scene the material belongs to.
  20288. * @param isFrozen defines wether the material is frozen or not.
  20289. */
  20290. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20291. /**
  20292. * Checks to see if a texture is used in the material.
  20293. * @param texture - Base texture to use.
  20294. * @returns - Boolean specifying if a texture is used in the material.
  20295. */
  20296. hasTexture(texture: BaseTexture): boolean;
  20297. /**
  20298. * Returns an array of the actively used textures.
  20299. * @param activeTextures Array of BaseTextures
  20300. */
  20301. getActiveTextures(activeTextures: BaseTexture[]): void;
  20302. /**
  20303. * Returns the animatable textures.
  20304. * @param animatables Array of animatable textures.
  20305. */
  20306. getAnimatables(animatables: IAnimatable[]): void;
  20307. /**
  20308. * Disposes the resources of the material.
  20309. * @param forceDisposeTextures - Forces the disposal of all textures.
  20310. */
  20311. dispose(forceDisposeTextures?: boolean): void;
  20312. /**
  20313. * Get the current class name of the texture useful for serialization or dynamic coding.
  20314. * @returns "PBRAnisotropicConfiguration"
  20315. */
  20316. getClassName(): string;
  20317. /**
  20318. * Add fallbacks to the effect fallbacks list.
  20319. * @param defines defines the Base texture to use.
  20320. * @param fallbacks defines the current fallback list.
  20321. * @param currentRank defines the current fallback rank.
  20322. * @returns the new fallback rank.
  20323. */
  20324. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20325. /**
  20326. * Add the required uniforms to the current list.
  20327. * @param uniforms defines the current uniform list.
  20328. */
  20329. static AddUniforms(uniforms: string[]): void;
  20330. /**
  20331. * Add the required uniforms to the current buffer.
  20332. * @param uniformBuffer defines the current uniform buffer.
  20333. */
  20334. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20335. /**
  20336. * Add the required samplers to the current list.
  20337. * @param samplers defines the current sampler list.
  20338. */
  20339. static AddSamplers(samplers: string[]): void;
  20340. /**
  20341. * Makes a duplicate of the current configuration into another one.
  20342. * @param anisotropicConfiguration define the config where to copy the info
  20343. */
  20344. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20345. /**
  20346. * Serializes this anisotropy configuration.
  20347. * @returns - An object with the serialized config.
  20348. */
  20349. serialize(): any;
  20350. /**
  20351. * Parses a anisotropy Configuration from a serialized object.
  20352. * @param source - Serialized object.
  20353. * @param scene Defines the scene we are parsing for
  20354. * @param rootUrl Defines the rootUrl to load from
  20355. */
  20356. parse(source: any, scene: Scene, rootUrl: string): void;
  20357. }
  20358. }
  20359. declare module BABYLON {
  20360. /**
  20361. * @hidden
  20362. */
  20363. export interface IMaterialBRDFDefines {
  20364. BRDF_V_HEIGHT_CORRELATED: boolean;
  20365. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20366. SPHERICAL_HARMONICS: boolean;
  20367. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20368. /** @hidden */
  20369. _areMiscDirty: boolean;
  20370. }
  20371. /**
  20372. * Define the code related to the BRDF parameters of the pbr material.
  20373. */
  20374. export class PBRBRDFConfiguration {
  20375. /**
  20376. * Default value used for the energy conservation.
  20377. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20378. */
  20379. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20380. /**
  20381. * Default value used for the Smith Visibility Height Correlated mode.
  20382. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20383. */
  20384. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20385. /**
  20386. * Default value used for the IBL diffuse part.
  20387. * This can help switching back to the polynomials mode globally which is a tiny bit
  20388. * less GPU intensive at the drawback of a lower quality.
  20389. */
  20390. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20391. /**
  20392. * Default value used for activating energy conservation for the specular workflow.
  20393. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20394. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20395. */
  20396. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20397. private _useEnergyConservation;
  20398. /**
  20399. * Defines if the material uses energy conservation.
  20400. */
  20401. useEnergyConservation: boolean;
  20402. private _useSmithVisibilityHeightCorrelated;
  20403. /**
  20404. * LEGACY Mode set to false
  20405. * Defines if the material uses height smith correlated visibility term.
  20406. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20407. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20408. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20409. * Not relying on height correlated will also disable energy conservation.
  20410. */
  20411. useSmithVisibilityHeightCorrelated: boolean;
  20412. private _useSphericalHarmonics;
  20413. /**
  20414. * LEGACY Mode set to false
  20415. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20416. * diffuse part of the IBL.
  20417. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20418. * to the ground truth.
  20419. */
  20420. useSphericalHarmonics: boolean;
  20421. private _useSpecularGlossinessInputEnergyConservation;
  20422. /**
  20423. * Defines if the material uses energy conservation, when the specular workflow is active.
  20424. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20425. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20426. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20427. */
  20428. useSpecularGlossinessInputEnergyConservation: boolean;
  20429. /** @hidden */
  20430. private _internalMarkAllSubMeshesAsMiscDirty;
  20431. /** @hidden */
  20432. _markAllSubMeshesAsMiscDirty(): void;
  20433. /**
  20434. * Instantiate a new istance of clear coat configuration.
  20435. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20436. */
  20437. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20438. /**
  20439. * Checks to see if a texture is used in the material.
  20440. * @param defines the list of "defines" to update.
  20441. */
  20442. prepareDefines(defines: IMaterialBRDFDefines): void;
  20443. /**
  20444. * Get the current class name of the texture useful for serialization or dynamic coding.
  20445. * @returns "PBRClearCoatConfiguration"
  20446. */
  20447. getClassName(): string;
  20448. /**
  20449. * Makes a duplicate of the current configuration into another one.
  20450. * @param brdfConfiguration define the config where to copy the info
  20451. */
  20452. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20453. /**
  20454. * Serializes this BRDF configuration.
  20455. * @returns - An object with the serialized config.
  20456. */
  20457. serialize(): any;
  20458. /**
  20459. * Parses a anisotropy Configuration from a serialized object.
  20460. * @param source - Serialized object.
  20461. * @param scene Defines the scene we are parsing for
  20462. * @param rootUrl Defines the rootUrl to load from
  20463. */
  20464. parse(source: any, scene: Scene, rootUrl: string): void;
  20465. }
  20466. }
  20467. declare module BABYLON {
  20468. /**
  20469. * @hidden
  20470. */
  20471. export interface IMaterialSheenDefines {
  20472. SHEEN: boolean;
  20473. SHEEN_TEXTURE: boolean;
  20474. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20475. SHEEN_TEXTUREDIRECTUV: number;
  20476. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20477. SHEEN_LINKWITHALBEDO: boolean;
  20478. SHEEN_ROUGHNESS: boolean;
  20479. SHEEN_ALBEDOSCALING: boolean;
  20480. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20481. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20482. /** @hidden */
  20483. _areTexturesDirty: boolean;
  20484. }
  20485. /**
  20486. * Define the code related to the Sheen parameters of the pbr material.
  20487. */
  20488. export class PBRSheenConfiguration {
  20489. private _isEnabled;
  20490. /**
  20491. * Defines if the material uses sheen.
  20492. */
  20493. isEnabled: boolean;
  20494. private _linkSheenWithAlbedo;
  20495. /**
  20496. * Defines if the sheen is linked to the sheen color.
  20497. */
  20498. linkSheenWithAlbedo: boolean;
  20499. /**
  20500. * Defines the sheen intensity.
  20501. */
  20502. intensity: number;
  20503. /**
  20504. * Defines the sheen color.
  20505. */
  20506. color: Color3;
  20507. private _texture;
  20508. /**
  20509. * Stores the sheen tint values in a texture.
  20510. * rgb is tint
  20511. * 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)
  20512. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20513. */
  20514. texture: Nullable<BaseTexture>;
  20515. private _useRoughnessFromMainTexture;
  20516. /**
  20517. * Indicates that the alpha channel of the texture property will be used for roughness.
  20518. * Has no effect if the roughness (and texture!) property is not defined
  20519. */
  20520. useRoughnessFromMainTexture: boolean;
  20521. private _roughness;
  20522. /**
  20523. * Defines the sheen roughness.
  20524. * It is not taken into account if linkSheenWithAlbedo is true.
  20525. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20526. */
  20527. roughness: Nullable<number>;
  20528. private _textureRoughness;
  20529. /**
  20530. * Stores the sheen roughness in a texture.
  20531. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20532. */
  20533. textureRoughness: Nullable<BaseTexture>;
  20534. private _albedoScaling;
  20535. /**
  20536. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20537. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20538. * making it easier to setup and tweak the effect
  20539. */
  20540. albedoScaling: boolean;
  20541. /** @hidden */
  20542. private _internalMarkAllSubMeshesAsTexturesDirty;
  20543. /** @hidden */
  20544. _markAllSubMeshesAsTexturesDirty(): void;
  20545. /**
  20546. * Instantiate a new istance of clear coat configuration.
  20547. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20548. */
  20549. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20550. /**
  20551. * Specifies that the submesh is ready to be used.
  20552. * @param defines the list of "defines" to update.
  20553. * @param scene defines the scene the material belongs to.
  20554. * @returns - boolean indicating that the submesh is ready or not.
  20555. */
  20556. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20557. /**
  20558. * Checks to see if a texture is used in the material.
  20559. * @param defines the list of "defines" to update.
  20560. * @param scene defines the scene the material belongs to.
  20561. */
  20562. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20563. /**
  20564. * Binds the material data.
  20565. * @param uniformBuffer defines the Uniform buffer to fill in.
  20566. * @param scene defines the scene the material belongs to.
  20567. * @param isFrozen defines wether the material is frozen or not.
  20568. * @param subMesh the submesh to bind data for
  20569. */
  20570. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20571. /**
  20572. * Checks to see if a texture is used in the material.
  20573. * @param texture - Base texture to use.
  20574. * @returns - Boolean specifying if a texture is used in the material.
  20575. */
  20576. hasTexture(texture: BaseTexture): boolean;
  20577. /**
  20578. * Returns an array of the actively used textures.
  20579. * @param activeTextures Array of BaseTextures
  20580. */
  20581. getActiveTextures(activeTextures: BaseTexture[]): void;
  20582. /**
  20583. * Returns the animatable textures.
  20584. * @param animatables Array of animatable textures.
  20585. */
  20586. getAnimatables(animatables: IAnimatable[]): void;
  20587. /**
  20588. * Disposes the resources of the material.
  20589. * @param forceDisposeTextures - Forces the disposal of all textures.
  20590. */
  20591. dispose(forceDisposeTextures?: boolean): void;
  20592. /**
  20593. * Get the current class name of the texture useful for serialization or dynamic coding.
  20594. * @returns "PBRSheenConfiguration"
  20595. */
  20596. getClassName(): string;
  20597. /**
  20598. * Add fallbacks to the effect fallbacks list.
  20599. * @param defines defines the Base texture to use.
  20600. * @param fallbacks defines the current fallback list.
  20601. * @param currentRank defines the current fallback rank.
  20602. * @returns the new fallback rank.
  20603. */
  20604. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20605. /**
  20606. * Add the required uniforms to the current list.
  20607. * @param uniforms defines the current uniform list.
  20608. */
  20609. static AddUniforms(uniforms: string[]): void;
  20610. /**
  20611. * Add the required uniforms to the current buffer.
  20612. * @param uniformBuffer defines the current uniform buffer.
  20613. */
  20614. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20615. /**
  20616. * Add the required samplers to the current list.
  20617. * @param samplers defines the current sampler list.
  20618. */
  20619. static AddSamplers(samplers: string[]): void;
  20620. /**
  20621. * Makes a duplicate of the current configuration into another one.
  20622. * @param sheenConfiguration define the config where to copy the info
  20623. */
  20624. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20625. /**
  20626. * Serializes this BRDF configuration.
  20627. * @returns - An object with the serialized config.
  20628. */
  20629. serialize(): any;
  20630. /**
  20631. * Parses a anisotropy Configuration from a serialized object.
  20632. * @param source - Serialized object.
  20633. * @param scene Defines the scene we are parsing for
  20634. * @param rootUrl Defines the rootUrl to load from
  20635. */
  20636. parse(source: any, scene: Scene, rootUrl: string): void;
  20637. }
  20638. }
  20639. declare module BABYLON {
  20640. /**
  20641. * @hidden
  20642. */
  20643. export interface IMaterialSubSurfaceDefines {
  20644. SUBSURFACE: boolean;
  20645. SS_REFRACTION: boolean;
  20646. SS_TRANSLUCENCY: boolean;
  20647. SS_SCATTERING: boolean;
  20648. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20649. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20650. SS_REFRACTIONMAP_3D: boolean;
  20651. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20652. SS_LODINREFRACTIONALPHA: boolean;
  20653. SS_GAMMAREFRACTION: boolean;
  20654. SS_RGBDREFRACTION: boolean;
  20655. SS_LINEARSPECULARREFRACTION: boolean;
  20656. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20657. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20658. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20659. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20660. /** @hidden */
  20661. _areTexturesDirty: boolean;
  20662. }
  20663. /**
  20664. * Define the code related to the sub surface parameters of the pbr material.
  20665. */
  20666. export class PBRSubSurfaceConfiguration {
  20667. private _isRefractionEnabled;
  20668. /**
  20669. * Defines if the refraction is enabled in the material.
  20670. */
  20671. isRefractionEnabled: boolean;
  20672. private _isTranslucencyEnabled;
  20673. /**
  20674. * Defines if the translucency is enabled in the material.
  20675. */
  20676. isTranslucencyEnabled: boolean;
  20677. private _isScatteringEnabled;
  20678. /**
  20679. * Defines if the sub surface scattering is enabled in the material.
  20680. */
  20681. isScatteringEnabled: boolean;
  20682. private _scatteringDiffusionProfileIndex;
  20683. /**
  20684. * Diffusion profile for subsurface scattering.
  20685. * Useful for better scattering in the skins or foliages.
  20686. */
  20687. get scatteringDiffusionProfile(): Nullable<Color3>;
  20688. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20689. /**
  20690. * Defines the refraction intensity of the material.
  20691. * The refraction when enabled replaces the Diffuse part of the material.
  20692. * The intensity helps transitionning between diffuse and refraction.
  20693. */
  20694. refractionIntensity: number;
  20695. /**
  20696. * Defines the translucency intensity of the material.
  20697. * When translucency has been enabled, this defines how much of the "translucency"
  20698. * is addded to the diffuse part of the material.
  20699. */
  20700. translucencyIntensity: number;
  20701. /**
  20702. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20703. */
  20704. useAlbedoToTintRefraction: boolean;
  20705. private _thicknessTexture;
  20706. /**
  20707. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20708. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20709. * 0 would mean minimumThickness
  20710. * 1 would mean maximumThickness
  20711. * The other channels might be use as a mask to vary the different effects intensity.
  20712. */
  20713. thicknessTexture: Nullable<BaseTexture>;
  20714. private _refractionTexture;
  20715. /**
  20716. * Defines the texture to use for refraction.
  20717. */
  20718. refractionTexture: Nullable<BaseTexture>;
  20719. private _indexOfRefraction;
  20720. /**
  20721. * Index of refraction of the material base layer.
  20722. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20723. *
  20724. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20725. *
  20726. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20727. */
  20728. indexOfRefraction: number;
  20729. private _volumeIndexOfRefraction;
  20730. /**
  20731. * Index of refraction of the material's volume.
  20732. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20733. *
  20734. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20735. * the volume will use the same IOR as the surface.
  20736. */
  20737. get volumeIndexOfRefraction(): number;
  20738. set volumeIndexOfRefraction(value: number);
  20739. private _invertRefractionY;
  20740. /**
  20741. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20742. */
  20743. invertRefractionY: boolean;
  20744. private _linkRefractionWithTransparency;
  20745. /**
  20746. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20747. * Materials half opaque for instance using refraction could benefit from this control.
  20748. */
  20749. linkRefractionWithTransparency: boolean;
  20750. /**
  20751. * Defines the minimum thickness stored in the thickness map.
  20752. * If no thickness map is defined, this value will be used to simulate thickness.
  20753. */
  20754. minimumThickness: number;
  20755. /**
  20756. * Defines the maximum thickness stored in the thickness map.
  20757. */
  20758. maximumThickness: number;
  20759. /**
  20760. * Defines the volume tint of the material.
  20761. * This is used for both translucency and scattering.
  20762. */
  20763. tintColor: Color3;
  20764. /**
  20765. * Defines the distance at which the tint color should be found in the media.
  20766. * This is used for refraction only.
  20767. */
  20768. tintColorAtDistance: number;
  20769. /**
  20770. * Defines how far each channel transmit through the media.
  20771. * It is defined as a color to simplify it selection.
  20772. */
  20773. diffusionDistance: Color3;
  20774. private _useMaskFromThicknessTexture;
  20775. /**
  20776. * Stores the intensity of the different subsurface effects in the thickness texture.
  20777. * * the green channel is the translucency intensity.
  20778. * * the blue channel is the scattering intensity.
  20779. * * the alpha channel is the refraction intensity.
  20780. */
  20781. useMaskFromThicknessTexture: boolean;
  20782. private _scene;
  20783. private _useMaskFromThicknessTextureGltf;
  20784. /**
  20785. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20786. * matches the channel-packing that is used by glTF.
  20787. * * the red channel is the transmission/translucency intensity.
  20788. * * the green channel is the thickness.
  20789. */
  20790. useMaskFromThicknessTextureGltf: boolean;
  20791. /** @hidden */
  20792. private _internalMarkAllSubMeshesAsTexturesDirty;
  20793. private _internalMarkScenePrePassDirty;
  20794. /** @hidden */
  20795. _markAllSubMeshesAsTexturesDirty(): void;
  20796. /** @hidden */
  20797. _markScenePrePassDirty(): void;
  20798. /**
  20799. * Instantiate a new istance of sub surface configuration.
  20800. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20801. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20802. * @param scene The scene
  20803. */
  20804. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20805. /**
  20806. * Gets wehter the submesh is ready to be used or not.
  20807. * @param defines the list of "defines" to update.
  20808. * @param scene defines the scene the material belongs to.
  20809. * @returns - boolean indicating that the submesh is ready or not.
  20810. */
  20811. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20812. /**
  20813. * Checks to see if a texture is used in the material.
  20814. * @param defines the list of "defines" to update.
  20815. * @param scene defines the scene to the material belongs to.
  20816. */
  20817. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20818. /**
  20819. * Binds the material data.
  20820. * @param uniformBuffer defines the Uniform buffer to fill in.
  20821. * @param scene defines the scene the material belongs to.
  20822. * @param engine defines the engine the material belongs to.
  20823. * @param isFrozen defines whether the material is frozen or not.
  20824. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20825. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20826. */
  20827. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20828. /**
  20829. * Unbinds the material from the mesh.
  20830. * @param activeEffect defines the effect that should be unbound from.
  20831. * @returns true if unbound, otherwise false
  20832. */
  20833. unbind(activeEffect: Effect): boolean;
  20834. /**
  20835. * Returns the texture used for refraction or null if none is used.
  20836. * @param scene defines the scene the material belongs to.
  20837. * @returns - Refraction texture if present. If no refraction texture and refraction
  20838. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20839. */
  20840. private _getRefractionTexture;
  20841. /**
  20842. * Returns true if alpha blending should be disabled.
  20843. */
  20844. get disableAlphaBlending(): boolean;
  20845. /**
  20846. * Fills the list of render target textures.
  20847. * @param renderTargets the list of render targets to update
  20848. */
  20849. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20850. /**
  20851. * Checks to see if a texture is used in the material.
  20852. * @param texture - Base texture to use.
  20853. * @returns - Boolean specifying if a texture is used in the material.
  20854. */
  20855. hasTexture(texture: BaseTexture): boolean;
  20856. /**
  20857. * Gets a boolean indicating that current material needs to register RTT
  20858. * @returns true if this uses a render target otherwise false.
  20859. */
  20860. hasRenderTargetTextures(): boolean;
  20861. /**
  20862. * Returns an array of the actively used textures.
  20863. * @param activeTextures Array of BaseTextures
  20864. */
  20865. getActiveTextures(activeTextures: BaseTexture[]): void;
  20866. /**
  20867. * Returns the animatable textures.
  20868. * @param animatables Array of animatable textures.
  20869. */
  20870. getAnimatables(animatables: IAnimatable[]): void;
  20871. /**
  20872. * Disposes the resources of the material.
  20873. * @param forceDisposeTextures - Forces the disposal of all textures.
  20874. */
  20875. dispose(forceDisposeTextures?: boolean): void;
  20876. /**
  20877. * Get the current class name of the texture useful for serialization or dynamic coding.
  20878. * @returns "PBRSubSurfaceConfiguration"
  20879. */
  20880. getClassName(): string;
  20881. /**
  20882. * Add fallbacks to the effect fallbacks list.
  20883. * @param defines defines the Base texture to use.
  20884. * @param fallbacks defines the current fallback list.
  20885. * @param currentRank defines the current fallback rank.
  20886. * @returns the new fallback rank.
  20887. */
  20888. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20889. /**
  20890. * Add the required uniforms to the current list.
  20891. * @param uniforms defines the current uniform list.
  20892. */
  20893. static AddUniforms(uniforms: string[]): void;
  20894. /**
  20895. * Add the required samplers to the current list.
  20896. * @param samplers defines the current sampler list.
  20897. */
  20898. static AddSamplers(samplers: string[]): void;
  20899. /**
  20900. * Add the required uniforms to the current buffer.
  20901. * @param uniformBuffer defines the current uniform buffer.
  20902. */
  20903. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20904. /**
  20905. * Makes a duplicate of the current configuration into another one.
  20906. * @param configuration define the config where to copy the info
  20907. */
  20908. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20909. /**
  20910. * Serializes this Sub Surface configuration.
  20911. * @returns - An object with the serialized config.
  20912. */
  20913. serialize(): any;
  20914. /**
  20915. * Parses a anisotropy Configuration from a serialized object.
  20916. * @param source - Serialized object.
  20917. * @param scene Defines the scene we are parsing for
  20918. * @param rootUrl Defines the rootUrl to load from
  20919. */
  20920. parse(source: any, scene: Scene, rootUrl: string): void;
  20921. }
  20922. }
  20923. declare module BABYLON {
  20924. /**
  20925. * Class representing spherical harmonics coefficients to the 3rd degree
  20926. */
  20927. export class SphericalHarmonics {
  20928. /**
  20929. * Defines whether or not the harmonics have been prescaled for rendering.
  20930. */
  20931. preScaled: boolean;
  20932. /**
  20933. * The l0,0 coefficients of the spherical harmonics
  20934. */
  20935. l00: Vector3;
  20936. /**
  20937. * The l1,-1 coefficients of the spherical harmonics
  20938. */
  20939. l1_1: Vector3;
  20940. /**
  20941. * The l1,0 coefficients of the spherical harmonics
  20942. */
  20943. l10: Vector3;
  20944. /**
  20945. * The l1,1 coefficients of the spherical harmonics
  20946. */
  20947. l11: Vector3;
  20948. /**
  20949. * The l2,-2 coefficients of the spherical harmonics
  20950. */
  20951. l2_2: Vector3;
  20952. /**
  20953. * The l2,-1 coefficients of the spherical harmonics
  20954. */
  20955. l2_1: Vector3;
  20956. /**
  20957. * The l2,0 coefficients of the spherical harmonics
  20958. */
  20959. l20: Vector3;
  20960. /**
  20961. * The l2,1 coefficients of the spherical harmonics
  20962. */
  20963. l21: Vector3;
  20964. /**
  20965. * The l2,2 coefficients of the spherical harmonics
  20966. */
  20967. l22: Vector3;
  20968. /**
  20969. * Adds a light to the spherical harmonics
  20970. * @param direction the direction of the light
  20971. * @param color the color of the light
  20972. * @param deltaSolidAngle the delta solid angle of the light
  20973. */
  20974. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20975. /**
  20976. * Scales the spherical harmonics by the given amount
  20977. * @param scale the amount to scale
  20978. */
  20979. scaleInPlace(scale: number): void;
  20980. /**
  20981. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20982. *
  20983. * ```
  20984. * E_lm = A_l * L_lm
  20985. * ```
  20986. *
  20987. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20988. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20989. * the scaling factors are given in equation 9.
  20990. */
  20991. convertIncidentRadianceToIrradiance(): void;
  20992. /**
  20993. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  20994. *
  20995. * ```
  20996. * L = (1/pi) * E * rho
  20997. * ```
  20998. *
  20999. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21000. */
  21001. convertIrradianceToLambertianRadiance(): void;
  21002. /**
  21003. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21004. * required operations at run time.
  21005. *
  21006. * This is simply done by scaling back the SH with Ylm constants parameter.
  21007. * The trigonometric part being applied by the shader at run time.
  21008. */
  21009. preScaleForRendering(): void;
  21010. /**
  21011. * Constructs a spherical harmonics from an array.
  21012. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21013. * @returns the spherical harmonics
  21014. */
  21015. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21016. /**
  21017. * Gets the spherical harmonics from polynomial
  21018. * @param polynomial the spherical polynomial
  21019. * @returns the spherical harmonics
  21020. */
  21021. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21022. }
  21023. /**
  21024. * Class representing spherical polynomial coefficients to the 3rd degree
  21025. */
  21026. export class SphericalPolynomial {
  21027. private _harmonics;
  21028. /**
  21029. * The spherical harmonics used to create the polynomials.
  21030. */
  21031. get preScaledHarmonics(): SphericalHarmonics;
  21032. /**
  21033. * The x coefficients of the spherical polynomial
  21034. */
  21035. x: Vector3;
  21036. /**
  21037. * The y coefficients of the spherical polynomial
  21038. */
  21039. y: Vector3;
  21040. /**
  21041. * The z coefficients of the spherical polynomial
  21042. */
  21043. z: Vector3;
  21044. /**
  21045. * The xx coefficients of the spherical polynomial
  21046. */
  21047. xx: Vector3;
  21048. /**
  21049. * The yy coefficients of the spherical polynomial
  21050. */
  21051. yy: Vector3;
  21052. /**
  21053. * The zz coefficients of the spherical polynomial
  21054. */
  21055. zz: Vector3;
  21056. /**
  21057. * The xy coefficients of the spherical polynomial
  21058. */
  21059. xy: Vector3;
  21060. /**
  21061. * The yz coefficients of the spherical polynomial
  21062. */
  21063. yz: Vector3;
  21064. /**
  21065. * The zx coefficients of the spherical polynomial
  21066. */
  21067. zx: Vector3;
  21068. /**
  21069. * Adds an ambient color to the spherical polynomial
  21070. * @param color the color to add
  21071. */
  21072. addAmbient(color: Color3): void;
  21073. /**
  21074. * Scales the spherical polynomial by the given amount
  21075. * @param scale the amount to scale
  21076. */
  21077. scaleInPlace(scale: number): void;
  21078. /**
  21079. * Gets the spherical polynomial from harmonics
  21080. * @param harmonics the spherical harmonics
  21081. * @returns the spherical polynomial
  21082. */
  21083. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21084. /**
  21085. * Constructs a spherical polynomial from an array.
  21086. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21087. * @returns the spherical polynomial
  21088. */
  21089. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21090. }
  21091. }
  21092. declare module BABYLON {
  21093. /**
  21094. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21095. */
  21096. export interface CubeMapInfo {
  21097. /**
  21098. * The pixel array for the front face.
  21099. * This is stored in format, left to right, up to down format.
  21100. */
  21101. front: Nullable<ArrayBufferView>;
  21102. /**
  21103. * The pixel array for the back face.
  21104. * This is stored in format, left to right, up to down format.
  21105. */
  21106. back: Nullable<ArrayBufferView>;
  21107. /**
  21108. * The pixel array for the left face.
  21109. * This is stored in format, left to right, up to down format.
  21110. */
  21111. left: Nullable<ArrayBufferView>;
  21112. /**
  21113. * The pixel array for the right face.
  21114. * This is stored in format, left to right, up to down format.
  21115. */
  21116. right: Nullable<ArrayBufferView>;
  21117. /**
  21118. * The pixel array for the up face.
  21119. * This is stored in format, left to right, up to down format.
  21120. */
  21121. up: Nullable<ArrayBufferView>;
  21122. /**
  21123. * The pixel array for the down face.
  21124. * This is stored in format, left to right, up to down format.
  21125. */
  21126. down: Nullable<ArrayBufferView>;
  21127. /**
  21128. * The size of the cubemap stored.
  21129. *
  21130. * Each faces will be size * size pixels.
  21131. */
  21132. size: number;
  21133. /**
  21134. * The format of the texture.
  21135. *
  21136. * RGBA, RGB.
  21137. */
  21138. format: number;
  21139. /**
  21140. * The type of the texture data.
  21141. *
  21142. * UNSIGNED_INT, FLOAT.
  21143. */
  21144. type: number;
  21145. /**
  21146. * Specifies whether the texture is in gamma space.
  21147. */
  21148. gammaSpace: boolean;
  21149. }
  21150. /**
  21151. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21152. */
  21153. export class PanoramaToCubeMapTools {
  21154. private static FACE_LEFT;
  21155. private static FACE_RIGHT;
  21156. private static FACE_FRONT;
  21157. private static FACE_BACK;
  21158. private static FACE_DOWN;
  21159. private static FACE_UP;
  21160. /**
  21161. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21162. *
  21163. * @param float32Array The source data.
  21164. * @param inputWidth The width of the input panorama.
  21165. * @param inputHeight The height of the input panorama.
  21166. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21167. * @return The cubemap data
  21168. */
  21169. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21170. private static CreateCubemapTexture;
  21171. private static CalcProjectionSpherical;
  21172. }
  21173. }
  21174. declare module BABYLON {
  21175. /**
  21176. * Helper class dealing with the extraction of spherical polynomial dataArray
  21177. * from a cube map.
  21178. */
  21179. export class CubeMapToSphericalPolynomialTools {
  21180. private static FileFaces;
  21181. /**
  21182. * Converts a texture to the according Spherical Polynomial data.
  21183. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21184. *
  21185. * @param texture The texture to extract the information from.
  21186. * @return The Spherical Polynomial data.
  21187. */
  21188. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21189. /**
  21190. * Converts a cubemap to the according Spherical Polynomial data.
  21191. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21192. *
  21193. * @param cubeInfo The Cube map to extract the information from.
  21194. * @return The Spherical Polynomial data.
  21195. */
  21196. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21197. }
  21198. }
  21199. declare module BABYLON {
  21200. interface BaseTexture {
  21201. /**
  21202. * Get the polynomial representation of the texture data.
  21203. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21204. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21205. */
  21206. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21207. }
  21208. }
  21209. declare module BABYLON {
  21210. /** @hidden */
  21211. export var pbrFragmentDeclaration: {
  21212. name: string;
  21213. shader: string;
  21214. };
  21215. }
  21216. declare module BABYLON {
  21217. /** @hidden */
  21218. export var pbrUboDeclaration: {
  21219. name: string;
  21220. shader: string;
  21221. };
  21222. }
  21223. declare module BABYLON {
  21224. /** @hidden */
  21225. export var pbrFragmentExtraDeclaration: {
  21226. name: string;
  21227. shader: string;
  21228. };
  21229. }
  21230. declare module BABYLON {
  21231. /** @hidden */
  21232. export var pbrFragmentSamplersDeclaration: {
  21233. name: string;
  21234. shader: string;
  21235. };
  21236. }
  21237. declare module BABYLON {
  21238. /** @hidden */
  21239. export var subSurfaceScatteringFunctions: {
  21240. name: string;
  21241. shader: string;
  21242. };
  21243. }
  21244. declare module BABYLON {
  21245. /** @hidden */
  21246. export var importanceSampling: {
  21247. name: string;
  21248. shader: string;
  21249. };
  21250. }
  21251. declare module BABYLON {
  21252. /** @hidden */
  21253. export var pbrHelperFunctions: {
  21254. name: string;
  21255. shader: string;
  21256. };
  21257. }
  21258. declare module BABYLON {
  21259. /** @hidden */
  21260. export var harmonicsFunctions: {
  21261. name: string;
  21262. shader: string;
  21263. };
  21264. }
  21265. declare module BABYLON {
  21266. /** @hidden */
  21267. export var pbrDirectLightingSetupFunctions: {
  21268. name: string;
  21269. shader: string;
  21270. };
  21271. }
  21272. declare module BABYLON {
  21273. /** @hidden */
  21274. export var pbrDirectLightingFalloffFunctions: {
  21275. name: string;
  21276. shader: string;
  21277. };
  21278. }
  21279. declare module BABYLON {
  21280. /** @hidden */
  21281. export var pbrBRDFFunctions: {
  21282. name: string;
  21283. shader: string;
  21284. };
  21285. }
  21286. declare module BABYLON {
  21287. /** @hidden */
  21288. export var hdrFilteringFunctions: {
  21289. name: string;
  21290. shader: string;
  21291. };
  21292. }
  21293. declare module BABYLON {
  21294. /** @hidden */
  21295. export var pbrDirectLightingFunctions: {
  21296. name: string;
  21297. shader: string;
  21298. };
  21299. }
  21300. declare module BABYLON {
  21301. /** @hidden */
  21302. export var pbrIBLFunctions: {
  21303. name: string;
  21304. shader: string;
  21305. };
  21306. }
  21307. declare module BABYLON {
  21308. /** @hidden */
  21309. export var pbrBlockAlbedoOpacity: {
  21310. name: string;
  21311. shader: string;
  21312. };
  21313. }
  21314. declare module BABYLON {
  21315. /** @hidden */
  21316. export var pbrBlockReflectivity: {
  21317. name: string;
  21318. shader: string;
  21319. };
  21320. }
  21321. declare module BABYLON {
  21322. /** @hidden */
  21323. export var pbrBlockAmbientOcclusion: {
  21324. name: string;
  21325. shader: string;
  21326. };
  21327. }
  21328. declare module BABYLON {
  21329. /** @hidden */
  21330. export var pbrBlockAlphaFresnel: {
  21331. name: string;
  21332. shader: string;
  21333. };
  21334. }
  21335. declare module BABYLON {
  21336. /** @hidden */
  21337. export var pbrBlockAnisotropic: {
  21338. name: string;
  21339. shader: string;
  21340. };
  21341. }
  21342. declare module BABYLON {
  21343. /** @hidden */
  21344. export var pbrBlockReflection: {
  21345. name: string;
  21346. shader: string;
  21347. };
  21348. }
  21349. declare module BABYLON {
  21350. /** @hidden */
  21351. export var pbrBlockSheen: {
  21352. name: string;
  21353. shader: string;
  21354. };
  21355. }
  21356. declare module BABYLON {
  21357. /** @hidden */
  21358. export var pbrBlockClearcoat: {
  21359. name: string;
  21360. shader: string;
  21361. };
  21362. }
  21363. declare module BABYLON {
  21364. /** @hidden */
  21365. export var pbrBlockSubSurface: {
  21366. name: string;
  21367. shader: string;
  21368. };
  21369. }
  21370. declare module BABYLON {
  21371. /** @hidden */
  21372. export var pbrBlockNormalGeometric: {
  21373. name: string;
  21374. shader: string;
  21375. };
  21376. }
  21377. declare module BABYLON {
  21378. /** @hidden */
  21379. export var pbrBlockNormalFinal: {
  21380. name: string;
  21381. shader: string;
  21382. };
  21383. }
  21384. declare module BABYLON {
  21385. /** @hidden */
  21386. export var pbrBlockLightmapInit: {
  21387. name: string;
  21388. shader: string;
  21389. };
  21390. }
  21391. declare module BABYLON {
  21392. /** @hidden */
  21393. export var pbrBlockGeometryInfo: {
  21394. name: string;
  21395. shader: string;
  21396. };
  21397. }
  21398. declare module BABYLON {
  21399. /** @hidden */
  21400. export var pbrBlockReflectance0: {
  21401. name: string;
  21402. shader: string;
  21403. };
  21404. }
  21405. declare module BABYLON {
  21406. /** @hidden */
  21407. export var pbrBlockReflectance: {
  21408. name: string;
  21409. shader: string;
  21410. };
  21411. }
  21412. declare module BABYLON {
  21413. /** @hidden */
  21414. export var pbrBlockDirectLighting: {
  21415. name: string;
  21416. shader: string;
  21417. };
  21418. }
  21419. declare module BABYLON {
  21420. /** @hidden */
  21421. export var pbrBlockFinalLitComponents: {
  21422. name: string;
  21423. shader: string;
  21424. };
  21425. }
  21426. declare module BABYLON {
  21427. /** @hidden */
  21428. export var pbrBlockFinalUnlitComponents: {
  21429. name: string;
  21430. shader: string;
  21431. };
  21432. }
  21433. declare module BABYLON {
  21434. /** @hidden */
  21435. export var pbrBlockFinalColorComposition: {
  21436. name: string;
  21437. shader: string;
  21438. };
  21439. }
  21440. declare module BABYLON {
  21441. /** @hidden */
  21442. export var pbrBlockImageProcessing: {
  21443. name: string;
  21444. shader: string;
  21445. };
  21446. }
  21447. declare module BABYLON {
  21448. /** @hidden */
  21449. export var pbrDebug: {
  21450. name: string;
  21451. shader: string;
  21452. };
  21453. }
  21454. declare module BABYLON {
  21455. /** @hidden */
  21456. export var pbrPixelShader: {
  21457. name: string;
  21458. shader: string;
  21459. };
  21460. }
  21461. declare module BABYLON {
  21462. /** @hidden */
  21463. export var pbrVertexDeclaration: {
  21464. name: string;
  21465. shader: string;
  21466. };
  21467. }
  21468. declare module BABYLON {
  21469. /** @hidden */
  21470. export var pbrVertexShader: {
  21471. name: string;
  21472. shader: string;
  21473. };
  21474. }
  21475. declare module BABYLON {
  21476. /**
  21477. * Manages the defines for the PBR Material.
  21478. * @hidden
  21479. */
  21480. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21481. PBR: boolean;
  21482. NUM_SAMPLES: string;
  21483. REALTIME_FILTERING: boolean;
  21484. MAINUV1: boolean;
  21485. MAINUV2: boolean;
  21486. UV1: boolean;
  21487. UV2: boolean;
  21488. ALBEDO: boolean;
  21489. GAMMAALBEDO: boolean;
  21490. ALBEDODIRECTUV: number;
  21491. VERTEXCOLOR: boolean;
  21492. DETAIL: boolean;
  21493. DETAILDIRECTUV: number;
  21494. DETAIL_NORMALBLENDMETHOD: number;
  21495. AMBIENT: boolean;
  21496. AMBIENTDIRECTUV: number;
  21497. AMBIENTINGRAYSCALE: boolean;
  21498. OPACITY: boolean;
  21499. VERTEXALPHA: boolean;
  21500. OPACITYDIRECTUV: number;
  21501. OPACITYRGB: boolean;
  21502. ALPHATEST: boolean;
  21503. DEPTHPREPASS: boolean;
  21504. ALPHABLEND: boolean;
  21505. ALPHAFROMALBEDO: boolean;
  21506. ALPHATESTVALUE: string;
  21507. SPECULAROVERALPHA: boolean;
  21508. RADIANCEOVERALPHA: boolean;
  21509. ALPHAFRESNEL: boolean;
  21510. LINEARALPHAFRESNEL: boolean;
  21511. PREMULTIPLYALPHA: boolean;
  21512. EMISSIVE: boolean;
  21513. EMISSIVEDIRECTUV: number;
  21514. REFLECTIVITY: boolean;
  21515. REFLECTIVITYDIRECTUV: number;
  21516. SPECULARTERM: boolean;
  21517. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21518. MICROSURFACEAUTOMATIC: boolean;
  21519. LODBASEDMICROSFURACE: boolean;
  21520. MICROSURFACEMAP: boolean;
  21521. MICROSURFACEMAPDIRECTUV: number;
  21522. METALLICWORKFLOW: boolean;
  21523. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21524. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21525. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21526. AOSTOREINMETALMAPRED: boolean;
  21527. METALLIC_REFLECTANCE: boolean;
  21528. METALLIC_REFLECTANCEDIRECTUV: number;
  21529. ENVIRONMENTBRDF: boolean;
  21530. ENVIRONMENTBRDF_RGBD: boolean;
  21531. NORMAL: boolean;
  21532. TANGENT: boolean;
  21533. BUMP: boolean;
  21534. BUMPDIRECTUV: number;
  21535. OBJECTSPACE_NORMALMAP: boolean;
  21536. PARALLAX: boolean;
  21537. PARALLAXOCCLUSION: boolean;
  21538. NORMALXYSCALE: boolean;
  21539. LIGHTMAP: boolean;
  21540. LIGHTMAPDIRECTUV: number;
  21541. USELIGHTMAPASSHADOWMAP: boolean;
  21542. GAMMALIGHTMAP: boolean;
  21543. RGBDLIGHTMAP: boolean;
  21544. REFLECTION: boolean;
  21545. REFLECTIONMAP_3D: boolean;
  21546. REFLECTIONMAP_SPHERICAL: boolean;
  21547. REFLECTIONMAP_PLANAR: boolean;
  21548. REFLECTIONMAP_CUBIC: boolean;
  21549. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21550. REFLECTIONMAP_PROJECTION: boolean;
  21551. REFLECTIONMAP_SKYBOX: boolean;
  21552. REFLECTIONMAP_EXPLICIT: boolean;
  21553. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21554. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21555. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21556. INVERTCUBICMAP: boolean;
  21557. USESPHERICALFROMREFLECTIONMAP: boolean;
  21558. USEIRRADIANCEMAP: boolean;
  21559. SPHERICAL_HARMONICS: boolean;
  21560. USESPHERICALINVERTEX: boolean;
  21561. REFLECTIONMAP_OPPOSITEZ: boolean;
  21562. LODINREFLECTIONALPHA: boolean;
  21563. GAMMAREFLECTION: boolean;
  21564. RGBDREFLECTION: boolean;
  21565. LINEARSPECULARREFLECTION: boolean;
  21566. RADIANCEOCCLUSION: boolean;
  21567. HORIZONOCCLUSION: boolean;
  21568. INSTANCES: boolean;
  21569. THIN_INSTANCES: boolean;
  21570. PREPASS: boolean;
  21571. PREPASS_IRRADIANCE: boolean;
  21572. PREPASS_IRRADIANCE_INDEX: number;
  21573. PREPASS_ALBEDO: boolean;
  21574. PREPASS_ALBEDO_INDEX: number;
  21575. PREPASS_DEPTHNORMAL: boolean;
  21576. PREPASS_DEPTHNORMAL_INDEX: number;
  21577. PREPASS_POSITION: boolean;
  21578. PREPASS_POSITION_INDEX: number;
  21579. PREPASS_VELOCITY: boolean;
  21580. PREPASS_VELOCITY_INDEX: number;
  21581. PREPASS_REFLECTIVITY: boolean;
  21582. PREPASS_REFLECTIVITY_INDEX: number;
  21583. SCENE_MRT_COUNT: number;
  21584. NUM_BONE_INFLUENCERS: number;
  21585. BonesPerMesh: number;
  21586. BONETEXTURE: boolean;
  21587. BONES_VELOCITY_ENABLED: boolean;
  21588. NONUNIFORMSCALING: boolean;
  21589. MORPHTARGETS: boolean;
  21590. MORPHTARGETS_NORMAL: boolean;
  21591. MORPHTARGETS_TANGENT: boolean;
  21592. MORPHTARGETS_UV: boolean;
  21593. NUM_MORPH_INFLUENCERS: number;
  21594. IMAGEPROCESSING: boolean;
  21595. VIGNETTE: boolean;
  21596. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21597. VIGNETTEBLENDMODEOPAQUE: boolean;
  21598. TONEMAPPING: boolean;
  21599. TONEMAPPING_ACES: boolean;
  21600. CONTRAST: boolean;
  21601. COLORCURVES: boolean;
  21602. COLORGRADING: boolean;
  21603. COLORGRADING3D: boolean;
  21604. SAMPLER3DGREENDEPTH: boolean;
  21605. SAMPLER3DBGRMAP: boolean;
  21606. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21607. EXPOSURE: boolean;
  21608. MULTIVIEW: boolean;
  21609. USEPHYSICALLIGHTFALLOFF: boolean;
  21610. USEGLTFLIGHTFALLOFF: boolean;
  21611. TWOSIDEDLIGHTING: boolean;
  21612. SHADOWFLOAT: boolean;
  21613. CLIPPLANE: boolean;
  21614. CLIPPLANE2: boolean;
  21615. CLIPPLANE3: boolean;
  21616. CLIPPLANE4: boolean;
  21617. CLIPPLANE5: boolean;
  21618. CLIPPLANE6: boolean;
  21619. POINTSIZE: boolean;
  21620. FOG: boolean;
  21621. LOGARITHMICDEPTH: boolean;
  21622. FORCENORMALFORWARD: boolean;
  21623. SPECULARAA: boolean;
  21624. CLEARCOAT: boolean;
  21625. CLEARCOAT_DEFAULTIOR: boolean;
  21626. CLEARCOAT_TEXTURE: boolean;
  21627. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21628. CLEARCOAT_TEXTUREDIRECTUV: number;
  21629. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21630. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21631. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21632. CLEARCOAT_BUMP: boolean;
  21633. CLEARCOAT_BUMPDIRECTUV: number;
  21634. CLEARCOAT_REMAP_F0: boolean;
  21635. CLEARCOAT_TINT: boolean;
  21636. CLEARCOAT_TINT_TEXTURE: boolean;
  21637. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21638. ANISOTROPIC: boolean;
  21639. ANISOTROPIC_TEXTURE: boolean;
  21640. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21641. BRDF_V_HEIGHT_CORRELATED: boolean;
  21642. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21643. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21644. SHEEN: boolean;
  21645. SHEEN_TEXTURE: boolean;
  21646. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21647. SHEEN_TEXTUREDIRECTUV: number;
  21648. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21649. SHEEN_LINKWITHALBEDO: boolean;
  21650. SHEEN_ROUGHNESS: boolean;
  21651. SHEEN_ALBEDOSCALING: boolean;
  21652. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21653. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21654. SUBSURFACE: boolean;
  21655. SS_REFRACTION: boolean;
  21656. SS_TRANSLUCENCY: boolean;
  21657. SS_SCATTERING: boolean;
  21658. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21659. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21660. SS_REFRACTIONMAP_3D: boolean;
  21661. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21662. SS_LODINREFRACTIONALPHA: boolean;
  21663. SS_GAMMAREFRACTION: boolean;
  21664. SS_RGBDREFRACTION: boolean;
  21665. SS_LINEARSPECULARREFRACTION: boolean;
  21666. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21667. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21668. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21669. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21670. UNLIT: boolean;
  21671. DEBUGMODE: number;
  21672. /**
  21673. * Initializes the PBR Material defines.
  21674. */
  21675. constructor();
  21676. /**
  21677. * Resets the PBR Material defines.
  21678. */
  21679. reset(): void;
  21680. }
  21681. /**
  21682. * The Physically based material base class of BJS.
  21683. *
  21684. * This offers the main features of a standard PBR material.
  21685. * For more information, please refer to the documentation :
  21686. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21687. */
  21688. export abstract class PBRBaseMaterial extends PushMaterial {
  21689. /**
  21690. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21691. */
  21692. static readonly PBRMATERIAL_OPAQUE: number;
  21693. /**
  21694. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21695. */
  21696. static readonly PBRMATERIAL_ALPHATEST: number;
  21697. /**
  21698. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21699. */
  21700. static readonly PBRMATERIAL_ALPHABLEND: number;
  21701. /**
  21702. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21703. * They are also discarded below the alpha cutoff threshold to improve performances.
  21704. */
  21705. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21706. /**
  21707. * Defines the default value of how much AO map is occluding the analytical lights
  21708. * (point spot...).
  21709. */
  21710. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21711. /**
  21712. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21713. */
  21714. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21715. /**
  21716. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21717. * to enhance interoperability with other engines.
  21718. */
  21719. static readonly LIGHTFALLOFF_GLTF: number;
  21720. /**
  21721. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21722. * to enhance interoperability with other materials.
  21723. */
  21724. static readonly LIGHTFALLOFF_STANDARD: number;
  21725. /**
  21726. * Intensity of the direct lights e.g. the four lights available in your scene.
  21727. * This impacts both the direct diffuse and specular highlights.
  21728. */
  21729. protected _directIntensity: number;
  21730. /**
  21731. * Intensity of the emissive part of the material.
  21732. * This helps controlling the emissive effect without modifying the emissive color.
  21733. */
  21734. protected _emissiveIntensity: number;
  21735. /**
  21736. * Intensity of the environment e.g. how much the environment will light the object
  21737. * either through harmonics for rough material or through the refelction for shiny ones.
  21738. */
  21739. protected _environmentIntensity: number;
  21740. /**
  21741. * This is a special control allowing the reduction of the specular highlights coming from the
  21742. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21743. */
  21744. protected _specularIntensity: number;
  21745. /**
  21746. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21747. */
  21748. private _lightingInfos;
  21749. /**
  21750. * Debug Control allowing disabling the bump map on this material.
  21751. */
  21752. protected _disableBumpMap: boolean;
  21753. /**
  21754. * AKA Diffuse Texture in standard nomenclature.
  21755. */
  21756. protected _albedoTexture: Nullable<BaseTexture>;
  21757. /**
  21758. * AKA Occlusion Texture in other nomenclature.
  21759. */
  21760. protected _ambientTexture: Nullable<BaseTexture>;
  21761. /**
  21762. * AKA Occlusion Texture Intensity in other nomenclature.
  21763. */
  21764. protected _ambientTextureStrength: number;
  21765. /**
  21766. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21767. * 1 means it completely occludes it
  21768. * 0 mean it has no impact
  21769. */
  21770. protected _ambientTextureImpactOnAnalyticalLights: number;
  21771. /**
  21772. * Stores the alpha values in a texture.
  21773. */
  21774. protected _opacityTexture: Nullable<BaseTexture>;
  21775. /**
  21776. * Stores the reflection values in a texture.
  21777. */
  21778. protected _reflectionTexture: Nullable<BaseTexture>;
  21779. /**
  21780. * Stores the emissive values in a texture.
  21781. */
  21782. protected _emissiveTexture: Nullable<BaseTexture>;
  21783. /**
  21784. * AKA Specular texture in other nomenclature.
  21785. */
  21786. protected _reflectivityTexture: Nullable<BaseTexture>;
  21787. /**
  21788. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21789. */
  21790. protected _metallicTexture: Nullable<BaseTexture>;
  21791. /**
  21792. * Specifies the metallic scalar of the metallic/roughness workflow.
  21793. * Can also be used to scale the metalness values of the metallic texture.
  21794. */
  21795. protected _metallic: Nullable<number>;
  21796. /**
  21797. * Specifies the roughness scalar of the metallic/roughness workflow.
  21798. * Can also be used to scale the roughness values of the metallic texture.
  21799. */
  21800. protected _roughness: Nullable<number>;
  21801. /**
  21802. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21803. * By default the indexOfrefraction is used to compute F0;
  21804. *
  21805. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21806. *
  21807. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21808. * F90 = metallicReflectanceColor;
  21809. */
  21810. protected _metallicF0Factor: number;
  21811. /**
  21812. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21813. * By default the F90 is always 1;
  21814. *
  21815. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21816. *
  21817. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21818. * F90 = metallicReflectanceColor;
  21819. */
  21820. protected _metallicReflectanceColor: Color3;
  21821. /**
  21822. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21823. * This is multiply against the scalar values defined in the material.
  21824. */
  21825. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21826. /**
  21827. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21828. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21829. */
  21830. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21831. /**
  21832. * Stores surface normal data used to displace a mesh in a texture.
  21833. */
  21834. protected _bumpTexture: Nullable<BaseTexture>;
  21835. /**
  21836. * Stores the pre-calculated light information of a mesh in a texture.
  21837. */
  21838. protected _lightmapTexture: Nullable<BaseTexture>;
  21839. /**
  21840. * The color of a material in ambient lighting.
  21841. */
  21842. protected _ambientColor: Color3;
  21843. /**
  21844. * AKA Diffuse Color in other nomenclature.
  21845. */
  21846. protected _albedoColor: Color3;
  21847. /**
  21848. * AKA Specular Color in other nomenclature.
  21849. */
  21850. protected _reflectivityColor: Color3;
  21851. /**
  21852. * The color applied when light is reflected from a material.
  21853. */
  21854. protected _reflectionColor: Color3;
  21855. /**
  21856. * The color applied when light is emitted from a material.
  21857. */
  21858. protected _emissiveColor: Color3;
  21859. /**
  21860. * AKA Glossiness in other nomenclature.
  21861. */
  21862. protected _microSurface: number;
  21863. /**
  21864. * Specifies that the material will use the light map as a show map.
  21865. */
  21866. protected _useLightmapAsShadowmap: boolean;
  21867. /**
  21868. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21869. * makes the reflect vector face the model (under horizon).
  21870. */
  21871. protected _useHorizonOcclusion: boolean;
  21872. /**
  21873. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21874. * too much the area relying on ambient texture to define their ambient occlusion.
  21875. */
  21876. protected _useRadianceOcclusion: boolean;
  21877. /**
  21878. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21879. */
  21880. protected _useAlphaFromAlbedoTexture: boolean;
  21881. /**
  21882. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21883. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21884. */
  21885. protected _useSpecularOverAlpha: boolean;
  21886. /**
  21887. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21888. */
  21889. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21890. /**
  21891. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21892. */
  21893. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21894. /**
  21895. * Specifies if the metallic texture contains the roughness information in its green channel.
  21896. */
  21897. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21898. /**
  21899. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21900. */
  21901. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21902. /**
  21903. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21904. */
  21905. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21906. /**
  21907. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21908. */
  21909. protected _useAmbientInGrayScale: boolean;
  21910. /**
  21911. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21912. * The material will try to infer what glossiness each pixel should be.
  21913. */
  21914. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21915. /**
  21916. * Defines the falloff type used in this material.
  21917. * It by default is Physical.
  21918. */
  21919. protected _lightFalloff: number;
  21920. /**
  21921. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21922. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21923. */
  21924. protected _useRadianceOverAlpha: boolean;
  21925. /**
  21926. * Allows using an object space normal map (instead of tangent space).
  21927. */
  21928. protected _useObjectSpaceNormalMap: boolean;
  21929. /**
  21930. * Allows using the bump map in parallax mode.
  21931. */
  21932. protected _useParallax: boolean;
  21933. /**
  21934. * Allows using the bump map in parallax occlusion mode.
  21935. */
  21936. protected _useParallaxOcclusion: boolean;
  21937. /**
  21938. * Controls the scale bias of the parallax mode.
  21939. */
  21940. protected _parallaxScaleBias: number;
  21941. /**
  21942. * If sets to true, disables all the lights affecting the material.
  21943. */
  21944. protected _disableLighting: boolean;
  21945. /**
  21946. * Number of Simultaneous lights allowed on the material.
  21947. */
  21948. protected _maxSimultaneousLights: number;
  21949. /**
  21950. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21951. */
  21952. protected _invertNormalMapX: boolean;
  21953. /**
  21954. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21955. */
  21956. protected _invertNormalMapY: boolean;
  21957. /**
  21958. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21959. */
  21960. protected _twoSidedLighting: boolean;
  21961. /**
  21962. * Defines the alpha limits in alpha test mode.
  21963. */
  21964. protected _alphaCutOff: number;
  21965. /**
  21966. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21967. */
  21968. protected _forceAlphaTest: boolean;
  21969. /**
  21970. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21971. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21972. */
  21973. protected _useAlphaFresnel: boolean;
  21974. /**
  21975. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21976. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21977. */
  21978. protected _useLinearAlphaFresnel: boolean;
  21979. /**
  21980. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  21981. * from cos thetav and roughness:
  21982. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  21983. */
  21984. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  21985. /**
  21986. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21987. */
  21988. protected _forceIrradianceInFragment: boolean;
  21989. private _realTimeFiltering;
  21990. /**
  21991. * Enables realtime filtering on the texture.
  21992. */
  21993. get realTimeFiltering(): boolean;
  21994. set realTimeFiltering(b: boolean);
  21995. private _realTimeFilteringQuality;
  21996. /**
  21997. * Quality switch for realtime filtering
  21998. */
  21999. get realTimeFilteringQuality(): number;
  22000. set realTimeFilteringQuality(n: number);
  22001. /**
  22002. * Can this material render to several textures at once
  22003. */
  22004. get canRenderToMRT(): boolean;
  22005. /**
  22006. * Force normal to face away from face.
  22007. */
  22008. protected _forceNormalForward: boolean;
  22009. /**
  22010. * Enables specular anti aliasing in the PBR shader.
  22011. * It will both interacts on the Geometry for analytical and IBL lighting.
  22012. * It also prefilter the roughness map based on the bump values.
  22013. */
  22014. protected _enableSpecularAntiAliasing: boolean;
  22015. /**
  22016. * Default configuration related to image processing available in the PBR Material.
  22017. */
  22018. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22019. /**
  22020. * Keep track of the image processing observer to allow dispose and replace.
  22021. */
  22022. private _imageProcessingObserver;
  22023. /**
  22024. * Attaches a new image processing configuration to the PBR Material.
  22025. * @param configuration
  22026. */
  22027. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22028. /**
  22029. * Stores the available render targets.
  22030. */
  22031. private _renderTargets;
  22032. /**
  22033. * Sets the global ambient color for the material used in lighting calculations.
  22034. */
  22035. private _globalAmbientColor;
  22036. /**
  22037. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22038. */
  22039. private _useLogarithmicDepth;
  22040. /**
  22041. * If set to true, no lighting calculations will be applied.
  22042. */
  22043. private _unlit;
  22044. private _debugMode;
  22045. /**
  22046. * @hidden
  22047. * This is reserved for the inspector.
  22048. * Defines the material debug mode.
  22049. * It helps seeing only some components of the material while troubleshooting.
  22050. */
  22051. debugMode: number;
  22052. /**
  22053. * @hidden
  22054. * This is reserved for the inspector.
  22055. * Specify from where on screen the debug mode should start.
  22056. * The value goes from -1 (full screen) to 1 (not visible)
  22057. * It helps with side by side comparison against the final render
  22058. * This defaults to -1
  22059. */
  22060. private debugLimit;
  22061. /**
  22062. * @hidden
  22063. * This is reserved for the inspector.
  22064. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22065. * You can use the factor to better multiply the final value.
  22066. */
  22067. private debugFactor;
  22068. /**
  22069. * Defines the clear coat layer parameters for the material.
  22070. */
  22071. readonly clearCoat: PBRClearCoatConfiguration;
  22072. /**
  22073. * Defines the anisotropic parameters for the material.
  22074. */
  22075. readonly anisotropy: PBRAnisotropicConfiguration;
  22076. /**
  22077. * Defines the BRDF parameters for the material.
  22078. */
  22079. readonly brdf: PBRBRDFConfiguration;
  22080. /**
  22081. * Defines the Sheen parameters for the material.
  22082. */
  22083. readonly sheen: PBRSheenConfiguration;
  22084. /**
  22085. * Defines the SubSurface parameters for the material.
  22086. */
  22087. readonly subSurface: PBRSubSurfaceConfiguration;
  22088. /**
  22089. * Defines additionnal PrePass parameters for the material.
  22090. */
  22091. readonly prePassConfiguration: PrePassConfiguration;
  22092. /**
  22093. * Defines the detail map parameters for the material.
  22094. */
  22095. readonly detailMap: DetailMapConfiguration;
  22096. protected _rebuildInParallel: boolean;
  22097. /**
  22098. * Instantiates a new PBRMaterial instance.
  22099. *
  22100. * @param name The material name
  22101. * @param scene The scene the material will be use in.
  22102. */
  22103. constructor(name: string, scene: Scene);
  22104. /**
  22105. * Gets a boolean indicating that current material needs to register RTT
  22106. */
  22107. get hasRenderTargetTextures(): boolean;
  22108. /**
  22109. * Gets the name of the material class.
  22110. */
  22111. getClassName(): string;
  22112. /**
  22113. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22114. */
  22115. get useLogarithmicDepth(): boolean;
  22116. /**
  22117. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22118. */
  22119. set useLogarithmicDepth(value: boolean);
  22120. /**
  22121. * Returns true if alpha blending should be disabled.
  22122. */
  22123. protected get _disableAlphaBlending(): boolean;
  22124. /**
  22125. * Specifies whether or not this material should be rendered in alpha blend mode.
  22126. */
  22127. needAlphaBlending(): boolean;
  22128. /**
  22129. * Specifies whether or not this material should be rendered in alpha test mode.
  22130. */
  22131. needAlphaTesting(): boolean;
  22132. /**
  22133. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22134. */
  22135. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22136. /**
  22137. * Specifies whether or not there is a usable alpha channel for transparency.
  22138. */
  22139. protected _hasAlphaChannel(): boolean;
  22140. /**
  22141. * Gets the texture used for the alpha test.
  22142. */
  22143. getAlphaTestTexture(): Nullable<BaseTexture>;
  22144. /**
  22145. * Specifies that the submesh is ready to be used.
  22146. * @param mesh - BJS mesh.
  22147. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22148. * @param useInstances - Specifies that instances should be used.
  22149. * @returns - boolean indicating that the submesh is ready or not.
  22150. */
  22151. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22152. /**
  22153. * Specifies if the material uses metallic roughness workflow.
  22154. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22155. */
  22156. isMetallicWorkflow(): boolean;
  22157. private _prepareEffect;
  22158. private _prepareDefines;
  22159. /**
  22160. * Force shader compilation
  22161. */
  22162. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22163. /**
  22164. * Initializes the uniform buffer layout for the shader.
  22165. */
  22166. buildUniformLayout(): void;
  22167. /**
  22168. * Unbinds the material from the mesh
  22169. */
  22170. unbind(): void;
  22171. /**
  22172. * Binds the submesh data.
  22173. * @param world - The world matrix.
  22174. * @param mesh - The BJS mesh.
  22175. * @param subMesh - A submesh of the BJS mesh.
  22176. */
  22177. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22178. /**
  22179. * Returns the animatable textures.
  22180. * @returns - Array of animatable textures.
  22181. */
  22182. getAnimatables(): IAnimatable[];
  22183. /**
  22184. * Returns the texture used for reflections.
  22185. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22186. */
  22187. private _getReflectionTexture;
  22188. /**
  22189. * Returns an array of the actively used textures.
  22190. * @returns - Array of BaseTextures
  22191. */
  22192. getActiveTextures(): BaseTexture[];
  22193. /**
  22194. * Checks to see if a texture is used in the material.
  22195. * @param texture - Base texture to use.
  22196. * @returns - Boolean specifying if a texture is used in the material.
  22197. */
  22198. hasTexture(texture: BaseTexture): boolean;
  22199. /**
  22200. * Sets the required values to the prepass renderer.
  22201. * @param prePassRenderer defines the prepass renderer to setup
  22202. */
  22203. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22204. /**
  22205. * Disposes the resources of the material.
  22206. * @param forceDisposeEffect - Forces the disposal of effects.
  22207. * @param forceDisposeTextures - Forces the disposal of all textures.
  22208. */
  22209. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22210. }
  22211. }
  22212. declare module BABYLON {
  22213. /**
  22214. * The Physically based material of BJS.
  22215. *
  22216. * This offers the main features of a standard PBR material.
  22217. * For more information, please refer to the documentation :
  22218. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22219. */
  22220. export class PBRMaterial extends PBRBaseMaterial {
  22221. /**
  22222. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22223. */
  22224. static readonly PBRMATERIAL_OPAQUE: number;
  22225. /**
  22226. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22227. */
  22228. static readonly PBRMATERIAL_ALPHATEST: number;
  22229. /**
  22230. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22231. */
  22232. static readonly PBRMATERIAL_ALPHABLEND: number;
  22233. /**
  22234. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22235. * They are also discarded below the alpha cutoff threshold to improve performances.
  22236. */
  22237. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22238. /**
  22239. * Defines the default value of how much AO map is occluding the analytical lights
  22240. * (point spot...).
  22241. */
  22242. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22243. /**
  22244. * Intensity of the direct lights e.g. the four lights available in your scene.
  22245. * This impacts both the direct diffuse and specular highlights.
  22246. */
  22247. directIntensity: number;
  22248. /**
  22249. * Intensity of the emissive part of the material.
  22250. * This helps controlling the emissive effect without modifying the emissive color.
  22251. */
  22252. emissiveIntensity: number;
  22253. /**
  22254. * Intensity of the environment e.g. how much the environment will light the object
  22255. * either through harmonics for rough material or through the refelction for shiny ones.
  22256. */
  22257. environmentIntensity: number;
  22258. /**
  22259. * This is a special control allowing the reduction of the specular highlights coming from the
  22260. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22261. */
  22262. specularIntensity: number;
  22263. /**
  22264. * Debug Control allowing disabling the bump map on this material.
  22265. */
  22266. disableBumpMap: boolean;
  22267. /**
  22268. * AKA Diffuse Texture in standard nomenclature.
  22269. */
  22270. albedoTexture: BaseTexture;
  22271. /**
  22272. * AKA Occlusion Texture in other nomenclature.
  22273. */
  22274. ambientTexture: BaseTexture;
  22275. /**
  22276. * AKA Occlusion Texture Intensity in other nomenclature.
  22277. */
  22278. ambientTextureStrength: number;
  22279. /**
  22280. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22281. * 1 means it completely occludes it
  22282. * 0 mean it has no impact
  22283. */
  22284. ambientTextureImpactOnAnalyticalLights: number;
  22285. /**
  22286. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22287. */
  22288. opacityTexture: BaseTexture;
  22289. /**
  22290. * Stores the reflection values in a texture.
  22291. */
  22292. reflectionTexture: Nullable<BaseTexture>;
  22293. /**
  22294. * Stores the emissive values in a texture.
  22295. */
  22296. emissiveTexture: BaseTexture;
  22297. /**
  22298. * AKA Specular texture in other nomenclature.
  22299. */
  22300. reflectivityTexture: BaseTexture;
  22301. /**
  22302. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22303. */
  22304. metallicTexture: BaseTexture;
  22305. /**
  22306. * Specifies the metallic scalar of the metallic/roughness workflow.
  22307. * Can also be used to scale the metalness values of the metallic texture.
  22308. */
  22309. metallic: Nullable<number>;
  22310. /**
  22311. * Specifies the roughness scalar of the metallic/roughness workflow.
  22312. * Can also be used to scale the roughness values of the metallic texture.
  22313. */
  22314. roughness: Nullable<number>;
  22315. /**
  22316. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22317. * By default the indexOfrefraction is used to compute F0;
  22318. *
  22319. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22320. *
  22321. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22322. * F90 = metallicReflectanceColor;
  22323. */
  22324. metallicF0Factor: number;
  22325. /**
  22326. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22327. * By default the F90 is always 1;
  22328. *
  22329. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22330. *
  22331. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22332. * F90 = metallicReflectanceColor;
  22333. */
  22334. metallicReflectanceColor: Color3;
  22335. /**
  22336. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22337. * This is multiply against the scalar values defined in the material.
  22338. */
  22339. metallicReflectanceTexture: Nullable<BaseTexture>;
  22340. /**
  22341. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22342. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22343. */
  22344. microSurfaceTexture: BaseTexture;
  22345. /**
  22346. * Stores surface normal data used to displace a mesh in a texture.
  22347. */
  22348. bumpTexture: BaseTexture;
  22349. /**
  22350. * Stores the pre-calculated light information of a mesh in a texture.
  22351. */
  22352. lightmapTexture: BaseTexture;
  22353. /**
  22354. * Stores the refracted light information in a texture.
  22355. */
  22356. get refractionTexture(): Nullable<BaseTexture>;
  22357. set refractionTexture(value: Nullable<BaseTexture>);
  22358. /**
  22359. * The color of a material in ambient lighting.
  22360. */
  22361. ambientColor: Color3;
  22362. /**
  22363. * AKA Diffuse Color in other nomenclature.
  22364. */
  22365. albedoColor: Color3;
  22366. /**
  22367. * AKA Specular Color in other nomenclature.
  22368. */
  22369. reflectivityColor: Color3;
  22370. /**
  22371. * The color reflected from the material.
  22372. */
  22373. reflectionColor: Color3;
  22374. /**
  22375. * The color emitted from the material.
  22376. */
  22377. emissiveColor: Color3;
  22378. /**
  22379. * AKA Glossiness in other nomenclature.
  22380. */
  22381. microSurface: number;
  22382. /**
  22383. * Index of refraction of the material base layer.
  22384. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22385. *
  22386. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22387. *
  22388. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22389. */
  22390. get indexOfRefraction(): number;
  22391. set indexOfRefraction(value: number);
  22392. /**
  22393. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22394. */
  22395. get invertRefractionY(): boolean;
  22396. set invertRefractionY(value: boolean);
  22397. /**
  22398. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22399. * Materials half opaque for instance using refraction could benefit from this control.
  22400. */
  22401. get linkRefractionWithTransparency(): boolean;
  22402. set linkRefractionWithTransparency(value: boolean);
  22403. /**
  22404. * If true, the light map contains occlusion information instead of lighting info.
  22405. */
  22406. useLightmapAsShadowmap: boolean;
  22407. /**
  22408. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22409. */
  22410. useAlphaFromAlbedoTexture: boolean;
  22411. /**
  22412. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22413. */
  22414. forceAlphaTest: boolean;
  22415. /**
  22416. * Defines the alpha limits in alpha test mode.
  22417. */
  22418. alphaCutOff: number;
  22419. /**
  22420. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22421. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22422. */
  22423. useSpecularOverAlpha: boolean;
  22424. /**
  22425. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22426. */
  22427. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22428. /**
  22429. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22430. */
  22431. useRoughnessFromMetallicTextureAlpha: boolean;
  22432. /**
  22433. * Specifies if the metallic texture contains the roughness information in its green channel.
  22434. */
  22435. useRoughnessFromMetallicTextureGreen: boolean;
  22436. /**
  22437. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22438. */
  22439. useMetallnessFromMetallicTextureBlue: boolean;
  22440. /**
  22441. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22442. */
  22443. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22444. /**
  22445. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22446. */
  22447. useAmbientInGrayScale: boolean;
  22448. /**
  22449. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22450. * The material will try to infer what glossiness each pixel should be.
  22451. */
  22452. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22453. /**
  22454. * BJS is using an harcoded light falloff based on a manually sets up range.
  22455. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22456. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22457. */
  22458. get usePhysicalLightFalloff(): boolean;
  22459. /**
  22460. * BJS is using an harcoded light falloff based on a manually sets up range.
  22461. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22462. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22463. */
  22464. set usePhysicalLightFalloff(value: boolean);
  22465. /**
  22466. * In order to support the falloff compatibility with gltf, a special mode has been added
  22467. * to reproduce the gltf light falloff.
  22468. */
  22469. get useGLTFLightFalloff(): boolean;
  22470. /**
  22471. * In order to support the falloff compatibility with gltf, a special mode has been added
  22472. * to reproduce the gltf light falloff.
  22473. */
  22474. set useGLTFLightFalloff(value: boolean);
  22475. /**
  22476. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22477. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22478. */
  22479. useRadianceOverAlpha: boolean;
  22480. /**
  22481. * Allows using an object space normal map (instead of tangent space).
  22482. */
  22483. useObjectSpaceNormalMap: boolean;
  22484. /**
  22485. * Allows using the bump map in parallax mode.
  22486. */
  22487. useParallax: boolean;
  22488. /**
  22489. * Allows using the bump map in parallax occlusion mode.
  22490. */
  22491. useParallaxOcclusion: boolean;
  22492. /**
  22493. * Controls the scale bias of the parallax mode.
  22494. */
  22495. parallaxScaleBias: number;
  22496. /**
  22497. * If sets to true, disables all the lights affecting the material.
  22498. */
  22499. disableLighting: boolean;
  22500. /**
  22501. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22502. */
  22503. forceIrradianceInFragment: boolean;
  22504. /**
  22505. * Number of Simultaneous lights allowed on the material.
  22506. */
  22507. maxSimultaneousLights: number;
  22508. /**
  22509. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22510. */
  22511. invertNormalMapX: boolean;
  22512. /**
  22513. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22514. */
  22515. invertNormalMapY: boolean;
  22516. /**
  22517. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22518. */
  22519. twoSidedLighting: boolean;
  22520. /**
  22521. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22522. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22523. */
  22524. useAlphaFresnel: boolean;
  22525. /**
  22526. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22527. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22528. */
  22529. useLinearAlphaFresnel: boolean;
  22530. /**
  22531. * Let user defines the brdf lookup texture used for IBL.
  22532. * A default 8bit version is embedded but you could point at :
  22533. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22534. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22535. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22536. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22537. */
  22538. environmentBRDFTexture: Nullable<BaseTexture>;
  22539. /**
  22540. * Force normal to face away from face.
  22541. */
  22542. forceNormalForward: boolean;
  22543. /**
  22544. * Enables specular anti aliasing in the PBR shader.
  22545. * It will both interacts on the Geometry for analytical and IBL lighting.
  22546. * It also prefilter the roughness map based on the bump values.
  22547. */
  22548. enableSpecularAntiAliasing: boolean;
  22549. /**
  22550. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22551. * makes the reflect vector face the model (under horizon).
  22552. */
  22553. useHorizonOcclusion: boolean;
  22554. /**
  22555. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22556. * too much the area relying on ambient texture to define their ambient occlusion.
  22557. */
  22558. useRadianceOcclusion: boolean;
  22559. /**
  22560. * If set to true, no lighting calculations will be applied.
  22561. */
  22562. unlit: boolean;
  22563. /**
  22564. * Gets the image processing configuration used either in this material.
  22565. */
  22566. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22567. /**
  22568. * Sets the Default image processing configuration used either in the this material.
  22569. *
  22570. * If sets to null, the scene one is in use.
  22571. */
  22572. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22573. /**
  22574. * Gets wether the color curves effect is enabled.
  22575. */
  22576. get cameraColorCurvesEnabled(): boolean;
  22577. /**
  22578. * Sets wether the color curves effect is enabled.
  22579. */
  22580. set cameraColorCurvesEnabled(value: boolean);
  22581. /**
  22582. * Gets wether the color grading effect is enabled.
  22583. */
  22584. get cameraColorGradingEnabled(): boolean;
  22585. /**
  22586. * Gets wether the color grading effect is enabled.
  22587. */
  22588. set cameraColorGradingEnabled(value: boolean);
  22589. /**
  22590. * Gets wether tonemapping is enabled or not.
  22591. */
  22592. get cameraToneMappingEnabled(): boolean;
  22593. /**
  22594. * Sets wether tonemapping is enabled or not
  22595. */
  22596. set cameraToneMappingEnabled(value: boolean);
  22597. /**
  22598. * The camera exposure used on this material.
  22599. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22600. * This corresponds to a photographic exposure.
  22601. */
  22602. get cameraExposure(): number;
  22603. /**
  22604. * The camera exposure used on this material.
  22605. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22606. * This corresponds to a photographic exposure.
  22607. */
  22608. set cameraExposure(value: number);
  22609. /**
  22610. * Gets The camera contrast used on this material.
  22611. */
  22612. get cameraContrast(): number;
  22613. /**
  22614. * Sets The camera contrast used on this material.
  22615. */
  22616. set cameraContrast(value: number);
  22617. /**
  22618. * Gets the Color Grading 2D Lookup Texture.
  22619. */
  22620. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22621. /**
  22622. * Sets the Color Grading 2D Lookup Texture.
  22623. */
  22624. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22625. /**
  22626. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22627. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22628. * 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;
  22629. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22630. */
  22631. get cameraColorCurves(): Nullable<ColorCurves>;
  22632. /**
  22633. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22634. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22635. * 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;
  22636. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22637. */
  22638. set cameraColorCurves(value: Nullable<ColorCurves>);
  22639. /**
  22640. * Instantiates a new PBRMaterial instance.
  22641. *
  22642. * @param name The material name
  22643. * @param scene The scene the material will be use in.
  22644. */
  22645. constructor(name: string, scene: Scene);
  22646. /**
  22647. * Returns the name of this material class.
  22648. */
  22649. getClassName(): string;
  22650. /**
  22651. * Makes a duplicate of the current material.
  22652. * @param name - name to use for the new material.
  22653. */
  22654. clone(name: string): PBRMaterial;
  22655. /**
  22656. * Serializes this PBR Material.
  22657. * @returns - An object with the serialized material.
  22658. */
  22659. serialize(): any;
  22660. /**
  22661. * Parses a PBR Material from a serialized object.
  22662. * @param source - Serialized object.
  22663. * @param scene - BJS scene instance.
  22664. * @param rootUrl - url for the scene object
  22665. * @returns - PBRMaterial
  22666. */
  22667. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22668. }
  22669. }
  22670. declare module BABYLON {
  22671. /** @hidden */
  22672. export var mrtFragmentDeclaration: {
  22673. name: string;
  22674. shader: string;
  22675. };
  22676. }
  22677. declare module BABYLON {
  22678. /** @hidden */
  22679. export var geometryPixelShader: {
  22680. name: string;
  22681. shader: string;
  22682. };
  22683. }
  22684. declare module BABYLON {
  22685. /** @hidden */
  22686. export var instancesDeclaration: {
  22687. name: string;
  22688. shader: string;
  22689. };
  22690. }
  22691. declare module BABYLON {
  22692. /** @hidden */
  22693. export var geometryVertexShader: {
  22694. name: string;
  22695. shader: string;
  22696. };
  22697. }
  22698. declare module BABYLON {
  22699. /** @hidden */
  22700. interface ISavedTransformationMatrix {
  22701. world: Matrix;
  22702. viewProjection: Matrix;
  22703. }
  22704. /**
  22705. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22706. */
  22707. export class GeometryBufferRenderer {
  22708. /**
  22709. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22710. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22711. */
  22712. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22713. /**
  22714. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22715. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22716. */
  22717. static readonly POSITION_TEXTURE_TYPE: number;
  22718. /**
  22719. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22720. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22721. */
  22722. static readonly VELOCITY_TEXTURE_TYPE: number;
  22723. /**
  22724. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22725. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22726. */
  22727. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22728. /**
  22729. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22730. * in order to compute objects velocities when enableVelocity is set to "true"
  22731. * @hidden
  22732. */
  22733. _previousTransformationMatrices: {
  22734. [index: number]: ISavedTransformationMatrix;
  22735. };
  22736. /**
  22737. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22738. * in order to compute objects velocities when enableVelocity is set to "true"
  22739. * @hidden
  22740. */
  22741. _previousBonesTransformationMatrices: {
  22742. [index: number]: Float32Array;
  22743. };
  22744. /**
  22745. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22746. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22747. */
  22748. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22749. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22750. renderTransparentMeshes: boolean;
  22751. private _scene;
  22752. private _resizeObserver;
  22753. private _multiRenderTarget;
  22754. private _ratio;
  22755. private _enablePosition;
  22756. private _enableVelocity;
  22757. private _enableReflectivity;
  22758. private _positionIndex;
  22759. private _velocityIndex;
  22760. private _reflectivityIndex;
  22761. private _depthNormalIndex;
  22762. private _linkedWithPrePass;
  22763. private _prePassRenderer;
  22764. private _attachments;
  22765. protected _effect: Effect;
  22766. protected _cachedDefines: string;
  22767. /**
  22768. * @hidden
  22769. * Sets up internal structures to share outputs with PrePassRenderer
  22770. * This method should only be called by the PrePassRenderer itself
  22771. */
  22772. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22773. /**
  22774. * @hidden
  22775. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22776. * This method should only be called by the PrePassRenderer itself
  22777. */
  22778. _unlinkPrePassRenderer(): void;
  22779. /**
  22780. * @hidden
  22781. * Resets the geometry buffer layout
  22782. */
  22783. _resetLayout(): void;
  22784. /**
  22785. * @hidden
  22786. * Replaces a texture in the geometry buffer renderer
  22787. * Useful when linking textures of the prepass renderer
  22788. */
  22789. _forceTextureType(geometryBufferType: number, index: number): void;
  22790. /**
  22791. * @hidden
  22792. * Sets texture attachments
  22793. * Useful when linking textures of the prepass renderer
  22794. */
  22795. _setAttachments(attachments: number[]): void;
  22796. /**
  22797. * @hidden
  22798. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22799. * Useful when linking textures of the prepass renderer
  22800. */
  22801. _linkInternalTexture(internalTexture: InternalTexture): void;
  22802. /**
  22803. * Gets the render list (meshes to be rendered) used in the G buffer.
  22804. */
  22805. get renderList(): Nullable<AbstractMesh[]>;
  22806. /**
  22807. * Set the render list (meshes to be rendered) used in the G buffer.
  22808. */
  22809. set renderList(meshes: Nullable<AbstractMesh[]>);
  22810. /**
  22811. * Gets wether or not G buffer are supported by the running hardware.
  22812. * This requires draw buffer supports
  22813. */
  22814. get isSupported(): boolean;
  22815. /**
  22816. * Returns the index of the given texture type in the G-Buffer textures array
  22817. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22818. * @returns the index of the given texture type in the G-Buffer textures array
  22819. */
  22820. getTextureIndex(textureType: number): number;
  22821. /**
  22822. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22823. */
  22824. get enablePosition(): boolean;
  22825. /**
  22826. * Sets whether or not objects positions are enabled for the G buffer.
  22827. */
  22828. set enablePosition(enable: boolean);
  22829. /**
  22830. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22831. */
  22832. get enableVelocity(): boolean;
  22833. /**
  22834. * Sets wether or not objects velocities are enabled for the G buffer.
  22835. */
  22836. set enableVelocity(enable: boolean);
  22837. /**
  22838. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22839. */
  22840. get enableReflectivity(): boolean;
  22841. /**
  22842. * Sets wether or not objects roughness are enabled for the G buffer.
  22843. */
  22844. set enableReflectivity(enable: boolean);
  22845. /**
  22846. * Gets the scene associated with the buffer.
  22847. */
  22848. get scene(): Scene;
  22849. /**
  22850. * Gets the ratio used by the buffer during its creation.
  22851. * How big is the buffer related to the main canvas.
  22852. */
  22853. get ratio(): number;
  22854. /** @hidden */
  22855. static _SceneComponentInitialization: (scene: Scene) => void;
  22856. /**
  22857. * Creates a new G Buffer for the scene
  22858. * @param scene The scene the buffer belongs to
  22859. * @param ratio How big is the buffer related to the main canvas.
  22860. */
  22861. constructor(scene: Scene, ratio?: number);
  22862. /**
  22863. * Checks wether everything is ready to render a submesh to the G buffer.
  22864. * @param subMesh the submesh to check readiness for
  22865. * @param useInstances is the mesh drawn using instance or not
  22866. * @returns true if ready otherwise false
  22867. */
  22868. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22869. /**
  22870. * Gets the current underlying G Buffer.
  22871. * @returns the buffer
  22872. */
  22873. getGBuffer(): MultiRenderTarget;
  22874. /**
  22875. * Gets the number of samples used to render the buffer (anti aliasing).
  22876. */
  22877. get samples(): number;
  22878. /**
  22879. * Sets the number of samples used to render the buffer (anti aliasing).
  22880. */
  22881. set samples(value: number);
  22882. /**
  22883. * Disposes the renderer and frees up associated resources.
  22884. */
  22885. dispose(): void;
  22886. private _assignRenderTargetIndices;
  22887. protected _createRenderTargets(): void;
  22888. private _copyBonesTransformationMatrices;
  22889. }
  22890. }
  22891. declare module BABYLON {
  22892. /**
  22893. * Renders a pre pass of the scene
  22894. * This means every mesh in the scene will be rendered to a render target texture
  22895. * And then this texture will be composited to the rendering canvas with post processes
  22896. * It is necessary for effects like subsurface scattering or deferred shading
  22897. */
  22898. export class PrePassRenderer {
  22899. /** @hidden */
  22900. static _SceneComponentInitialization: (scene: Scene) => void;
  22901. private _textureFormats;
  22902. /**
  22903. * To save performance, we can excluded skinned meshes from the prepass
  22904. */
  22905. excludedSkinnedMesh: AbstractMesh[];
  22906. /**
  22907. * Force material to be excluded from the prepass
  22908. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22909. * and you don't want a material to show in the effect.
  22910. */
  22911. excludedMaterials: Material[];
  22912. private _textureIndices;
  22913. private _scene;
  22914. private _engine;
  22915. private _isDirty;
  22916. /**
  22917. * Number of textures in the multi render target texture where the scene is directly rendered
  22918. */
  22919. mrtCount: number;
  22920. /**
  22921. * The render target where the scene is directly rendered
  22922. */
  22923. prePassRT: MultiRenderTarget;
  22924. private _multiRenderAttachments;
  22925. private _defaultAttachments;
  22926. private _clearAttachments;
  22927. private _postProcesses;
  22928. private readonly _clearColor;
  22929. /**
  22930. * Image processing post process for composition
  22931. */
  22932. imageProcessingPostProcess: ImageProcessingPostProcess;
  22933. /**
  22934. * Configuration for prepass effects
  22935. */
  22936. private _effectConfigurations;
  22937. private _mrtFormats;
  22938. private _mrtLayout;
  22939. private _enabled;
  22940. /**
  22941. * Indicates if the prepass is enabled
  22942. */
  22943. get enabled(): boolean;
  22944. /**
  22945. * How many samples are used for MSAA of the scene render target
  22946. */
  22947. get samples(): number;
  22948. set samples(n: number);
  22949. private _geometryBuffer;
  22950. private _useGeometryBufferFallback;
  22951. /**
  22952. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22953. */
  22954. get useGeometryBufferFallback(): boolean;
  22955. set useGeometryBufferFallback(value: boolean);
  22956. /**
  22957. * Set to true to disable gamma transform in PrePass.
  22958. * Can be useful in case you already proceed to gamma transform on a material level
  22959. * and your post processes don't need to be in linear color space.
  22960. */
  22961. disableGammaTransform: boolean;
  22962. /**
  22963. * Instanciates a prepass renderer
  22964. * @param scene The scene
  22965. */
  22966. constructor(scene: Scene);
  22967. private _initializeAttachments;
  22968. private _createCompositionEffect;
  22969. /**
  22970. * Indicates if rendering a prepass is supported
  22971. */
  22972. get isSupported(): boolean;
  22973. /**
  22974. * Sets the proper output textures to draw in the engine.
  22975. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  22976. * @param subMesh Submesh on which the effect is applied
  22977. */
  22978. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  22979. /**
  22980. * Restores attachments for single texture draw.
  22981. */
  22982. restoreAttachments(): void;
  22983. /**
  22984. * @hidden
  22985. */
  22986. _beforeCameraDraw(): void;
  22987. /**
  22988. * @hidden
  22989. */
  22990. _afterCameraDraw(): void;
  22991. private _checkRTSize;
  22992. private _bindFrameBuffer;
  22993. /**
  22994. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  22995. */
  22996. clear(): void;
  22997. private _setState;
  22998. private _updateGeometryBufferLayout;
  22999. /**
  23000. * Adds an effect configuration to the prepass.
  23001. * If an effect has already been added, it won't add it twice and will return the configuration
  23002. * already present.
  23003. * @param cfg the effect configuration
  23004. * @return the effect configuration now used by the prepass
  23005. */
  23006. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23007. /**
  23008. * Returns the index of a texture in the multi render target texture array.
  23009. * @param type Texture type
  23010. * @return The index
  23011. */
  23012. getIndex(type: number): number;
  23013. private _enable;
  23014. private _disable;
  23015. private _resetLayout;
  23016. private _resetPostProcessChain;
  23017. private _bindPostProcessChain;
  23018. /**
  23019. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23020. */
  23021. markAsDirty(): void;
  23022. /**
  23023. * Enables a texture on the MultiRenderTarget for prepass
  23024. */
  23025. private _enableTextures;
  23026. private _update;
  23027. private _markAllMaterialsAsPrePassDirty;
  23028. /**
  23029. * Disposes the prepass renderer.
  23030. */
  23031. dispose(): void;
  23032. }
  23033. }
  23034. declare module BABYLON {
  23035. /**
  23036. * Size options for a post process
  23037. */
  23038. export type PostProcessOptions = {
  23039. width: number;
  23040. height: number;
  23041. };
  23042. /**
  23043. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23044. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23045. */
  23046. export class PostProcess {
  23047. /**
  23048. * Gets or sets the unique id of the post process
  23049. */
  23050. uniqueId: number;
  23051. /** Name of the PostProcess. */
  23052. name: string;
  23053. /**
  23054. * Width of the texture to apply the post process on
  23055. */
  23056. width: number;
  23057. /**
  23058. * Height of the texture to apply the post process on
  23059. */
  23060. height: number;
  23061. /**
  23062. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23063. */
  23064. nodeMaterialSource: Nullable<NodeMaterial>;
  23065. /**
  23066. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23067. * @hidden
  23068. */
  23069. _outputTexture: Nullable<InternalTexture>;
  23070. /**
  23071. * Sampling mode used by the shader
  23072. * See https://doc.babylonjs.com/classes/3.1/texture
  23073. */
  23074. renderTargetSamplingMode: number;
  23075. /**
  23076. * Clear color to use when screen clearing
  23077. */
  23078. clearColor: Color4;
  23079. /**
  23080. * If the buffer needs to be cleared before applying the post process. (default: true)
  23081. * Should be set to false if shader will overwrite all previous pixels.
  23082. */
  23083. autoClear: boolean;
  23084. /**
  23085. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23086. */
  23087. alphaMode: number;
  23088. /**
  23089. * Sets the setAlphaBlendConstants of the babylon engine
  23090. */
  23091. alphaConstants: Color4;
  23092. /**
  23093. * Animations to be used for the post processing
  23094. */
  23095. animations: Animation[];
  23096. /**
  23097. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23098. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23099. */
  23100. enablePixelPerfectMode: boolean;
  23101. /**
  23102. * Force the postprocess to be applied without taking in account viewport
  23103. */
  23104. forceFullscreenViewport: boolean;
  23105. /**
  23106. * List of inspectable custom properties (used by the Inspector)
  23107. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23108. */
  23109. inspectableCustomProperties: IInspectable[];
  23110. /**
  23111. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23112. *
  23113. * | Value | Type | Description |
  23114. * | ----- | ----------------------------------- | ----------- |
  23115. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23116. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23117. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23118. *
  23119. */
  23120. scaleMode: number;
  23121. /**
  23122. * Force textures to be a power of two (default: false)
  23123. */
  23124. alwaysForcePOT: boolean;
  23125. private _samples;
  23126. /**
  23127. * Number of sample textures (default: 1)
  23128. */
  23129. get samples(): number;
  23130. set samples(n: number);
  23131. /**
  23132. * Modify the scale of the post process to be the same as the viewport (default: false)
  23133. */
  23134. adaptScaleToCurrentViewport: boolean;
  23135. private _camera;
  23136. protected _scene: Scene;
  23137. private _engine;
  23138. private _options;
  23139. private _reusable;
  23140. private _textureType;
  23141. private _textureFormat;
  23142. /**
  23143. * Smart array of input and output textures for the post process.
  23144. * @hidden
  23145. */
  23146. _textures: SmartArray<InternalTexture>;
  23147. /**
  23148. * The index in _textures that corresponds to the output texture.
  23149. * @hidden
  23150. */
  23151. _currentRenderTextureInd: number;
  23152. private _effect;
  23153. private _samplers;
  23154. private _fragmentUrl;
  23155. private _vertexUrl;
  23156. private _parameters;
  23157. private _scaleRatio;
  23158. protected _indexParameters: any;
  23159. private _shareOutputWithPostProcess;
  23160. private _texelSize;
  23161. private _forcedOutputTexture;
  23162. /**
  23163. * Prepass configuration in case this post process needs a texture from prepass
  23164. * @hidden
  23165. */
  23166. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23167. /**
  23168. * Returns the fragment url or shader name used in the post process.
  23169. * @returns the fragment url or name in the shader store.
  23170. */
  23171. getEffectName(): string;
  23172. /**
  23173. * An event triggered when the postprocess is activated.
  23174. */
  23175. onActivateObservable: Observable<Camera>;
  23176. private _onActivateObserver;
  23177. /**
  23178. * A function that is added to the onActivateObservable
  23179. */
  23180. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23181. /**
  23182. * An event triggered when the postprocess changes its size.
  23183. */
  23184. onSizeChangedObservable: Observable<PostProcess>;
  23185. private _onSizeChangedObserver;
  23186. /**
  23187. * A function that is added to the onSizeChangedObservable
  23188. */
  23189. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23190. /**
  23191. * An event triggered when the postprocess applies its effect.
  23192. */
  23193. onApplyObservable: Observable<Effect>;
  23194. private _onApplyObserver;
  23195. /**
  23196. * A function that is added to the onApplyObservable
  23197. */
  23198. set onApply(callback: (effect: Effect) => void);
  23199. /**
  23200. * An event triggered before rendering the postprocess
  23201. */
  23202. onBeforeRenderObservable: Observable<Effect>;
  23203. private _onBeforeRenderObserver;
  23204. /**
  23205. * A function that is added to the onBeforeRenderObservable
  23206. */
  23207. set onBeforeRender(callback: (effect: Effect) => void);
  23208. /**
  23209. * An event triggered after rendering the postprocess
  23210. */
  23211. onAfterRenderObservable: Observable<Effect>;
  23212. private _onAfterRenderObserver;
  23213. /**
  23214. * A function that is added to the onAfterRenderObservable
  23215. */
  23216. set onAfterRender(callback: (efect: Effect) => void);
  23217. /**
  23218. * 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
  23219. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23220. */
  23221. get inputTexture(): InternalTexture;
  23222. set inputTexture(value: InternalTexture);
  23223. /**
  23224. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23225. * the only way to unset it is to use this function to restore its internal state
  23226. */
  23227. restoreDefaultInputTexture(): void;
  23228. /**
  23229. * Gets the camera which post process is applied to.
  23230. * @returns The camera the post process is applied to.
  23231. */
  23232. getCamera(): Camera;
  23233. /**
  23234. * Gets the texel size of the postprocess.
  23235. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23236. */
  23237. get texelSize(): Vector2;
  23238. /**
  23239. * Creates a new instance PostProcess
  23240. * @param name The name of the PostProcess.
  23241. * @param fragmentUrl The url of the fragment shader to be used.
  23242. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23243. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23244. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23245. * @param camera The camera to apply the render pass to.
  23246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23247. * @param engine The engine which the post process will be applied. (default: current engine)
  23248. * @param reusable If the post process can be reused on the same frame. (default: false)
  23249. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23250. * @param textureType Type of textures used when performing the post process. (default: 0)
  23251. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23252. * @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
  23253. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23254. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23255. */
  23256. 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);
  23257. /**
  23258. * Gets a string identifying the name of the class
  23259. * @returns "PostProcess" string
  23260. */
  23261. getClassName(): string;
  23262. /**
  23263. * Gets the engine which this post process belongs to.
  23264. * @returns The engine the post process was enabled with.
  23265. */
  23266. getEngine(): Engine;
  23267. /**
  23268. * The effect that is created when initializing the post process.
  23269. * @returns The created effect corresponding the the postprocess.
  23270. */
  23271. getEffect(): Effect;
  23272. /**
  23273. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23274. * @param postProcess The post process to share the output with.
  23275. * @returns This post process.
  23276. */
  23277. shareOutputWith(postProcess: PostProcess): PostProcess;
  23278. /**
  23279. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23280. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23281. */
  23282. useOwnOutput(): void;
  23283. /**
  23284. * Updates the effect with the current post process compile time values and recompiles the shader.
  23285. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23286. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23287. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23288. * @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
  23289. * @param onCompiled Called when the shader has been compiled.
  23290. * @param onError Called if there is an error when compiling a shader.
  23291. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23292. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23293. */
  23294. 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;
  23295. /**
  23296. * The post process is reusable if it can be used multiple times within one frame.
  23297. * @returns If the post process is reusable
  23298. */
  23299. isReusable(): boolean;
  23300. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23301. markTextureDirty(): void;
  23302. /**
  23303. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23304. * 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.
  23305. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23306. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23307. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23308. * @returns The target texture that was bound to be written to.
  23309. */
  23310. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23311. /**
  23312. * If the post process is supported.
  23313. */
  23314. get isSupported(): boolean;
  23315. /**
  23316. * The aspect ratio of the output texture.
  23317. */
  23318. get aspectRatio(): number;
  23319. /**
  23320. * Get a value indicating if the post-process is ready to be used
  23321. * @returns true if the post-process is ready (shader is compiled)
  23322. */
  23323. isReady(): boolean;
  23324. /**
  23325. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23326. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23327. */
  23328. apply(): Nullable<Effect>;
  23329. private _disposeTextures;
  23330. /**
  23331. * Sets the required values to the prepass renderer.
  23332. * @param prePassRenderer defines the prepass renderer to setup.
  23333. * @returns true if the pre pass is needed.
  23334. */
  23335. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23336. /**
  23337. * Disposes the post process.
  23338. * @param camera The camera to dispose the post process on.
  23339. */
  23340. dispose(camera?: Camera): void;
  23341. /**
  23342. * Serializes the particle system to a JSON object
  23343. * @returns the JSON object
  23344. */
  23345. serialize(): any;
  23346. /**
  23347. * Creates a material from parsed material data
  23348. * @param parsedPostProcess defines parsed post process data
  23349. * @param scene defines the hosting scene
  23350. * @param rootUrl defines the root URL to use to load textures
  23351. * @returns a new post process
  23352. */
  23353. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23354. }
  23355. }
  23356. declare module BABYLON {
  23357. /** @hidden */
  23358. export var kernelBlurVaryingDeclaration: {
  23359. name: string;
  23360. shader: string;
  23361. };
  23362. }
  23363. declare module BABYLON {
  23364. /** @hidden */
  23365. export var packingFunctions: {
  23366. name: string;
  23367. shader: string;
  23368. };
  23369. }
  23370. declare module BABYLON {
  23371. /** @hidden */
  23372. export var kernelBlurFragment: {
  23373. name: string;
  23374. shader: string;
  23375. };
  23376. }
  23377. declare module BABYLON {
  23378. /** @hidden */
  23379. export var kernelBlurFragment2: {
  23380. name: string;
  23381. shader: string;
  23382. };
  23383. }
  23384. declare module BABYLON {
  23385. /** @hidden */
  23386. export var kernelBlurPixelShader: {
  23387. name: string;
  23388. shader: string;
  23389. };
  23390. }
  23391. declare module BABYLON {
  23392. /** @hidden */
  23393. export var kernelBlurVertex: {
  23394. name: string;
  23395. shader: string;
  23396. };
  23397. }
  23398. declare module BABYLON {
  23399. /** @hidden */
  23400. export var kernelBlurVertexShader: {
  23401. name: string;
  23402. shader: string;
  23403. };
  23404. }
  23405. declare module BABYLON {
  23406. /**
  23407. * The Blur Post Process which blurs an image based on a kernel and direction.
  23408. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23409. */
  23410. export class BlurPostProcess extends PostProcess {
  23411. private blockCompilation;
  23412. protected _kernel: number;
  23413. protected _idealKernel: number;
  23414. protected _packedFloat: boolean;
  23415. private _staticDefines;
  23416. /** The direction in which to blur the image. */
  23417. direction: Vector2;
  23418. /**
  23419. * Sets the length in pixels of the blur sample region
  23420. */
  23421. set kernel(v: number);
  23422. /**
  23423. * Gets the length in pixels of the blur sample region
  23424. */
  23425. get kernel(): number;
  23426. /**
  23427. * Sets wether or not the blur needs to unpack/repack floats
  23428. */
  23429. set packedFloat(v: boolean);
  23430. /**
  23431. * Gets wether or not the blur is unpacking/repacking floats
  23432. */
  23433. get packedFloat(): boolean;
  23434. /**
  23435. * Gets a string identifying the name of the class
  23436. * @returns "BlurPostProcess" string
  23437. */
  23438. getClassName(): string;
  23439. /**
  23440. * Creates a new instance BlurPostProcess
  23441. * @param name The name of the effect.
  23442. * @param direction The direction in which to blur the image.
  23443. * @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.
  23444. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23445. * @param camera The camera to apply the render pass to.
  23446. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23447. * @param engine The engine which the post process will be applied. (default: current engine)
  23448. * @param reusable If the post process can be reused on the same frame. (default: false)
  23449. * @param textureType Type of textures used when performing the post process. (default: 0)
  23450. * @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)
  23451. */
  23452. 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);
  23453. /**
  23454. * Updates the effect with the current post process compile time values and recompiles the shader.
  23455. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23456. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23457. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23458. * @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
  23459. * @param onCompiled Called when the shader has been compiled.
  23460. * @param onError Called if there is an error when compiling a shader.
  23461. */
  23462. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23463. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23464. /**
  23465. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23466. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23467. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23468. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23469. * The gaps between physical kernels are compensated for in the weighting of the samples
  23470. * @param idealKernel Ideal blur kernel.
  23471. * @return Nearest best kernel.
  23472. */
  23473. protected _nearestBestKernel(idealKernel: number): number;
  23474. /**
  23475. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23476. * @param x The point on the Gaussian distribution to sample.
  23477. * @return the value of the Gaussian function at x.
  23478. */
  23479. protected _gaussianWeight(x: number): number;
  23480. /**
  23481. * Generates a string that can be used as a floating point number in GLSL.
  23482. * @param x Value to print.
  23483. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23484. * @return GLSL float string.
  23485. */
  23486. protected _glslFloat(x: number, decimalFigures?: number): string;
  23487. /** @hidden */
  23488. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23489. }
  23490. }
  23491. declare module BABYLON {
  23492. /**
  23493. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23494. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23495. * You can then easily use it as a reflectionTexture on a flat surface.
  23496. * In case the surface is not a plane, please consider relying on reflection probes.
  23497. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23498. */
  23499. export class MirrorTexture extends RenderTargetTexture {
  23500. private scene;
  23501. /**
  23502. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23503. * 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.
  23504. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23505. */
  23506. mirrorPlane: Plane;
  23507. /**
  23508. * Define the blur ratio used to blur the reflection if needed.
  23509. */
  23510. set blurRatio(value: number);
  23511. get blurRatio(): number;
  23512. /**
  23513. * Define the adaptive blur kernel used to blur the reflection if needed.
  23514. * This will autocompute the closest best match for the `blurKernel`
  23515. */
  23516. set adaptiveBlurKernel(value: number);
  23517. /**
  23518. * Define the blur kernel used to blur the reflection if needed.
  23519. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23520. */
  23521. set blurKernel(value: number);
  23522. /**
  23523. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23524. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23525. */
  23526. set blurKernelX(value: number);
  23527. get blurKernelX(): number;
  23528. /**
  23529. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23530. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23531. */
  23532. set blurKernelY(value: number);
  23533. get blurKernelY(): number;
  23534. private _autoComputeBlurKernel;
  23535. protected _onRatioRescale(): void;
  23536. private _updateGammaSpace;
  23537. private _imageProcessingConfigChangeObserver;
  23538. private _transformMatrix;
  23539. private _mirrorMatrix;
  23540. private _savedViewMatrix;
  23541. private _blurX;
  23542. private _blurY;
  23543. private _adaptiveBlurKernel;
  23544. private _blurKernelX;
  23545. private _blurKernelY;
  23546. private _blurRatio;
  23547. /**
  23548. * Instantiates a Mirror Texture.
  23549. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23550. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23551. * You can then easily use it as a reflectionTexture on a flat surface.
  23552. * In case the surface is not a plane, please consider relying on reflection probes.
  23553. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23554. * @param name
  23555. * @param size
  23556. * @param scene
  23557. * @param generateMipMaps
  23558. * @param type
  23559. * @param samplingMode
  23560. * @param generateDepthBuffer
  23561. */
  23562. constructor(name: string, size: number | {
  23563. width: number;
  23564. height: number;
  23565. } | {
  23566. ratio: number;
  23567. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23568. private _preparePostProcesses;
  23569. /**
  23570. * Clone the mirror texture.
  23571. * @returns the cloned texture
  23572. */
  23573. clone(): MirrorTexture;
  23574. /**
  23575. * Serialize the texture to a JSON representation you could use in Parse later on
  23576. * @returns the serialized JSON representation
  23577. */
  23578. serialize(): any;
  23579. /**
  23580. * Dispose the texture and release its associated resources.
  23581. */
  23582. dispose(): void;
  23583. }
  23584. }
  23585. declare module BABYLON {
  23586. /**
  23587. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23588. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23589. */
  23590. export class Texture extends BaseTexture {
  23591. /**
  23592. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23593. */
  23594. static SerializeBuffers: boolean;
  23595. /**
  23596. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23597. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23598. */
  23599. static ForceSerializeBuffers: boolean;
  23600. /** @hidden */
  23601. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23602. /** @hidden */
  23603. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23604. /** @hidden */
  23605. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23606. /** nearest is mag = nearest and min = nearest and mip = linear */
  23607. static readonly NEAREST_SAMPLINGMODE: number;
  23608. /** nearest is mag = nearest and min = nearest and mip = linear */
  23609. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23610. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23611. static readonly BILINEAR_SAMPLINGMODE: number;
  23612. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23613. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23614. /** Trilinear is mag = linear and min = linear and mip = linear */
  23615. static readonly TRILINEAR_SAMPLINGMODE: number;
  23616. /** Trilinear is mag = linear and min = linear and mip = linear */
  23617. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23618. /** mag = nearest and min = nearest and mip = nearest */
  23619. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23620. /** mag = nearest and min = linear and mip = nearest */
  23621. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23622. /** mag = nearest and min = linear and mip = linear */
  23623. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23624. /** mag = nearest and min = linear and mip = none */
  23625. static readonly NEAREST_LINEAR: number;
  23626. /** mag = nearest and min = nearest and mip = none */
  23627. static readonly NEAREST_NEAREST: number;
  23628. /** mag = linear and min = nearest and mip = nearest */
  23629. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23630. /** mag = linear and min = nearest and mip = linear */
  23631. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23632. /** mag = linear and min = linear and mip = none */
  23633. static readonly LINEAR_LINEAR: number;
  23634. /** mag = linear and min = nearest and mip = none */
  23635. static readonly LINEAR_NEAREST: number;
  23636. /** Explicit coordinates mode */
  23637. static readonly EXPLICIT_MODE: number;
  23638. /** Spherical coordinates mode */
  23639. static readonly SPHERICAL_MODE: number;
  23640. /** Planar coordinates mode */
  23641. static readonly PLANAR_MODE: number;
  23642. /** Cubic coordinates mode */
  23643. static readonly CUBIC_MODE: number;
  23644. /** Projection coordinates mode */
  23645. static readonly PROJECTION_MODE: number;
  23646. /** Inverse Cubic coordinates mode */
  23647. static readonly SKYBOX_MODE: number;
  23648. /** Inverse Cubic coordinates mode */
  23649. static readonly INVCUBIC_MODE: number;
  23650. /** Equirectangular coordinates mode */
  23651. static readonly EQUIRECTANGULAR_MODE: number;
  23652. /** Equirectangular Fixed coordinates mode */
  23653. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23654. /** Equirectangular Fixed Mirrored coordinates mode */
  23655. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23656. /** Texture is not repeating outside of 0..1 UVs */
  23657. static readonly CLAMP_ADDRESSMODE: number;
  23658. /** Texture is repeating outside of 0..1 UVs */
  23659. static readonly WRAP_ADDRESSMODE: number;
  23660. /** Texture is repeating and mirrored */
  23661. static readonly MIRROR_ADDRESSMODE: number;
  23662. /**
  23663. * 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
  23664. */
  23665. static UseSerializedUrlIfAny: boolean;
  23666. /**
  23667. * Define the url of the texture.
  23668. */
  23669. url: Nullable<string>;
  23670. /**
  23671. * Define an offset on the texture to offset the u coordinates of the UVs
  23672. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23673. */
  23674. uOffset: number;
  23675. /**
  23676. * Define an offset on the texture to offset the v coordinates of the UVs
  23677. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23678. */
  23679. vOffset: number;
  23680. /**
  23681. * Define an offset on the texture to scale the u coordinates of the UVs
  23682. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23683. */
  23684. uScale: number;
  23685. /**
  23686. * Define an offset on the texture to scale the v coordinates of the UVs
  23687. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23688. */
  23689. vScale: number;
  23690. /**
  23691. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23692. * @see https://doc.babylonjs.com/how_to/more_materials
  23693. */
  23694. uAng: number;
  23695. /**
  23696. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23697. * @see https://doc.babylonjs.com/how_to/more_materials
  23698. */
  23699. vAng: number;
  23700. /**
  23701. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23702. * @see https://doc.babylonjs.com/how_to/more_materials
  23703. */
  23704. wAng: number;
  23705. /**
  23706. * Defines the center of rotation (U)
  23707. */
  23708. uRotationCenter: number;
  23709. /**
  23710. * Defines the center of rotation (V)
  23711. */
  23712. vRotationCenter: number;
  23713. /**
  23714. * Defines the center of rotation (W)
  23715. */
  23716. wRotationCenter: number;
  23717. /**
  23718. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23719. */
  23720. homogeneousRotationInUVTransform: boolean;
  23721. /**
  23722. * Are mip maps generated for this texture or not.
  23723. */
  23724. get noMipmap(): boolean;
  23725. /**
  23726. * List of inspectable custom properties (used by the Inspector)
  23727. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23728. */
  23729. inspectableCustomProperties: Nullable<IInspectable[]>;
  23730. private _noMipmap;
  23731. /** @hidden */
  23732. _invertY: boolean;
  23733. private _rowGenerationMatrix;
  23734. private _cachedTextureMatrix;
  23735. private _projectionModeMatrix;
  23736. private _t0;
  23737. private _t1;
  23738. private _t2;
  23739. private _cachedUOffset;
  23740. private _cachedVOffset;
  23741. private _cachedUScale;
  23742. private _cachedVScale;
  23743. private _cachedUAng;
  23744. private _cachedVAng;
  23745. private _cachedWAng;
  23746. private _cachedProjectionMatrixId;
  23747. private _cachedURotationCenter;
  23748. private _cachedVRotationCenter;
  23749. private _cachedWRotationCenter;
  23750. private _cachedHomogeneousRotationInUVTransform;
  23751. private _cachedCoordinatesMode;
  23752. /** @hidden */
  23753. protected _initialSamplingMode: number;
  23754. /** @hidden */
  23755. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23756. private _deleteBuffer;
  23757. protected _format: Nullable<number>;
  23758. private _delayedOnLoad;
  23759. private _delayedOnError;
  23760. private _mimeType?;
  23761. private _loaderOptions?;
  23762. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23763. get mimeType(): string | undefined;
  23764. /**
  23765. * Observable triggered once the texture has been loaded.
  23766. */
  23767. onLoadObservable: Observable<Texture>;
  23768. protected _isBlocking: boolean;
  23769. /**
  23770. * Is the texture preventing material to render while loading.
  23771. * If false, a default texture will be used instead of the loading one during the preparation step.
  23772. */
  23773. set isBlocking(value: boolean);
  23774. get isBlocking(): boolean;
  23775. /**
  23776. * Get the current sampling mode associated with the texture.
  23777. */
  23778. get samplingMode(): number;
  23779. /**
  23780. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23781. */
  23782. get invertY(): boolean;
  23783. /**
  23784. * Instantiates a new texture.
  23785. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23786. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23787. * @param url defines the url of the picture to load as a texture
  23788. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23789. * @param noMipmap defines if the texture will require mip maps or not
  23790. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23791. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23792. * @param onLoad defines a callback triggered when the texture has been loaded
  23793. * @param onError defines a callback triggered when an error occurred during the loading session
  23794. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23795. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23796. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23797. * @param mimeType defines an optional mime type information
  23798. * @param loaderOptions options to be passed to the loader
  23799. */
  23800. 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);
  23801. /**
  23802. * Update the url (and optional buffer) of this texture if url was null during construction.
  23803. * @param url the url of the texture
  23804. * @param buffer the buffer of the texture (defaults to null)
  23805. * @param onLoad callback called when the texture is loaded (defaults to null)
  23806. */
  23807. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23808. /**
  23809. * Finish the loading sequence of a texture flagged as delayed load.
  23810. * @hidden
  23811. */
  23812. delayLoad(): void;
  23813. private _prepareRowForTextureGeneration;
  23814. /**
  23815. * Checks if the texture has the same transform matrix than another texture
  23816. * @param texture texture to check against
  23817. * @returns true if the transforms are the same, else false
  23818. */
  23819. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23820. /**
  23821. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23822. * @returns the transform matrix of the texture.
  23823. */
  23824. getTextureMatrix(uBase?: number): Matrix;
  23825. /**
  23826. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23827. * @returns The reflection texture transform
  23828. */
  23829. getReflectionTextureMatrix(): Matrix;
  23830. /**
  23831. * Clones the texture.
  23832. * @returns the cloned texture
  23833. */
  23834. clone(): Texture;
  23835. /**
  23836. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23837. * @returns The JSON representation of the texture
  23838. */
  23839. serialize(): any;
  23840. /**
  23841. * Get the current class name of the texture useful for serialization or dynamic coding.
  23842. * @returns "Texture"
  23843. */
  23844. getClassName(): string;
  23845. /**
  23846. * Dispose the texture and release its associated resources.
  23847. */
  23848. dispose(): void;
  23849. /**
  23850. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23851. * @param parsedTexture Define the JSON representation of the texture
  23852. * @param scene Define the scene the parsed texture should be instantiated in
  23853. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23854. * @returns The parsed texture if successful
  23855. */
  23856. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23857. /**
  23858. * Creates a texture from its base 64 representation.
  23859. * @param data Define the base64 payload without the data: prefix
  23860. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23861. * @param scene Define the scene the texture should belong to
  23862. * @param noMipmap Forces the texture to not create mip map information if true
  23863. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23864. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23865. * @param onLoad define a callback triggered when the texture has been loaded
  23866. * @param onError define a callback triggered when an error occurred during the loading session
  23867. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23868. * @returns the created texture
  23869. */
  23870. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23871. /**
  23872. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23873. * @param data Define the base64 payload without the data: prefix
  23874. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23875. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23876. * @param scene Define the scene the texture should belong to
  23877. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23878. * @param noMipmap Forces the texture to not create mip map information if true
  23879. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23880. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23881. * @param onLoad define a callback triggered when the texture has been loaded
  23882. * @param onError define a callback triggered when an error occurred during the loading session
  23883. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23884. * @returns the created texture
  23885. */
  23886. 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;
  23887. }
  23888. }
  23889. declare module BABYLON {
  23890. /**
  23891. * ThinSprite Class used to represent a thin sprite
  23892. * This is the base class for sprites but can also directly be used with ThinEngine
  23893. * @see https://doc.babylonjs.com/babylon101/sprites
  23894. */
  23895. export class ThinSprite {
  23896. /** Gets or sets the cell index in the sprite sheet */
  23897. cellIndex: number;
  23898. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23899. cellRef: string;
  23900. /** Gets or sets the current world position */
  23901. position: IVector3Like;
  23902. /** Gets or sets the main color */
  23903. color: IColor4Like;
  23904. /** Gets or sets the width */
  23905. width: number;
  23906. /** Gets or sets the height */
  23907. height: number;
  23908. /** Gets or sets rotation angle */
  23909. angle: number;
  23910. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23911. invertU: boolean;
  23912. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23913. invertV: boolean;
  23914. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23915. isVisible: boolean;
  23916. /**
  23917. * Returns a boolean indicating if the animation is started
  23918. */
  23919. get animationStarted(): boolean;
  23920. /** Gets the initial key for the animation (setting it will restart the animation) */
  23921. get fromIndex(): number;
  23922. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23923. get toIndex(): number;
  23924. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23925. get loopAnimation(): boolean;
  23926. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23927. get delay(): number;
  23928. /** @hidden */
  23929. _xOffset: number;
  23930. /** @hidden */
  23931. _yOffset: number;
  23932. /** @hidden */
  23933. _xSize: number;
  23934. /** @hidden */
  23935. _ySize: number;
  23936. private _animationStarted;
  23937. protected _loopAnimation: boolean;
  23938. protected _fromIndex: number;
  23939. protected _toIndex: number;
  23940. protected _delay: number;
  23941. private _direction;
  23942. private _time;
  23943. private _onBaseAnimationEnd;
  23944. /**
  23945. * Creates a new Thin Sprite
  23946. */
  23947. constructor();
  23948. /**
  23949. * Starts an animation
  23950. * @param from defines the initial key
  23951. * @param to defines the end key
  23952. * @param loop defines if the animation must loop
  23953. * @param delay defines the start delay (in ms)
  23954. * @param onAnimationEnd defines a callback for when the animation ends
  23955. */
  23956. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  23957. /** Stops current animation (if any) */
  23958. stopAnimation(): void;
  23959. /** @hidden */
  23960. _animate(deltaTime: number): void;
  23961. }
  23962. }
  23963. declare module BABYLON {
  23964. /** @hidden */
  23965. export var imageProcessingCompatibility: {
  23966. name: string;
  23967. shader: string;
  23968. };
  23969. }
  23970. declare module BABYLON {
  23971. /** @hidden */
  23972. export var spritesPixelShader: {
  23973. name: string;
  23974. shader: string;
  23975. };
  23976. }
  23977. declare module BABYLON {
  23978. /** @hidden */
  23979. export var spritesVertexShader: {
  23980. name: string;
  23981. shader: string;
  23982. };
  23983. }
  23984. declare module BABYLON {
  23985. /**
  23986. * Class used to render sprites.
  23987. *
  23988. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  23989. */
  23990. export class SpriteRenderer {
  23991. /**
  23992. * Defines the texture of the spritesheet
  23993. */
  23994. texture: Nullable<ThinTexture>;
  23995. /**
  23996. * Defines the default width of a cell in the spritesheet
  23997. */
  23998. cellWidth: number;
  23999. /**
  24000. * Defines the default height of a cell in the spritesheet
  24001. */
  24002. cellHeight: number;
  24003. /**
  24004. * Blend mode use to render the particle, it can be any of
  24005. * the static Constants.ALPHA_x properties provided in this class.
  24006. * Default value is Constants.ALPHA_COMBINE
  24007. */
  24008. blendMode: number;
  24009. /**
  24010. * Gets or sets a boolean indicating if alpha mode is automatically
  24011. * reset.
  24012. */
  24013. autoResetAlpha: boolean;
  24014. /**
  24015. * Disables writing to the depth buffer when rendering the sprites.
  24016. * It can be handy to disable depth writing when using textures without alpha channel
  24017. * and setting some specific blend modes.
  24018. */
  24019. disableDepthWrite: boolean;
  24020. /**
  24021. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24022. */
  24023. fogEnabled: boolean;
  24024. /**
  24025. * Gets the capacity of the manager
  24026. */
  24027. get capacity(): number;
  24028. private readonly _engine;
  24029. private readonly _useVAO;
  24030. private readonly _useInstancing;
  24031. private readonly _scene;
  24032. private readonly _capacity;
  24033. private readonly _epsilon;
  24034. private _vertexBufferSize;
  24035. private _vertexData;
  24036. private _buffer;
  24037. private _vertexBuffers;
  24038. private _spriteBuffer;
  24039. private _indexBuffer;
  24040. private _effectBase;
  24041. private _effectFog;
  24042. private _vertexArrayObject;
  24043. /**
  24044. * Creates a new sprite Renderer
  24045. * @param engine defines the engine the renderer works with
  24046. * @param capacity defines the maximum allowed number of sprites
  24047. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24048. * @param scene defines the hosting scene
  24049. */
  24050. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24051. /**
  24052. * Render all child sprites
  24053. * @param sprites defines the list of sprites to render
  24054. * @param deltaTime defines the time since last frame
  24055. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24056. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24057. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24058. */
  24059. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24060. private _appendSpriteVertex;
  24061. /**
  24062. * Release associated resources
  24063. */
  24064. dispose(): void;
  24065. }
  24066. }
  24067. declare module BABYLON {
  24068. /**
  24069. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24070. */
  24071. export interface ISpriteManager extends IDisposable {
  24072. /**
  24073. * Gets manager's name
  24074. */
  24075. name: string;
  24076. /**
  24077. * Restricts the camera to viewing objects with the same layerMask.
  24078. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24079. */
  24080. layerMask: number;
  24081. /**
  24082. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24083. */
  24084. isPickable: boolean;
  24085. /**
  24086. * Gets the hosting scene
  24087. */
  24088. scene: Scene;
  24089. /**
  24090. * Specifies the rendering group id for this mesh (0 by default)
  24091. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24092. */
  24093. renderingGroupId: number;
  24094. /**
  24095. * Defines the list of sprites managed by the manager.
  24096. */
  24097. sprites: Array<Sprite>;
  24098. /**
  24099. * Gets or sets the spritesheet texture
  24100. */
  24101. texture: Texture;
  24102. /** Defines the default width of a cell in the spritesheet */
  24103. cellWidth: number;
  24104. /** Defines the default height of a cell in the spritesheet */
  24105. cellHeight: number;
  24106. /**
  24107. * Tests the intersection of a sprite with a specific ray.
  24108. * @param ray The ray we are sending to test the collision
  24109. * @param camera The camera space we are sending rays in
  24110. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24111. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24112. * @returns picking info or null.
  24113. */
  24114. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24115. /**
  24116. * Intersects the sprites with a ray
  24117. * @param ray defines the ray to intersect with
  24118. * @param camera defines the current active camera
  24119. * @param predicate defines a predicate used to select candidate sprites
  24120. * @returns null if no hit or a PickingInfo array
  24121. */
  24122. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24123. /**
  24124. * Renders the list of sprites on screen.
  24125. */
  24126. render(): void;
  24127. }
  24128. /**
  24129. * Class used to manage multiple sprites on the same spritesheet
  24130. * @see https://doc.babylonjs.com/babylon101/sprites
  24131. */
  24132. export class SpriteManager implements ISpriteManager {
  24133. /** defines the manager's name */
  24134. name: string;
  24135. /** Define the Url to load snippets */
  24136. static SnippetUrl: string;
  24137. /** Snippet ID if the manager was created from the snippet server */
  24138. snippetId: string;
  24139. /** Gets the list of sprites */
  24140. sprites: Sprite[];
  24141. /** Gets or sets the rendering group id (0 by default) */
  24142. renderingGroupId: number;
  24143. /** Gets or sets camera layer mask */
  24144. layerMask: number;
  24145. /** Gets or sets a boolean indicating if the sprites are pickable */
  24146. isPickable: boolean;
  24147. /**
  24148. * An event triggered when the manager is disposed.
  24149. */
  24150. onDisposeObservable: Observable<SpriteManager>;
  24151. /**
  24152. * Callback called when the manager is disposed
  24153. */
  24154. set onDispose(callback: () => void);
  24155. /**
  24156. * Gets or sets the unique id of the sprite
  24157. */
  24158. uniqueId: number;
  24159. /**
  24160. * Gets the array of sprites
  24161. */
  24162. get children(): Sprite[];
  24163. /**
  24164. * Gets the hosting scene
  24165. */
  24166. get scene(): Scene;
  24167. /**
  24168. * Gets the capacity of the manager
  24169. */
  24170. get capacity(): number;
  24171. /**
  24172. * Gets or sets the spritesheet texture
  24173. */
  24174. get texture(): Texture;
  24175. set texture(value: Texture);
  24176. /** Defines the default width of a cell in the spritesheet */
  24177. get cellWidth(): number;
  24178. set cellWidth(value: number);
  24179. /** Defines the default height of a cell in the spritesheet */
  24180. get cellHeight(): number;
  24181. set cellHeight(value: number);
  24182. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24183. get fogEnabled(): boolean;
  24184. set fogEnabled(value: boolean);
  24185. /**
  24186. * Blend mode use to render the particle, it can be any of
  24187. * the static Constants.ALPHA_x properties provided in this class.
  24188. * Default value is Constants.ALPHA_COMBINE
  24189. */
  24190. get blendMode(): number;
  24191. set blendMode(blendMode: number);
  24192. /** Disables writing to the depth buffer when rendering the sprites.
  24193. * It can be handy to disable depth writing when using textures without alpha channel
  24194. * and setting some specific blend modes.
  24195. */
  24196. disableDepthWrite: boolean;
  24197. private _spriteRenderer;
  24198. /** Associative array from JSON sprite data file */
  24199. private _cellData;
  24200. /** Array of sprite names from JSON sprite data file */
  24201. private _spriteMap;
  24202. /** True when packed cell data from JSON file is ready*/
  24203. private _packedAndReady;
  24204. private _textureContent;
  24205. private _onDisposeObserver;
  24206. private _fromPacked;
  24207. private _scene;
  24208. /**
  24209. * Creates a new sprite manager
  24210. * @param name defines the manager's name
  24211. * @param imgUrl defines the sprite sheet url
  24212. * @param capacity defines the maximum allowed number of sprites
  24213. * @param cellSize defines the size of a sprite cell
  24214. * @param scene defines the hosting scene
  24215. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24216. * @param samplingMode defines the smapling mode to use with spritesheet
  24217. * @param fromPacked set to false; do not alter
  24218. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24219. */
  24220. constructor(
  24221. /** defines the manager's name */
  24222. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24223. /**
  24224. * Returns the string "SpriteManager"
  24225. * @returns "SpriteManager"
  24226. */
  24227. getClassName(): string;
  24228. private _makePacked;
  24229. private _checkTextureAlpha;
  24230. /**
  24231. * Intersects the sprites with a ray
  24232. * @param ray defines the ray to intersect with
  24233. * @param camera defines the current active camera
  24234. * @param predicate defines a predicate used to select candidate sprites
  24235. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24236. * @returns null if no hit or a PickingInfo
  24237. */
  24238. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24239. /**
  24240. * Intersects the sprites with a ray
  24241. * @param ray defines the ray to intersect with
  24242. * @param camera defines the current active camera
  24243. * @param predicate defines a predicate used to select candidate sprites
  24244. * @returns null if no hit or a PickingInfo array
  24245. */
  24246. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24247. /**
  24248. * Render all child sprites
  24249. */
  24250. render(): void;
  24251. private _customUpdate;
  24252. /**
  24253. * Release associated resources
  24254. */
  24255. dispose(): void;
  24256. /**
  24257. * Serializes the sprite manager to a JSON object
  24258. * @param serializeTexture defines if the texture must be serialized as well
  24259. * @returns the JSON object
  24260. */
  24261. serialize(serializeTexture?: boolean): any;
  24262. /**
  24263. * Parses a JSON object to create a new sprite manager.
  24264. * @param parsedManager The JSON object to parse
  24265. * @param scene The scene to create the sprite managerin
  24266. * @param rootUrl The root url to use to load external dependencies like texture
  24267. * @returns the new sprite manager
  24268. */
  24269. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24270. /**
  24271. * Creates a sprite manager from a snippet saved in a remote file
  24272. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24273. * @param url defines the url to load from
  24274. * @param scene defines the hosting scene
  24275. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24276. * @returns a promise that will resolve to the new sprite manager
  24277. */
  24278. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24279. /**
  24280. * Creates a sprite manager from a snippet saved by the sprite editor
  24281. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24282. * @param scene defines the hosting scene
  24283. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24284. * @returns a promise that will resolve to the new sprite manager
  24285. */
  24286. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24287. }
  24288. }
  24289. declare module BABYLON {
  24290. /**
  24291. * Class used to represent a sprite
  24292. * @see https://doc.babylonjs.com/babylon101/sprites
  24293. */
  24294. export class Sprite extends ThinSprite implements IAnimatable {
  24295. /** defines the name */
  24296. name: string;
  24297. /** Gets or sets the current world position */
  24298. position: Vector3;
  24299. /** Gets or sets the main color */
  24300. color: Color4;
  24301. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24302. disposeWhenFinishedAnimating: boolean;
  24303. /** Gets the list of attached animations */
  24304. animations: Nullable<Array<Animation>>;
  24305. /** Gets or sets a boolean indicating if the sprite can be picked */
  24306. isPickable: boolean;
  24307. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24308. useAlphaForPicking: boolean;
  24309. /**
  24310. * Gets or sets the associated action manager
  24311. */
  24312. actionManager: Nullable<ActionManager>;
  24313. /**
  24314. * An event triggered when the control has been disposed
  24315. */
  24316. onDisposeObservable: Observable<Sprite>;
  24317. private _manager;
  24318. private _onAnimationEnd;
  24319. /**
  24320. * Gets or sets the sprite size
  24321. */
  24322. get size(): number;
  24323. set size(value: number);
  24324. /**
  24325. * Gets or sets the unique id of the sprite
  24326. */
  24327. uniqueId: number;
  24328. /**
  24329. * Gets the manager of this sprite
  24330. */
  24331. get manager(): ISpriteManager;
  24332. /**
  24333. * Creates a new Sprite
  24334. * @param name defines the name
  24335. * @param manager defines the manager
  24336. */
  24337. constructor(
  24338. /** defines the name */
  24339. name: string, manager: ISpriteManager);
  24340. /**
  24341. * Returns the string "Sprite"
  24342. * @returns "Sprite"
  24343. */
  24344. getClassName(): string;
  24345. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24346. get fromIndex(): number;
  24347. set fromIndex(value: number);
  24348. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24349. get toIndex(): number;
  24350. set toIndex(value: number);
  24351. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24352. get loopAnimation(): boolean;
  24353. set loopAnimation(value: boolean);
  24354. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24355. get delay(): number;
  24356. set delay(value: number);
  24357. /**
  24358. * Starts an animation
  24359. * @param from defines the initial key
  24360. * @param to defines the end key
  24361. * @param loop defines if the animation must loop
  24362. * @param delay defines the start delay (in ms)
  24363. * @param onAnimationEnd defines a callback to call when animation ends
  24364. */
  24365. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24366. private _endAnimation;
  24367. /** Release associated resources */
  24368. dispose(): void;
  24369. /**
  24370. * Serializes the sprite to a JSON object
  24371. * @returns the JSON object
  24372. */
  24373. serialize(): any;
  24374. /**
  24375. * Parses a JSON object to create a new sprite
  24376. * @param parsedSprite The JSON object to parse
  24377. * @param manager defines the hosting manager
  24378. * @returns the new sprite
  24379. */
  24380. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24381. }
  24382. }
  24383. declare module BABYLON {
  24384. /**
  24385. * Information about the result of picking within a scene
  24386. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24387. */
  24388. export class PickingInfo {
  24389. /** @hidden */
  24390. _pickingUnavailable: boolean;
  24391. /**
  24392. * If the pick collided with an object
  24393. */
  24394. hit: boolean;
  24395. /**
  24396. * Distance away where the pick collided
  24397. */
  24398. distance: number;
  24399. /**
  24400. * The location of pick collision
  24401. */
  24402. pickedPoint: Nullable<Vector3>;
  24403. /**
  24404. * The mesh corresponding the the pick collision
  24405. */
  24406. pickedMesh: Nullable<AbstractMesh>;
  24407. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24408. bu: number;
  24409. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24410. bv: number;
  24411. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24412. faceId: number;
  24413. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24414. subMeshFaceId: number;
  24415. /** Id of the the submesh that was picked */
  24416. subMeshId: number;
  24417. /** If a sprite was picked, this will be the sprite the pick collided with */
  24418. pickedSprite: Nullable<Sprite>;
  24419. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24420. thinInstanceIndex: number;
  24421. /**
  24422. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24423. */
  24424. originMesh: Nullable<AbstractMesh>;
  24425. /**
  24426. * The ray that was used to perform the picking.
  24427. */
  24428. ray: Nullable<Ray>;
  24429. /**
  24430. * Gets the normal correspodning to the face the pick collided with
  24431. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24432. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24433. * @returns The normal correspodning to the face the pick collided with
  24434. */
  24435. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24436. /**
  24437. * Gets the texture coordinates of where the pick occured
  24438. * @returns the vector containing the coordnates of the texture
  24439. */
  24440. getTextureCoordinates(): Nullable<Vector2>;
  24441. }
  24442. }
  24443. declare module BABYLON {
  24444. /**
  24445. * Gather the list of pointer event types as constants.
  24446. */
  24447. export class PointerEventTypes {
  24448. /**
  24449. * 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.
  24450. */
  24451. static readonly POINTERDOWN: number;
  24452. /**
  24453. * The pointerup event is fired when a pointer is no longer active.
  24454. */
  24455. static readonly POINTERUP: number;
  24456. /**
  24457. * The pointermove event is fired when a pointer changes coordinates.
  24458. */
  24459. static readonly POINTERMOVE: number;
  24460. /**
  24461. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24462. */
  24463. static readonly POINTERWHEEL: number;
  24464. /**
  24465. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24466. */
  24467. static readonly POINTERPICK: number;
  24468. /**
  24469. * The pointertap event is fired when a the object has been touched and released without drag.
  24470. */
  24471. static readonly POINTERTAP: number;
  24472. /**
  24473. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24474. */
  24475. static readonly POINTERDOUBLETAP: number;
  24476. }
  24477. /**
  24478. * Base class of pointer info types.
  24479. */
  24480. export class PointerInfoBase {
  24481. /**
  24482. * Defines the type of event (PointerEventTypes)
  24483. */
  24484. type: number;
  24485. /**
  24486. * Defines the related dom event
  24487. */
  24488. event: PointerEvent | MouseWheelEvent;
  24489. /**
  24490. * Instantiates the base class of pointers info.
  24491. * @param type Defines the type of event (PointerEventTypes)
  24492. * @param event Defines the related dom event
  24493. */
  24494. constructor(
  24495. /**
  24496. * Defines the type of event (PointerEventTypes)
  24497. */
  24498. type: number,
  24499. /**
  24500. * Defines the related dom event
  24501. */
  24502. event: PointerEvent | MouseWheelEvent);
  24503. }
  24504. /**
  24505. * This class is used to store pointer related info for the onPrePointerObservable event.
  24506. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24507. */
  24508. export class PointerInfoPre extends PointerInfoBase {
  24509. /**
  24510. * Ray from a pointer if availible (eg. 6dof controller)
  24511. */
  24512. ray: Nullable<Ray>;
  24513. /**
  24514. * Defines the local position of the pointer on the canvas.
  24515. */
  24516. localPosition: Vector2;
  24517. /**
  24518. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24519. */
  24520. skipOnPointerObservable: boolean;
  24521. /**
  24522. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24523. * @param type Defines the type of event (PointerEventTypes)
  24524. * @param event Defines the related dom event
  24525. * @param localX Defines the local x coordinates of the pointer when the event occured
  24526. * @param localY Defines the local y coordinates of the pointer when the event occured
  24527. */
  24528. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24529. }
  24530. /**
  24531. * This type contains all the data related to a pointer event in Babylon.js.
  24532. * 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.
  24533. */
  24534. export class PointerInfo extends PointerInfoBase {
  24535. /**
  24536. * Defines the picking info associated to the info (if any)\
  24537. */
  24538. pickInfo: Nullable<PickingInfo>;
  24539. /**
  24540. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24541. * @param type Defines the type of event (PointerEventTypes)
  24542. * @param event Defines the related dom event
  24543. * @param pickInfo Defines the picking info associated to the info (if any)\
  24544. */
  24545. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24546. /**
  24547. * Defines the picking info associated to the info (if any)\
  24548. */
  24549. pickInfo: Nullable<PickingInfo>);
  24550. }
  24551. /**
  24552. * Data relating to a touch event on the screen.
  24553. */
  24554. export interface PointerTouch {
  24555. /**
  24556. * X coordinate of touch.
  24557. */
  24558. x: number;
  24559. /**
  24560. * Y coordinate of touch.
  24561. */
  24562. y: number;
  24563. /**
  24564. * Id of touch. Unique for each finger.
  24565. */
  24566. pointerId: number;
  24567. /**
  24568. * Event type passed from DOM.
  24569. */
  24570. type: any;
  24571. }
  24572. }
  24573. declare module BABYLON {
  24574. /**
  24575. * Manage the mouse inputs to control the movement of a free camera.
  24576. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24577. */
  24578. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24579. /**
  24580. * Define if touch is enabled in the mouse input
  24581. */
  24582. touchEnabled: boolean;
  24583. /**
  24584. * Defines the camera the input is attached to.
  24585. */
  24586. camera: FreeCamera;
  24587. /**
  24588. * Defines the buttons associated with the input to handle camera move.
  24589. */
  24590. buttons: number[];
  24591. /**
  24592. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24593. */
  24594. angularSensibility: number;
  24595. private _pointerInput;
  24596. private _onMouseMove;
  24597. private _observer;
  24598. private previousPosition;
  24599. /**
  24600. * Observable for when a pointer move event occurs containing the move offset
  24601. */
  24602. onPointerMovedObservable: Observable<{
  24603. offsetX: number;
  24604. offsetY: number;
  24605. }>;
  24606. /**
  24607. * @hidden
  24608. * If the camera should be rotated automatically based on pointer movement
  24609. */
  24610. _allowCameraRotation: boolean;
  24611. /**
  24612. * Manage the mouse inputs to control the movement of a free camera.
  24613. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24614. * @param touchEnabled Defines if touch is enabled or not
  24615. */
  24616. constructor(
  24617. /**
  24618. * Define if touch is enabled in the mouse input
  24619. */
  24620. touchEnabled?: boolean);
  24621. /**
  24622. * Attach the input controls to a specific dom element to get the input from.
  24623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24624. */
  24625. attachControl(noPreventDefault?: boolean): void;
  24626. /**
  24627. * Called on JS contextmenu event.
  24628. * Override this method to provide functionality.
  24629. */
  24630. protected onContextMenu(evt: PointerEvent): void;
  24631. /**
  24632. * Detach the current controls from the specified dom element.
  24633. */
  24634. detachControl(): void;
  24635. /**
  24636. * Gets the class name of the current intput.
  24637. * @returns the class name
  24638. */
  24639. getClassName(): string;
  24640. /**
  24641. * Get the friendly name associated with the input class.
  24642. * @returns the input friendly name
  24643. */
  24644. getSimpleName(): string;
  24645. }
  24646. }
  24647. declare module BABYLON {
  24648. /**
  24649. * Base class for mouse wheel input..
  24650. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24651. * for example usage.
  24652. */
  24653. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24654. /**
  24655. * Defines the camera the input is attached to.
  24656. */
  24657. abstract camera: Camera;
  24658. /**
  24659. * How fast is the camera moves in relation to X axis mouseWheel events.
  24660. * Use negative value to reverse direction.
  24661. */
  24662. wheelPrecisionX: number;
  24663. /**
  24664. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24665. * Use negative value to reverse direction.
  24666. */
  24667. wheelPrecisionY: number;
  24668. /**
  24669. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24670. * Use negative value to reverse direction.
  24671. */
  24672. wheelPrecisionZ: number;
  24673. /**
  24674. * Observable for when a mouse wheel move event occurs.
  24675. */
  24676. onChangedObservable: Observable<{
  24677. wheelDeltaX: number;
  24678. wheelDeltaY: number;
  24679. wheelDeltaZ: number;
  24680. }>;
  24681. private _wheel;
  24682. private _observer;
  24683. /**
  24684. * Attach the input controls to a specific dom element to get the input from.
  24685. * @param noPreventDefault Defines whether event caught by the controls
  24686. * should call preventdefault().
  24687. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24688. */
  24689. attachControl(noPreventDefault?: boolean): void;
  24690. /**
  24691. * Detach the current controls from the specified dom element.
  24692. */
  24693. detachControl(): void;
  24694. /**
  24695. * Called for each rendered frame.
  24696. */
  24697. checkInputs(): void;
  24698. /**
  24699. * Gets the class name of the current intput.
  24700. * @returns the class name
  24701. */
  24702. getClassName(): string;
  24703. /**
  24704. * Get the friendly name associated with the input class.
  24705. * @returns the input friendly name
  24706. */
  24707. getSimpleName(): string;
  24708. /**
  24709. * Incremental value of multiple mouse wheel movements of the X axis.
  24710. * Should be zero-ed when read.
  24711. */
  24712. protected _wheelDeltaX: number;
  24713. /**
  24714. * Incremental value of multiple mouse wheel movements of the Y axis.
  24715. * Should be zero-ed when read.
  24716. */
  24717. protected _wheelDeltaY: number;
  24718. /**
  24719. * Incremental value of multiple mouse wheel movements of the Z axis.
  24720. * Should be zero-ed when read.
  24721. */
  24722. protected _wheelDeltaZ: number;
  24723. /**
  24724. * Firefox uses a different scheme to report scroll distances to other
  24725. * browsers. Rather than use complicated methods to calculate the exact
  24726. * multiple we need to apply, let's just cheat and use a constant.
  24727. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24728. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24729. */
  24730. private readonly _ffMultiplier;
  24731. /**
  24732. * Different event attributes for wheel data fall into a few set ranges.
  24733. * Some relevant but dated date here:
  24734. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24735. */
  24736. private readonly _normalize;
  24737. }
  24738. }
  24739. declare module BABYLON {
  24740. /**
  24741. * Manage the mouse wheel inputs to control a free camera.
  24742. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24743. */
  24744. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24745. /**
  24746. * Defines the camera the input is attached to.
  24747. */
  24748. camera: FreeCamera;
  24749. /**
  24750. * Gets the class name of the current input.
  24751. * @returns the class name
  24752. */
  24753. getClassName(): string;
  24754. /**
  24755. * Set which movement axis (relative to camera's orientation) the mouse
  24756. * wheel's X axis controls.
  24757. * @param axis The axis to be moved. Set null to clear.
  24758. */
  24759. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24760. /**
  24761. * Get the configured movement axis (relative to camera's orientation) the
  24762. * mouse wheel's X axis controls.
  24763. * @returns The configured axis or null if none.
  24764. */
  24765. get wheelXMoveRelative(): Nullable<Coordinate>;
  24766. /**
  24767. * Set which movement axis (relative to camera's orientation) the mouse
  24768. * wheel's Y axis controls.
  24769. * @param axis The axis to be moved. Set null to clear.
  24770. */
  24771. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24772. /**
  24773. * Get the configured movement axis (relative to camera's orientation) the
  24774. * mouse wheel's Y axis controls.
  24775. * @returns The configured axis or null if none.
  24776. */
  24777. get wheelYMoveRelative(): Nullable<Coordinate>;
  24778. /**
  24779. * Set which movement axis (relative to camera's orientation) the mouse
  24780. * wheel's Z axis controls.
  24781. * @param axis The axis to be moved. Set null to clear.
  24782. */
  24783. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24784. /**
  24785. * Get the configured movement axis (relative to camera's orientation) the
  24786. * mouse wheel's Z axis controls.
  24787. * @returns The configured axis or null if none.
  24788. */
  24789. get wheelZMoveRelative(): Nullable<Coordinate>;
  24790. /**
  24791. * Set which rotation axis (relative to camera's orientation) the mouse
  24792. * wheel's X axis controls.
  24793. * @param axis The axis to be moved. Set null to clear.
  24794. */
  24795. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24796. /**
  24797. * Get the configured rotation axis (relative to camera's orientation) the
  24798. * mouse wheel's X axis controls.
  24799. * @returns The configured axis or null if none.
  24800. */
  24801. get wheelXRotateRelative(): Nullable<Coordinate>;
  24802. /**
  24803. * Set which rotation axis (relative to camera's orientation) the mouse
  24804. * wheel's Y axis controls.
  24805. * @param axis The axis to be moved. Set null to clear.
  24806. */
  24807. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24808. /**
  24809. * Get the configured rotation axis (relative to camera's orientation) the
  24810. * mouse wheel's Y axis controls.
  24811. * @returns The configured axis or null if none.
  24812. */
  24813. get wheelYRotateRelative(): Nullable<Coordinate>;
  24814. /**
  24815. * Set which rotation axis (relative to camera's orientation) the mouse
  24816. * wheel's Z axis controls.
  24817. * @param axis The axis to be moved. Set null to clear.
  24818. */
  24819. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24820. /**
  24821. * Get the configured rotation axis (relative to camera's orientation) the
  24822. * mouse wheel's Z axis controls.
  24823. * @returns The configured axis or null if none.
  24824. */
  24825. get wheelZRotateRelative(): Nullable<Coordinate>;
  24826. /**
  24827. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24828. * controls.
  24829. * @param axis The axis to be moved. Set null to clear.
  24830. */
  24831. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24832. /**
  24833. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24834. * X axis controls.
  24835. * @returns The configured axis or null if none.
  24836. */
  24837. get wheelXMoveScene(): Nullable<Coordinate>;
  24838. /**
  24839. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24840. * controls.
  24841. * @param axis The axis to be moved. Set null to clear.
  24842. */
  24843. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24844. /**
  24845. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24846. * Y axis controls.
  24847. * @returns The configured axis or null if none.
  24848. */
  24849. get wheelYMoveScene(): Nullable<Coordinate>;
  24850. /**
  24851. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24852. * controls.
  24853. * @param axis The axis to be moved. Set null to clear.
  24854. */
  24855. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24856. /**
  24857. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24858. * Z axis controls.
  24859. * @returns The configured axis or null if none.
  24860. */
  24861. get wheelZMoveScene(): Nullable<Coordinate>;
  24862. /**
  24863. * Called for each rendered frame.
  24864. */
  24865. checkInputs(): void;
  24866. private _moveRelative;
  24867. private _rotateRelative;
  24868. private _moveScene;
  24869. /**
  24870. * These are set to the desired default behaviour.
  24871. */
  24872. private _wheelXAction;
  24873. private _wheelXActionCoordinate;
  24874. private _wheelYAction;
  24875. private _wheelYActionCoordinate;
  24876. private _wheelZAction;
  24877. private _wheelZActionCoordinate;
  24878. /**
  24879. * Update the camera according to any configured properties for the 3
  24880. * mouse-wheel axis.
  24881. */
  24882. private _updateCamera;
  24883. }
  24884. }
  24885. declare module BABYLON {
  24886. /**
  24887. * Manage the touch inputs to control the movement of a free camera.
  24888. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24889. */
  24890. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24891. /**
  24892. * Define if mouse events can be treated as touch events
  24893. */
  24894. allowMouse: boolean;
  24895. /**
  24896. * Defines the camera the input is attached to.
  24897. */
  24898. camera: FreeCamera;
  24899. /**
  24900. * Defines the touch sensibility for rotation.
  24901. * The higher the faster.
  24902. */
  24903. touchAngularSensibility: number;
  24904. /**
  24905. * Defines the touch sensibility for move.
  24906. * The higher the faster.
  24907. */
  24908. touchMoveSensibility: number;
  24909. private _offsetX;
  24910. private _offsetY;
  24911. private _pointerPressed;
  24912. private _pointerInput?;
  24913. private _observer;
  24914. private _onLostFocus;
  24915. /**
  24916. * Manage the touch inputs to control the movement of a free camera.
  24917. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24918. * @param allowMouse Defines if mouse events can be treated as touch events
  24919. */
  24920. constructor(
  24921. /**
  24922. * Define if mouse events can be treated as touch events
  24923. */
  24924. allowMouse?: boolean);
  24925. /**
  24926. * Attach the input controls to a specific dom element to get the input from.
  24927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24928. */
  24929. attachControl(noPreventDefault?: boolean): void;
  24930. /**
  24931. * Detach the current controls from the specified dom element.
  24932. */
  24933. detachControl(): void;
  24934. /**
  24935. * Update the current camera state depending on the inputs that have been used this frame.
  24936. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24937. */
  24938. checkInputs(): void;
  24939. /**
  24940. * Gets the class name of the current intput.
  24941. * @returns the class name
  24942. */
  24943. getClassName(): string;
  24944. /**
  24945. * Get the friendly name associated with the input class.
  24946. * @returns the input friendly name
  24947. */
  24948. getSimpleName(): string;
  24949. }
  24950. }
  24951. declare module BABYLON {
  24952. /**
  24953. * Default Inputs manager for the FreeCamera.
  24954. * It groups all the default supported inputs for ease of use.
  24955. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24956. */
  24957. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24958. /**
  24959. * @hidden
  24960. */
  24961. _mouseInput: Nullable<FreeCameraMouseInput>;
  24962. /**
  24963. * @hidden
  24964. */
  24965. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24966. /**
  24967. * Instantiates a new FreeCameraInputsManager.
  24968. * @param camera Defines the camera the inputs belong to
  24969. */
  24970. constructor(camera: FreeCamera);
  24971. /**
  24972. * Add keyboard input support to the input manager.
  24973. * @returns the current input manager
  24974. */
  24975. addKeyboard(): FreeCameraInputsManager;
  24976. /**
  24977. * Add mouse input support to the input manager.
  24978. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  24979. * @returns the current input manager
  24980. */
  24981. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  24982. /**
  24983. * Removes the mouse input support from the manager
  24984. * @returns the current input manager
  24985. */
  24986. removeMouse(): FreeCameraInputsManager;
  24987. /**
  24988. * Add mouse wheel input support to the input manager.
  24989. * @returns the current input manager
  24990. */
  24991. addMouseWheel(): FreeCameraInputsManager;
  24992. /**
  24993. * Removes the mouse wheel input support from the manager
  24994. * @returns the current input manager
  24995. */
  24996. removeMouseWheel(): FreeCameraInputsManager;
  24997. /**
  24998. * Add touch input support to the input manager.
  24999. * @returns the current input manager
  25000. */
  25001. addTouch(): FreeCameraInputsManager;
  25002. /**
  25003. * Remove all attached input methods from a camera
  25004. */
  25005. clear(): void;
  25006. }
  25007. }
  25008. declare module BABYLON {
  25009. /**
  25010. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25011. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25012. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25013. */
  25014. export class FreeCamera extends TargetCamera {
  25015. /**
  25016. * Define the collision ellipsoid of the camera.
  25017. * This is helpful to simulate a camera body like the player body around the camera
  25018. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25019. */
  25020. ellipsoid: Vector3;
  25021. /**
  25022. * Define an offset for the position of the ellipsoid around the camera.
  25023. * This can be helpful to determine the center of the body near the gravity center of the body
  25024. * instead of its head.
  25025. */
  25026. ellipsoidOffset: Vector3;
  25027. /**
  25028. * Enable or disable collisions of the camera with the rest of the scene objects.
  25029. */
  25030. checkCollisions: boolean;
  25031. /**
  25032. * Enable or disable gravity on the camera.
  25033. */
  25034. applyGravity: boolean;
  25035. /**
  25036. * Define the input manager associated to the camera.
  25037. */
  25038. inputs: FreeCameraInputsManager;
  25039. /**
  25040. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25041. * Higher values reduce sensitivity.
  25042. */
  25043. get angularSensibility(): number;
  25044. /**
  25045. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25046. * Higher values reduce sensitivity.
  25047. */
  25048. set angularSensibility(value: number);
  25049. /**
  25050. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25051. */
  25052. get keysUp(): number[];
  25053. set keysUp(value: number[]);
  25054. /**
  25055. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25056. */
  25057. get keysUpward(): number[];
  25058. set keysUpward(value: number[]);
  25059. /**
  25060. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25061. */
  25062. get keysDown(): number[];
  25063. set keysDown(value: number[]);
  25064. /**
  25065. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25066. */
  25067. get keysDownward(): number[];
  25068. set keysDownward(value: number[]);
  25069. /**
  25070. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25071. */
  25072. get keysLeft(): number[];
  25073. set keysLeft(value: number[]);
  25074. /**
  25075. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25076. */
  25077. get keysRight(): number[];
  25078. set keysRight(value: number[]);
  25079. /**
  25080. * Event raised when the camera collide with a mesh in the scene.
  25081. */
  25082. onCollide: (collidedMesh: AbstractMesh) => void;
  25083. private _collider;
  25084. private _needMoveForGravity;
  25085. private _oldPosition;
  25086. private _diffPosition;
  25087. private _newPosition;
  25088. /** @hidden */
  25089. _localDirection: Vector3;
  25090. /** @hidden */
  25091. _transformedDirection: Vector3;
  25092. /**
  25093. * Instantiates a Free Camera.
  25094. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25095. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25096. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25097. * @param name Define the name of the camera in the scene
  25098. * @param position Define the start position of the camera in the scene
  25099. * @param scene Define the scene the camera belongs to
  25100. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25101. */
  25102. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25103. /**
  25104. * Attach the input controls to a specific dom element to get the input from.
  25105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25106. */
  25107. attachControl(noPreventDefault?: boolean): void;
  25108. /**
  25109. * Attach the input controls to a specific dom element to get the input from.
  25110. * @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
  25111. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25112. * BACK COMPAT SIGNATURE ONLY.
  25113. */
  25114. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25115. /**
  25116. * Detach the current controls from the specified dom element.
  25117. */
  25118. detachControl(): void;
  25119. /**
  25120. * Detach the current controls from the specified dom element.
  25121. * @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
  25122. */
  25123. detachControl(ignored: any): void;
  25124. private _collisionMask;
  25125. /**
  25126. * Define a collision mask to limit the list of object the camera can collide with
  25127. */
  25128. get collisionMask(): number;
  25129. set collisionMask(mask: number);
  25130. /** @hidden */
  25131. _collideWithWorld(displacement: Vector3): void;
  25132. private _onCollisionPositionChange;
  25133. /** @hidden */
  25134. _checkInputs(): void;
  25135. /** @hidden */
  25136. _decideIfNeedsToMove(): boolean;
  25137. /** @hidden */
  25138. _updatePosition(): void;
  25139. /**
  25140. * Destroy the camera and release the current resources hold by it.
  25141. */
  25142. dispose(): void;
  25143. /**
  25144. * Gets the current object class name.
  25145. * @return the class name
  25146. */
  25147. getClassName(): string;
  25148. }
  25149. }
  25150. declare module BABYLON {
  25151. /**
  25152. * Represents a gamepad control stick position
  25153. */
  25154. export class StickValues {
  25155. /**
  25156. * The x component of the control stick
  25157. */
  25158. x: number;
  25159. /**
  25160. * The y component of the control stick
  25161. */
  25162. y: number;
  25163. /**
  25164. * Initializes the gamepad x and y control stick values
  25165. * @param x The x component of the gamepad control stick value
  25166. * @param y The y component of the gamepad control stick value
  25167. */
  25168. constructor(
  25169. /**
  25170. * The x component of the control stick
  25171. */
  25172. x: number,
  25173. /**
  25174. * The y component of the control stick
  25175. */
  25176. y: number);
  25177. }
  25178. /**
  25179. * An interface which manages callbacks for gamepad button changes
  25180. */
  25181. export interface GamepadButtonChanges {
  25182. /**
  25183. * Called when a gamepad has been changed
  25184. */
  25185. changed: boolean;
  25186. /**
  25187. * Called when a gamepad press event has been triggered
  25188. */
  25189. pressChanged: boolean;
  25190. /**
  25191. * Called when a touch event has been triggered
  25192. */
  25193. touchChanged: boolean;
  25194. /**
  25195. * Called when a value has changed
  25196. */
  25197. valueChanged: boolean;
  25198. }
  25199. /**
  25200. * Represents a gamepad
  25201. */
  25202. export class Gamepad {
  25203. /**
  25204. * The id of the gamepad
  25205. */
  25206. id: string;
  25207. /**
  25208. * The index of the gamepad
  25209. */
  25210. index: number;
  25211. /**
  25212. * The browser gamepad
  25213. */
  25214. browserGamepad: any;
  25215. /**
  25216. * Specifies what type of gamepad this represents
  25217. */
  25218. type: number;
  25219. private _leftStick;
  25220. private _rightStick;
  25221. /** @hidden */
  25222. _isConnected: boolean;
  25223. private _leftStickAxisX;
  25224. private _leftStickAxisY;
  25225. private _rightStickAxisX;
  25226. private _rightStickAxisY;
  25227. /**
  25228. * Triggered when the left control stick has been changed
  25229. */
  25230. private _onleftstickchanged;
  25231. /**
  25232. * Triggered when the right control stick has been changed
  25233. */
  25234. private _onrightstickchanged;
  25235. /**
  25236. * Represents a gamepad controller
  25237. */
  25238. static GAMEPAD: number;
  25239. /**
  25240. * Represents a generic controller
  25241. */
  25242. static GENERIC: number;
  25243. /**
  25244. * Represents an XBox controller
  25245. */
  25246. static XBOX: number;
  25247. /**
  25248. * Represents a pose-enabled controller
  25249. */
  25250. static POSE_ENABLED: number;
  25251. /**
  25252. * Represents an Dual Shock controller
  25253. */
  25254. static DUALSHOCK: number;
  25255. /**
  25256. * Specifies whether the left control stick should be Y-inverted
  25257. */
  25258. protected _invertLeftStickY: boolean;
  25259. /**
  25260. * Specifies if the gamepad has been connected
  25261. */
  25262. get isConnected(): boolean;
  25263. /**
  25264. * Initializes the gamepad
  25265. * @param id The id of the gamepad
  25266. * @param index The index of the gamepad
  25267. * @param browserGamepad The browser gamepad
  25268. * @param leftStickX The x component of the left joystick
  25269. * @param leftStickY The y component of the left joystick
  25270. * @param rightStickX The x component of the right joystick
  25271. * @param rightStickY The y component of the right joystick
  25272. */
  25273. constructor(
  25274. /**
  25275. * The id of the gamepad
  25276. */
  25277. id: string,
  25278. /**
  25279. * The index of the gamepad
  25280. */
  25281. index: number,
  25282. /**
  25283. * The browser gamepad
  25284. */
  25285. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25286. /**
  25287. * Callback triggered when the left joystick has changed
  25288. * @param callback
  25289. */
  25290. onleftstickchanged(callback: (values: StickValues) => void): void;
  25291. /**
  25292. * Callback triggered when the right joystick has changed
  25293. * @param callback
  25294. */
  25295. onrightstickchanged(callback: (values: StickValues) => void): void;
  25296. /**
  25297. * Gets the left joystick
  25298. */
  25299. get leftStick(): StickValues;
  25300. /**
  25301. * Sets the left joystick values
  25302. */
  25303. set leftStick(newValues: StickValues);
  25304. /**
  25305. * Gets the right joystick
  25306. */
  25307. get rightStick(): StickValues;
  25308. /**
  25309. * Sets the right joystick value
  25310. */
  25311. set rightStick(newValues: StickValues);
  25312. /**
  25313. * Updates the gamepad joystick positions
  25314. */
  25315. update(): void;
  25316. /**
  25317. * Disposes the gamepad
  25318. */
  25319. dispose(): void;
  25320. }
  25321. /**
  25322. * Represents a generic gamepad
  25323. */
  25324. export class GenericPad extends Gamepad {
  25325. private _buttons;
  25326. private _onbuttondown;
  25327. private _onbuttonup;
  25328. /**
  25329. * Observable triggered when a button has been pressed
  25330. */
  25331. onButtonDownObservable: Observable<number>;
  25332. /**
  25333. * Observable triggered when a button has been released
  25334. */
  25335. onButtonUpObservable: Observable<number>;
  25336. /**
  25337. * Callback triggered when a button has been pressed
  25338. * @param callback Called when a button has been pressed
  25339. */
  25340. onbuttondown(callback: (buttonPressed: number) => void): void;
  25341. /**
  25342. * Callback triggered when a button has been released
  25343. * @param callback Called when a button has been released
  25344. */
  25345. onbuttonup(callback: (buttonReleased: number) => void): void;
  25346. /**
  25347. * Initializes the generic gamepad
  25348. * @param id The id of the generic gamepad
  25349. * @param index The index of the generic gamepad
  25350. * @param browserGamepad The browser gamepad
  25351. */
  25352. constructor(id: string, index: number, browserGamepad: any);
  25353. private _setButtonValue;
  25354. /**
  25355. * Updates the generic gamepad
  25356. */
  25357. update(): void;
  25358. /**
  25359. * Disposes the generic gamepad
  25360. */
  25361. dispose(): void;
  25362. }
  25363. }
  25364. declare module BABYLON {
  25365. /**
  25366. * Defines a runtime animation
  25367. */
  25368. export class RuntimeAnimation {
  25369. private _events;
  25370. /**
  25371. * The current frame of the runtime animation
  25372. */
  25373. private _currentFrame;
  25374. /**
  25375. * The animation used by the runtime animation
  25376. */
  25377. private _animation;
  25378. /**
  25379. * The target of the runtime animation
  25380. */
  25381. private _target;
  25382. /**
  25383. * The initiating animatable
  25384. */
  25385. private _host;
  25386. /**
  25387. * The original value of the runtime animation
  25388. */
  25389. private _originalValue;
  25390. /**
  25391. * The original blend value of the runtime animation
  25392. */
  25393. private _originalBlendValue;
  25394. /**
  25395. * The offsets cache of the runtime animation
  25396. */
  25397. private _offsetsCache;
  25398. /**
  25399. * The high limits cache of the runtime animation
  25400. */
  25401. private _highLimitsCache;
  25402. /**
  25403. * Specifies if the runtime animation has been stopped
  25404. */
  25405. private _stopped;
  25406. /**
  25407. * The blending factor of the runtime animation
  25408. */
  25409. private _blendingFactor;
  25410. /**
  25411. * The BabylonJS scene
  25412. */
  25413. private _scene;
  25414. /**
  25415. * The current value of the runtime animation
  25416. */
  25417. private _currentValue;
  25418. /** @hidden */
  25419. _animationState: _IAnimationState;
  25420. /**
  25421. * The active target of the runtime animation
  25422. */
  25423. private _activeTargets;
  25424. private _currentActiveTarget;
  25425. private _directTarget;
  25426. /**
  25427. * The target path of the runtime animation
  25428. */
  25429. private _targetPath;
  25430. /**
  25431. * The weight of the runtime animation
  25432. */
  25433. private _weight;
  25434. /**
  25435. * The ratio offset of the runtime animation
  25436. */
  25437. private _ratioOffset;
  25438. /**
  25439. * The previous delay of the runtime animation
  25440. */
  25441. private _previousDelay;
  25442. /**
  25443. * The previous ratio of the runtime animation
  25444. */
  25445. private _previousRatio;
  25446. private _enableBlending;
  25447. private _keys;
  25448. private _minFrame;
  25449. private _maxFrame;
  25450. private _minValue;
  25451. private _maxValue;
  25452. private _targetIsArray;
  25453. /**
  25454. * Gets the current frame of the runtime animation
  25455. */
  25456. get currentFrame(): number;
  25457. /**
  25458. * Gets the weight of the runtime animation
  25459. */
  25460. get weight(): number;
  25461. /**
  25462. * Gets the current value of the runtime animation
  25463. */
  25464. get currentValue(): any;
  25465. /**
  25466. * Gets the target path of the runtime animation
  25467. */
  25468. get targetPath(): string;
  25469. /**
  25470. * Gets the actual target of the runtime animation
  25471. */
  25472. get target(): any;
  25473. /**
  25474. * Gets the additive state of the runtime animation
  25475. */
  25476. get isAdditive(): boolean;
  25477. /** @hidden */
  25478. _onLoop: () => void;
  25479. /**
  25480. * Create a new RuntimeAnimation object
  25481. * @param target defines the target of the animation
  25482. * @param animation defines the source animation object
  25483. * @param scene defines the hosting scene
  25484. * @param host defines the initiating Animatable
  25485. */
  25486. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25487. private _preparePath;
  25488. /**
  25489. * Gets the animation from the runtime animation
  25490. */
  25491. get animation(): Animation;
  25492. /**
  25493. * Resets the runtime animation to the beginning
  25494. * @param restoreOriginal defines whether to restore the target property to the original value
  25495. */
  25496. reset(restoreOriginal?: boolean): void;
  25497. /**
  25498. * Specifies if the runtime animation is stopped
  25499. * @returns Boolean specifying if the runtime animation is stopped
  25500. */
  25501. isStopped(): boolean;
  25502. /**
  25503. * Disposes of the runtime animation
  25504. */
  25505. dispose(): void;
  25506. /**
  25507. * Apply the interpolated value to the target
  25508. * @param currentValue defines the value computed by the animation
  25509. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25510. */
  25511. setValue(currentValue: any, weight: number): void;
  25512. private _getOriginalValues;
  25513. private _setValue;
  25514. /**
  25515. * Gets the loop pmode of the runtime animation
  25516. * @returns Loop Mode
  25517. */
  25518. private _getCorrectLoopMode;
  25519. /**
  25520. * Move the current animation to a given frame
  25521. * @param frame defines the frame to move to
  25522. */
  25523. goToFrame(frame: number): void;
  25524. /**
  25525. * @hidden Internal use only
  25526. */
  25527. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25528. /**
  25529. * Execute the current animation
  25530. * @param delay defines the delay to add to the current frame
  25531. * @param from defines the lower bound of the animation range
  25532. * @param to defines the upper bound of the animation range
  25533. * @param loop defines if the current animation must loop
  25534. * @param speedRatio defines the current speed ratio
  25535. * @param weight defines the weight of the animation (default is -1 so no weight)
  25536. * @param onLoop optional callback called when animation loops
  25537. * @returns a boolean indicating if the animation is running
  25538. */
  25539. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25540. }
  25541. }
  25542. declare module BABYLON {
  25543. /**
  25544. * Class used to store an actual running animation
  25545. */
  25546. export class Animatable {
  25547. /** defines the target object */
  25548. target: any;
  25549. /** defines the starting frame number (default is 0) */
  25550. fromFrame: number;
  25551. /** defines the ending frame number (default is 100) */
  25552. toFrame: number;
  25553. /** defines if the animation must loop (default is false) */
  25554. loopAnimation: boolean;
  25555. /** defines a callback to call when animation ends if it is not looping */
  25556. onAnimationEnd?: (() => void) | null | undefined;
  25557. /** defines a callback to call when animation loops */
  25558. onAnimationLoop?: (() => void) | null | undefined;
  25559. /** defines whether the animation should be evaluated additively */
  25560. isAdditive: boolean;
  25561. private _localDelayOffset;
  25562. private _pausedDelay;
  25563. private _runtimeAnimations;
  25564. private _paused;
  25565. private _scene;
  25566. private _speedRatio;
  25567. private _weight;
  25568. private _syncRoot;
  25569. /**
  25570. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25571. * This will only apply for non looping animation (default is true)
  25572. */
  25573. disposeOnEnd: boolean;
  25574. /**
  25575. * Gets a boolean indicating if the animation has started
  25576. */
  25577. animationStarted: boolean;
  25578. /**
  25579. * Observer raised when the animation ends
  25580. */
  25581. onAnimationEndObservable: Observable<Animatable>;
  25582. /**
  25583. * Observer raised when the animation loops
  25584. */
  25585. onAnimationLoopObservable: Observable<Animatable>;
  25586. /**
  25587. * Gets the root Animatable used to synchronize and normalize animations
  25588. */
  25589. get syncRoot(): Nullable<Animatable>;
  25590. /**
  25591. * Gets the current frame of the first RuntimeAnimation
  25592. * Used to synchronize Animatables
  25593. */
  25594. get masterFrame(): number;
  25595. /**
  25596. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25597. */
  25598. get weight(): number;
  25599. set weight(value: number);
  25600. /**
  25601. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25602. */
  25603. get speedRatio(): number;
  25604. set speedRatio(value: number);
  25605. /**
  25606. * Creates a new Animatable
  25607. * @param scene defines the hosting scene
  25608. * @param target defines the target object
  25609. * @param fromFrame defines the starting frame number (default is 0)
  25610. * @param toFrame defines the ending frame number (default is 100)
  25611. * @param loopAnimation defines if the animation must loop (default is false)
  25612. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25613. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25614. * @param animations defines a group of animation to add to the new Animatable
  25615. * @param onAnimationLoop defines a callback to call when animation loops
  25616. * @param isAdditive defines whether the animation should be evaluated additively
  25617. */
  25618. constructor(scene: Scene,
  25619. /** defines the target object */
  25620. target: any,
  25621. /** defines the starting frame number (default is 0) */
  25622. fromFrame?: number,
  25623. /** defines the ending frame number (default is 100) */
  25624. toFrame?: number,
  25625. /** defines if the animation must loop (default is false) */
  25626. loopAnimation?: boolean, speedRatio?: number,
  25627. /** defines a callback to call when animation ends if it is not looping */
  25628. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25629. /** defines a callback to call when animation loops */
  25630. onAnimationLoop?: (() => void) | null | undefined,
  25631. /** defines whether the animation should be evaluated additively */
  25632. isAdditive?: boolean);
  25633. /**
  25634. * Synchronize and normalize current Animatable with a source Animatable
  25635. * This is useful when using animation weights and when animations are not of the same length
  25636. * @param root defines the root Animatable to synchronize with
  25637. * @returns the current Animatable
  25638. */
  25639. syncWith(root: Animatable): Animatable;
  25640. /**
  25641. * Gets the list of runtime animations
  25642. * @returns an array of RuntimeAnimation
  25643. */
  25644. getAnimations(): RuntimeAnimation[];
  25645. /**
  25646. * Adds more animations to the current animatable
  25647. * @param target defines the target of the animations
  25648. * @param animations defines the new animations to add
  25649. */
  25650. appendAnimations(target: any, animations: Animation[]): void;
  25651. /**
  25652. * Gets the source animation for a specific property
  25653. * @param property defines the propertyu to look for
  25654. * @returns null or the source animation for the given property
  25655. */
  25656. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25657. /**
  25658. * Gets the runtime animation for a specific property
  25659. * @param property defines the propertyu to look for
  25660. * @returns null or the runtime animation for the given property
  25661. */
  25662. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25663. /**
  25664. * Resets the animatable to its original state
  25665. */
  25666. reset(): void;
  25667. /**
  25668. * Allows the animatable to blend with current running animations
  25669. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25670. * @param blendingSpeed defines the blending speed to use
  25671. */
  25672. enableBlending(blendingSpeed: number): void;
  25673. /**
  25674. * Disable animation blending
  25675. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25676. */
  25677. disableBlending(): void;
  25678. /**
  25679. * Jump directly to a given frame
  25680. * @param frame defines the frame to jump to
  25681. */
  25682. goToFrame(frame: number): void;
  25683. /**
  25684. * Pause the animation
  25685. */
  25686. pause(): void;
  25687. /**
  25688. * Restart the animation
  25689. */
  25690. restart(): void;
  25691. private _raiseOnAnimationEnd;
  25692. /**
  25693. * Stop and delete the current animation
  25694. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25695. * @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)
  25696. */
  25697. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25698. /**
  25699. * Wait asynchronously for the animation to end
  25700. * @returns a promise which will be fullfilled when the animation ends
  25701. */
  25702. waitAsync(): Promise<Animatable>;
  25703. /** @hidden */
  25704. _animate(delay: number): boolean;
  25705. }
  25706. interface Scene {
  25707. /** @hidden */
  25708. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25709. /** @hidden */
  25710. _processLateAnimationBindingsForMatrices(holder: {
  25711. totalWeight: number;
  25712. totalAdditiveWeight: number;
  25713. animations: RuntimeAnimation[];
  25714. additiveAnimations: RuntimeAnimation[];
  25715. originalValue: Matrix;
  25716. }): any;
  25717. /** @hidden */
  25718. _processLateAnimationBindingsForQuaternions(holder: {
  25719. totalWeight: number;
  25720. totalAdditiveWeight: number;
  25721. animations: RuntimeAnimation[];
  25722. additiveAnimations: RuntimeAnimation[];
  25723. originalValue: Quaternion;
  25724. }, refQuaternion: Quaternion): Quaternion;
  25725. /** @hidden */
  25726. _processLateAnimationBindings(): void;
  25727. /**
  25728. * Will start the animation sequence of a given target
  25729. * @param target defines the target
  25730. * @param from defines from which frame should animation start
  25731. * @param to defines until which frame should animation run.
  25732. * @param weight defines the weight to apply to the animation (1.0 by default)
  25733. * @param loop defines if the animation loops
  25734. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25735. * @param onAnimationEnd defines the function to be executed when the animation ends
  25736. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25737. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25738. * @param onAnimationLoop defines the callback to call when an animation loops
  25739. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25740. * @returns the animatable object created for this animation
  25741. */
  25742. 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;
  25743. /**
  25744. * Will start the animation sequence of a given target
  25745. * @param target defines the target
  25746. * @param from defines from which frame should animation start
  25747. * @param to defines until which frame should animation run.
  25748. * @param loop defines if the animation loops
  25749. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25750. * @param onAnimationEnd defines the function to be executed when the animation ends
  25751. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25752. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25753. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25754. * @param onAnimationLoop defines the callback to call when an animation loops
  25755. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25756. * @returns the animatable object created for this animation
  25757. */
  25758. 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;
  25759. /**
  25760. * Will start the animation sequence of a given target and its hierarchy
  25761. * @param target defines the target
  25762. * @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.
  25763. * @param from defines from which frame should animation start
  25764. * @param to defines until which frame should animation run.
  25765. * @param loop defines if the animation loops
  25766. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25767. * @param onAnimationEnd defines the function to be executed when the animation ends
  25768. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25769. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25770. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25771. * @param onAnimationLoop defines the callback to call when an animation loops
  25772. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25773. * @returns the list of created animatables
  25774. */
  25775. 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[];
  25776. /**
  25777. * Begin a new animation on a given node
  25778. * @param target defines the target where the animation will take place
  25779. * @param animations defines the list of animations to start
  25780. * @param from defines the initial value
  25781. * @param to defines the final value
  25782. * @param loop defines if you want animation to loop (off by default)
  25783. * @param speedRatio defines the speed ratio to apply to all animations
  25784. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25785. * @param onAnimationLoop defines the callback to call when an animation loops
  25786. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25787. * @returns the list of created animatables
  25788. */
  25789. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25790. /**
  25791. * Begin a new animation on a given node and its hierarchy
  25792. * @param target defines the root node where the animation will take place
  25793. * @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.
  25794. * @param animations defines the list of animations to start
  25795. * @param from defines the initial value
  25796. * @param to defines the final value
  25797. * @param loop defines if you want animation to loop (off by default)
  25798. * @param speedRatio defines the speed ratio to apply to all animations
  25799. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25800. * @param onAnimationLoop defines the callback to call when an animation loops
  25801. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25802. * @returns the list of animatables created for all nodes
  25803. */
  25804. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25805. /**
  25806. * Gets the animatable associated with a specific target
  25807. * @param target defines the target of the animatable
  25808. * @returns the required animatable if found
  25809. */
  25810. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25811. /**
  25812. * Gets all animatables associated with a given target
  25813. * @param target defines the target to look animatables for
  25814. * @returns an array of Animatables
  25815. */
  25816. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25817. /**
  25818. * Stops and removes all animations that have been applied to the scene
  25819. */
  25820. stopAllAnimations(): void;
  25821. /**
  25822. * Gets the current delta time used by animation engine
  25823. */
  25824. deltaTime: number;
  25825. }
  25826. interface Bone {
  25827. /**
  25828. * Copy an animation range from another bone
  25829. * @param source defines the source bone
  25830. * @param rangeName defines the range name to copy
  25831. * @param frameOffset defines the frame offset
  25832. * @param rescaleAsRequired defines if rescaling must be applied if required
  25833. * @param skelDimensionsRatio defines the scaling ratio
  25834. * @returns true if operation was successful
  25835. */
  25836. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25837. }
  25838. }
  25839. declare module BABYLON {
  25840. /**
  25841. * Class used to override all child animations of a given target
  25842. */
  25843. export class AnimationPropertiesOverride {
  25844. /**
  25845. * Gets or sets a value indicating if animation blending must be used
  25846. */
  25847. enableBlending: boolean;
  25848. /**
  25849. * Gets or sets the blending speed to use when enableBlending is true
  25850. */
  25851. blendingSpeed: number;
  25852. /**
  25853. * Gets or sets the default loop mode to use
  25854. */
  25855. loopMode: number;
  25856. }
  25857. }
  25858. declare module BABYLON {
  25859. /**
  25860. * Class used to handle skinning animations
  25861. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25862. */
  25863. export class Skeleton implements IAnimatable {
  25864. /** defines the skeleton name */
  25865. name: string;
  25866. /** defines the skeleton Id */
  25867. id: string;
  25868. /**
  25869. * Defines the list of child bones
  25870. */
  25871. bones: Bone[];
  25872. /**
  25873. * Defines an estimate of the dimension of the skeleton at rest
  25874. */
  25875. dimensionsAtRest: Vector3;
  25876. /**
  25877. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25878. */
  25879. needInitialSkinMatrix: boolean;
  25880. /**
  25881. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25882. */
  25883. overrideMesh: Nullable<AbstractMesh>;
  25884. /**
  25885. * Gets the list of animations attached to this skeleton
  25886. */
  25887. animations: Array<Animation>;
  25888. private _scene;
  25889. private _isDirty;
  25890. private _transformMatrices;
  25891. private _transformMatrixTexture;
  25892. private _meshesWithPoseMatrix;
  25893. private _animatables;
  25894. private _identity;
  25895. private _synchronizedWithMesh;
  25896. private _ranges;
  25897. private _lastAbsoluteTransformsUpdateId;
  25898. private _canUseTextureForBones;
  25899. private _uniqueId;
  25900. /** @hidden */
  25901. _numBonesWithLinkedTransformNode: number;
  25902. /** @hidden */
  25903. _hasWaitingData: Nullable<boolean>;
  25904. /** @hidden */
  25905. _waitingOverrideMeshId: Nullable<string>;
  25906. /**
  25907. * Specifies if the skeleton should be serialized
  25908. */
  25909. doNotSerialize: boolean;
  25910. private _useTextureToStoreBoneMatrices;
  25911. /**
  25912. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25913. * Please note that this option is not available if the hardware does not support it
  25914. */
  25915. get useTextureToStoreBoneMatrices(): boolean;
  25916. set useTextureToStoreBoneMatrices(value: boolean);
  25917. private _animationPropertiesOverride;
  25918. /**
  25919. * Gets or sets the animation properties override
  25920. */
  25921. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25922. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25923. /**
  25924. * List of inspectable custom properties (used by the Inspector)
  25925. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25926. */
  25927. inspectableCustomProperties: IInspectable[];
  25928. /**
  25929. * An observable triggered before computing the skeleton's matrices
  25930. */
  25931. onBeforeComputeObservable: Observable<Skeleton>;
  25932. /**
  25933. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25934. */
  25935. get isUsingTextureForMatrices(): boolean;
  25936. /**
  25937. * Gets the unique ID of this skeleton
  25938. */
  25939. get uniqueId(): number;
  25940. /**
  25941. * Creates a new skeleton
  25942. * @param name defines the skeleton name
  25943. * @param id defines the skeleton Id
  25944. * @param scene defines the hosting scene
  25945. */
  25946. constructor(
  25947. /** defines the skeleton name */
  25948. name: string,
  25949. /** defines the skeleton Id */
  25950. id: string, scene: Scene);
  25951. /**
  25952. * Gets the current object class name.
  25953. * @return the class name
  25954. */
  25955. getClassName(): string;
  25956. /**
  25957. * Returns an array containing the root bones
  25958. * @returns an array containing the root bones
  25959. */
  25960. getChildren(): Array<Bone>;
  25961. /**
  25962. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25963. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25964. * @returns a Float32Array containing matrices data
  25965. */
  25966. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25967. /**
  25968. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25969. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25970. * @returns a raw texture containing the data
  25971. */
  25972. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25973. /**
  25974. * Gets the current hosting scene
  25975. * @returns a scene object
  25976. */
  25977. getScene(): Scene;
  25978. /**
  25979. * Gets a string representing the current skeleton data
  25980. * @param fullDetails defines a boolean indicating if we want a verbose version
  25981. * @returns a string representing the current skeleton data
  25982. */
  25983. toString(fullDetails?: boolean): string;
  25984. /**
  25985. * Get bone's index searching by name
  25986. * @param name defines bone's name to search for
  25987. * @return the indice of the bone. Returns -1 if not found
  25988. */
  25989. getBoneIndexByName(name: string): number;
  25990. /**
  25991. * Creater a new animation range
  25992. * @param name defines the name of the range
  25993. * @param from defines the start key
  25994. * @param to defines the end key
  25995. */
  25996. createAnimationRange(name: string, from: number, to: number): void;
  25997. /**
  25998. * Delete a specific animation range
  25999. * @param name defines the name of the range
  26000. * @param deleteFrames defines if frames must be removed as well
  26001. */
  26002. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26003. /**
  26004. * Gets a specific animation range
  26005. * @param name defines the name of the range to look for
  26006. * @returns the requested animation range or null if not found
  26007. */
  26008. getAnimationRange(name: string): Nullable<AnimationRange>;
  26009. /**
  26010. * Gets the list of all animation ranges defined on this skeleton
  26011. * @returns an array
  26012. */
  26013. getAnimationRanges(): Nullable<AnimationRange>[];
  26014. /**
  26015. * Copy animation range from a source skeleton.
  26016. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26017. * @param source defines the source skeleton
  26018. * @param name defines the name of the range to copy
  26019. * @param rescaleAsRequired defines if rescaling must be applied if required
  26020. * @returns true if operation was successful
  26021. */
  26022. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26023. /**
  26024. * Forces the skeleton to go to rest pose
  26025. */
  26026. returnToRest(): void;
  26027. private _getHighestAnimationFrame;
  26028. /**
  26029. * Begin a specific animation range
  26030. * @param name defines the name of the range to start
  26031. * @param loop defines if looping must be turned on (false by default)
  26032. * @param speedRatio defines the speed ratio to apply (1 by default)
  26033. * @param onAnimationEnd defines a callback which will be called when animation will end
  26034. * @returns a new animatable
  26035. */
  26036. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26037. /**
  26038. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26039. * @param skeleton defines the Skeleton containing the animation range to convert
  26040. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26041. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26042. * @returns the original skeleton
  26043. */
  26044. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26045. /** @hidden */
  26046. _markAsDirty(): void;
  26047. /** @hidden */
  26048. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26049. /** @hidden */
  26050. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26051. private _computeTransformMatrices;
  26052. /**
  26053. * Build all resources required to render a skeleton
  26054. */
  26055. prepare(): void;
  26056. /**
  26057. * Gets the list of animatables currently running for this skeleton
  26058. * @returns an array of animatables
  26059. */
  26060. getAnimatables(): IAnimatable[];
  26061. /**
  26062. * Clone the current skeleton
  26063. * @param name defines the name of the new skeleton
  26064. * @param id defines the id of the new skeleton
  26065. * @returns the new skeleton
  26066. */
  26067. clone(name: string, id?: string): Skeleton;
  26068. /**
  26069. * Enable animation blending for this skeleton
  26070. * @param blendingSpeed defines the blending speed to apply
  26071. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26072. */
  26073. enableBlending(blendingSpeed?: number): void;
  26074. /**
  26075. * Releases all resources associated with the current skeleton
  26076. */
  26077. dispose(): void;
  26078. /**
  26079. * Serialize the skeleton in a JSON object
  26080. * @returns a JSON object
  26081. */
  26082. serialize(): any;
  26083. /**
  26084. * Creates a new skeleton from serialized data
  26085. * @param parsedSkeleton defines the serialized data
  26086. * @param scene defines the hosting scene
  26087. * @returns a new skeleton
  26088. */
  26089. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26090. /**
  26091. * Compute all node absolute transforms
  26092. * @param forceUpdate defines if computation must be done even if cache is up to date
  26093. */
  26094. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26095. /**
  26096. * Gets the root pose matrix
  26097. * @returns a matrix
  26098. */
  26099. getPoseMatrix(): Nullable<Matrix>;
  26100. /**
  26101. * Sorts bones per internal index
  26102. */
  26103. sortBones(): void;
  26104. private _sortBones;
  26105. /**
  26106. * Set the current local matrix as the restPose for all bones in the skeleton.
  26107. */
  26108. setCurrentPoseAsRest(): void;
  26109. }
  26110. }
  26111. declare module BABYLON {
  26112. /**
  26113. * Class used to store bone information
  26114. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26115. */
  26116. export class Bone extends Node {
  26117. /**
  26118. * defines the bone name
  26119. */
  26120. name: string;
  26121. private static _tmpVecs;
  26122. private static _tmpQuat;
  26123. private static _tmpMats;
  26124. /**
  26125. * Gets the list of child bones
  26126. */
  26127. children: Bone[];
  26128. /** Gets the animations associated with this bone */
  26129. animations: Animation[];
  26130. /**
  26131. * Gets or sets bone length
  26132. */
  26133. length: number;
  26134. /**
  26135. * @hidden Internal only
  26136. * Set this value to map this bone to a different index in the transform matrices
  26137. * Set this value to -1 to exclude the bone from the transform matrices
  26138. */
  26139. _index: Nullable<number>;
  26140. private _skeleton;
  26141. private _localMatrix;
  26142. private _restPose;
  26143. private _bindPose;
  26144. private _baseMatrix;
  26145. private _absoluteTransform;
  26146. private _invertedAbsoluteTransform;
  26147. private _parent;
  26148. private _scalingDeterminant;
  26149. private _worldTransform;
  26150. private _localScaling;
  26151. private _localRotation;
  26152. private _localPosition;
  26153. private _needToDecompose;
  26154. private _needToCompose;
  26155. /** @hidden */
  26156. _linkedTransformNode: Nullable<TransformNode>;
  26157. /** @hidden */
  26158. _waitingTransformNodeId: Nullable<string>;
  26159. /** @hidden */
  26160. get _matrix(): Matrix;
  26161. /** @hidden */
  26162. set _matrix(value: Matrix);
  26163. /**
  26164. * Create a new bone
  26165. * @param name defines the bone name
  26166. * @param skeleton defines the parent skeleton
  26167. * @param parentBone defines the parent (can be null if the bone is the root)
  26168. * @param localMatrix defines the local matrix
  26169. * @param restPose defines the rest pose matrix
  26170. * @param baseMatrix defines the base matrix
  26171. * @param index defines index of the bone in the hiearchy
  26172. */
  26173. constructor(
  26174. /**
  26175. * defines the bone name
  26176. */
  26177. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26178. /**
  26179. * Gets the current object class name.
  26180. * @return the class name
  26181. */
  26182. getClassName(): string;
  26183. /**
  26184. * Gets the parent skeleton
  26185. * @returns a skeleton
  26186. */
  26187. getSkeleton(): Skeleton;
  26188. /**
  26189. * Gets parent bone
  26190. * @returns a bone or null if the bone is the root of the bone hierarchy
  26191. */
  26192. getParent(): Nullable<Bone>;
  26193. /**
  26194. * Returns an array containing the root bones
  26195. * @returns an array containing the root bones
  26196. */
  26197. getChildren(): Array<Bone>;
  26198. /**
  26199. * Gets the node index in matrix array generated for rendering
  26200. * @returns the node index
  26201. */
  26202. getIndex(): number;
  26203. /**
  26204. * Sets the parent bone
  26205. * @param parent defines the parent (can be null if the bone is the root)
  26206. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26207. */
  26208. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26209. /**
  26210. * Gets the local matrix
  26211. * @returns a matrix
  26212. */
  26213. getLocalMatrix(): Matrix;
  26214. /**
  26215. * Gets the base matrix (initial matrix which remains unchanged)
  26216. * @returns a matrix
  26217. */
  26218. getBaseMatrix(): Matrix;
  26219. /**
  26220. * Gets the rest pose matrix
  26221. * @returns a matrix
  26222. */
  26223. getRestPose(): Matrix;
  26224. /**
  26225. * Sets the rest pose matrix
  26226. * @param matrix the local-space rest pose to set for this bone
  26227. */
  26228. setRestPose(matrix: Matrix): void;
  26229. /**
  26230. * Gets the bind pose matrix
  26231. * @returns the bind pose matrix
  26232. */
  26233. getBindPose(): Matrix;
  26234. /**
  26235. * Sets the bind pose matrix
  26236. * @param matrix the local-space bind pose to set for this bone
  26237. */
  26238. setBindPose(matrix: Matrix): void;
  26239. /**
  26240. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26241. */
  26242. getWorldMatrix(): Matrix;
  26243. /**
  26244. * Sets the local matrix to rest pose matrix
  26245. */
  26246. returnToRest(): void;
  26247. /**
  26248. * Gets the inverse of the absolute transform matrix.
  26249. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26250. * @returns a matrix
  26251. */
  26252. getInvertedAbsoluteTransform(): Matrix;
  26253. /**
  26254. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26255. * @returns a matrix
  26256. */
  26257. getAbsoluteTransform(): Matrix;
  26258. /**
  26259. * Links with the given transform node.
  26260. * The local matrix of this bone is copied from the transform node every frame.
  26261. * @param transformNode defines the transform node to link to
  26262. */
  26263. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26264. /**
  26265. * Gets the node used to drive the bone's transformation
  26266. * @returns a transform node or null
  26267. */
  26268. getTransformNode(): Nullable<TransformNode>;
  26269. /** Gets or sets current position (in local space) */
  26270. get position(): Vector3;
  26271. set position(newPosition: Vector3);
  26272. /** Gets or sets current rotation (in local space) */
  26273. get rotation(): Vector3;
  26274. set rotation(newRotation: Vector3);
  26275. /** Gets or sets current rotation quaternion (in local space) */
  26276. get rotationQuaternion(): Quaternion;
  26277. set rotationQuaternion(newRotation: Quaternion);
  26278. /** Gets or sets current scaling (in local space) */
  26279. get scaling(): Vector3;
  26280. set scaling(newScaling: Vector3);
  26281. /**
  26282. * Gets the animation properties override
  26283. */
  26284. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26285. private _decompose;
  26286. private _compose;
  26287. /**
  26288. * Update the base and local matrices
  26289. * @param matrix defines the new base or local matrix
  26290. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26291. * @param updateLocalMatrix defines if the local matrix should be updated
  26292. */
  26293. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26294. /** @hidden */
  26295. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26296. /**
  26297. * Flag the bone as dirty (Forcing it to update everything)
  26298. */
  26299. markAsDirty(): void;
  26300. /** @hidden */
  26301. _markAsDirtyAndCompose(): void;
  26302. private _markAsDirtyAndDecompose;
  26303. /**
  26304. * Translate the bone in local or world space
  26305. * @param vec The amount to translate the bone
  26306. * @param space The space that the translation is in
  26307. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26308. */
  26309. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26310. /**
  26311. * Set the postion of the bone in local or world space
  26312. * @param position The position to set the bone
  26313. * @param space The space that the position is in
  26314. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26315. */
  26316. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26317. /**
  26318. * Set the absolute position of the bone (world space)
  26319. * @param position The position to set the bone
  26320. * @param mesh The mesh that this bone is attached to
  26321. */
  26322. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26323. /**
  26324. * Scale the bone on the x, y and z axes (in local space)
  26325. * @param x The amount to scale the bone on the x axis
  26326. * @param y The amount to scale the bone on the y axis
  26327. * @param z The amount to scale the bone on the z axis
  26328. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26329. */
  26330. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26331. /**
  26332. * Set the bone scaling in local space
  26333. * @param scale defines the scaling vector
  26334. */
  26335. setScale(scale: Vector3): void;
  26336. /**
  26337. * Gets the current scaling in local space
  26338. * @returns the current scaling vector
  26339. */
  26340. getScale(): Vector3;
  26341. /**
  26342. * Gets the current scaling in local space and stores it in a target vector
  26343. * @param result defines the target vector
  26344. */
  26345. getScaleToRef(result: Vector3): void;
  26346. /**
  26347. * Set the yaw, pitch, and roll of the bone in local or world space
  26348. * @param yaw The rotation of the bone on the y axis
  26349. * @param pitch The rotation of the bone on the x axis
  26350. * @param roll The rotation of the bone on the z axis
  26351. * @param space The space that the axes of rotation are in
  26352. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26353. */
  26354. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26355. /**
  26356. * Add a rotation to the bone on an axis in local or world space
  26357. * @param axis The axis to rotate the bone on
  26358. * @param amount The amount to rotate the bone
  26359. * @param space The space that the axis is in
  26360. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26361. */
  26362. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26363. /**
  26364. * Set the rotation of the bone to a particular axis angle in local or world space
  26365. * @param axis The axis to rotate the bone on
  26366. * @param angle The angle that the bone should be rotated to
  26367. * @param space The space that the axis is in
  26368. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26369. */
  26370. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26371. /**
  26372. * Set the euler rotation of the bone in local or world space
  26373. * @param rotation The euler rotation that the bone should be set to
  26374. * @param space The space that the rotation is in
  26375. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26376. */
  26377. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26378. /**
  26379. * Set the quaternion rotation of the bone in local or world space
  26380. * @param quat The quaternion rotation that the bone should be set to
  26381. * @param space The space that the rotation is in
  26382. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26383. */
  26384. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26385. /**
  26386. * Set the rotation matrix of the bone in local or world space
  26387. * @param rotMat The rotation matrix that the bone should be set to
  26388. * @param space The space that the rotation is in
  26389. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26390. */
  26391. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26392. private _rotateWithMatrix;
  26393. private _getNegativeRotationToRef;
  26394. /**
  26395. * Get the position of the bone in local or world space
  26396. * @param space The space that the returned position is in
  26397. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26398. * @returns The position of the bone
  26399. */
  26400. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26401. /**
  26402. * Copy the position of the bone to a vector3 in local or world space
  26403. * @param space The space that the returned position is in
  26404. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26405. * @param result The vector3 to copy the position to
  26406. */
  26407. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26408. /**
  26409. * Get the absolute position of the bone (world space)
  26410. * @param mesh The mesh that this bone is attached to
  26411. * @returns The absolute position of the bone
  26412. */
  26413. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26414. /**
  26415. * Copy the absolute position of the bone (world space) to the result param
  26416. * @param mesh The mesh that this bone is attached to
  26417. * @param result The vector3 to copy the absolute position to
  26418. */
  26419. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26420. /**
  26421. * Compute the absolute transforms of this bone and its children
  26422. */
  26423. computeAbsoluteTransforms(): void;
  26424. /**
  26425. * Get the world direction from an axis that is in the local space of the bone
  26426. * @param localAxis The local direction that is used to compute the world direction
  26427. * @param mesh The mesh that this bone is attached to
  26428. * @returns The world direction
  26429. */
  26430. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26431. /**
  26432. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26433. * @param localAxis The local direction that is used to compute the world direction
  26434. * @param mesh The mesh that this bone is attached to
  26435. * @param result The vector3 that the world direction will be copied to
  26436. */
  26437. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26438. /**
  26439. * Get the euler rotation of the bone in local or world space
  26440. * @param space The space that the rotation should be in
  26441. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26442. * @returns The euler rotation
  26443. */
  26444. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26445. /**
  26446. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26447. * @param space The space that the rotation should be in
  26448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26449. * @param result The vector3 that the rotation should be copied to
  26450. */
  26451. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26452. /**
  26453. * Get the quaternion rotation of the bone in either local or world space
  26454. * @param space The space that the rotation should be in
  26455. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26456. * @returns The quaternion rotation
  26457. */
  26458. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26459. /**
  26460. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26461. * @param space The space that the rotation should be in
  26462. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26463. * @param result The quaternion that the rotation should be copied to
  26464. */
  26465. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26466. /**
  26467. * Get the rotation matrix of the bone in local or world space
  26468. * @param space The space that the rotation should be in
  26469. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26470. * @returns The rotation matrix
  26471. */
  26472. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26473. /**
  26474. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26475. * @param space The space that the rotation should be in
  26476. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26477. * @param result The quaternion that the rotation should be copied to
  26478. */
  26479. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26480. /**
  26481. * Get the world position of a point that is in the local space of the bone
  26482. * @param position The local position
  26483. * @param mesh The mesh that this bone is attached to
  26484. * @returns The world position
  26485. */
  26486. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26487. /**
  26488. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26489. * @param position The local position
  26490. * @param mesh The mesh that this bone is attached to
  26491. * @param result The vector3 that the world position should be copied to
  26492. */
  26493. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26494. /**
  26495. * Get the local position of a point that is in world space
  26496. * @param position The world position
  26497. * @param mesh The mesh that this bone is attached to
  26498. * @returns The local position
  26499. */
  26500. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26501. /**
  26502. * Get the local position of a point that is in world space and copy it to the result param
  26503. * @param position The world position
  26504. * @param mesh The mesh that this bone is attached to
  26505. * @param result The vector3 that the local position should be copied to
  26506. */
  26507. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26508. /**
  26509. * Set the current local matrix as the restPose for this bone.
  26510. */
  26511. setCurrentPoseAsRest(): void;
  26512. }
  26513. }
  26514. declare module BABYLON {
  26515. /**
  26516. * 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.
  26517. * @see https://doc.babylonjs.com/how_to/transformnode
  26518. */
  26519. export class TransformNode extends Node {
  26520. /**
  26521. * Object will not rotate to face the camera
  26522. */
  26523. static BILLBOARDMODE_NONE: number;
  26524. /**
  26525. * Object will rotate to face the camera but only on the x axis
  26526. */
  26527. static BILLBOARDMODE_X: number;
  26528. /**
  26529. * Object will rotate to face the camera but only on the y axis
  26530. */
  26531. static BILLBOARDMODE_Y: number;
  26532. /**
  26533. * Object will rotate to face the camera but only on the z axis
  26534. */
  26535. static BILLBOARDMODE_Z: number;
  26536. /**
  26537. * Object will rotate to face the camera
  26538. */
  26539. static BILLBOARDMODE_ALL: number;
  26540. /**
  26541. * Object will rotate to face the camera's position instead of orientation
  26542. */
  26543. static BILLBOARDMODE_USE_POSITION: number;
  26544. private static _TmpRotation;
  26545. private static _TmpScaling;
  26546. private static _TmpTranslation;
  26547. private _forward;
  26548. private _forwardInverted;
  26549. private _up;
  26550. private _right;
  26551. private _rightInverted;
  26552. private _position;
  26553. private _rotation;
  26554. private _rotationQuaternion;
  26555. protected _scaling: Vector3;
  26556. protected _isDirty: boolean;
  26557. private _transformToBoneReferal;
  26558. private _isAbsoluteSynced;
  26559. private _billboardMode;
  26560. /**
  26561. * Gets or sets the billboard mode. Default is 0.
  26562. *
  26563. * | Value | Type | Description |
  26564. * | --- | --- | --- |
  26565. * | 0 | BILLBOARDMODE_NONE | |
  26566. * | 1 | BILLBOARDMODE_X | |
  26567. * | 2 | BILLBOARDMODE_Y | |
  26568. * | 4 | BILLBOARDMODE_Z | |
  26569. * | 7 | BILLBOARDMODE_ALL | |
  26570. *
  26571. */
  26572. get billboardMode(): number;
  26573. set billboardMode(value: number);
  26574. private _preserveParentRotationForBillboard;
  26575. /**
  26576. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26577. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26578. */
  26579. get preserveParentRotationForBillboard(): boolean;
  26580. set preserveParentRotationForBillboard(value: boolean);
  26581. /**
  26582. * 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
  26583. */
  26584. scalingDeterminant: number;
  26585. private _infiniteDistance;
  26586. /**
  26587. * Gets or sets the distance of the object to max, often used by skybox
  26588. */
  26589. get infiniteDistance(): boolean;
  26590. set infiniteDistance(value: boolean);
  26591. /**
  26592. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26593. * By default the system will update normals to compensate
  26594. */
  26595. ignoreNonUniformScaling: boolean;
  26596. /**
  26597. * 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
  26598. */
  26599. reIntegrateRotationIntoRotationQuaternion: boolean;
  26600. /** @hidden */
  26601. _poseMatrix: Nullable<Matrix>;
  26602. /** @hidden */
  26603. _localMatrix: Matrix;
  26604. private _usePivotMatrix;
  26605. private _absolutePosition;
  26606. private _absoluteScaling;
  26607. private _absoluteRotationQuaternion;
  26608. private _pivotMatrix;
  26609. private _pivotMatrixInverse;
  26610. /** @hidden */
  26611. _postMultiplyPivotMatrix: boolean;
  26612. protected _isWorldMatrixFrozen: boolean;
  26613. /** @hidden */
  26614. _indexInSceneTransformNodesArray: number;
  26615. /**
  26616. * An event triggered after the world matrix is updated
  26617. */
  26618. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26619. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26620. /**
  26621. * Gets a string identifying the name of the class
  26622. * @returns "TransformNode" string
  26623. */
  26624. getClassName(): string;
  26625. /**
  26626. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26627. */
  26628. get position(): Vector3;
  26629. set position(newPosition: Vector3);
  26630. /**
  26631. * 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)).
  26632. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26633. */
  26634. get rotation(): Vector3;
  26635. set rotation(newRotation: Vector3);
  26636. /**
  26637. * 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)).
  26638. */
  26639. get scaling(): Vector3;
  26640. set scaling(newScaling: Vector3);
  26641. /**
  26642. * 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).
  26643. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26644. */
  26645. get rotationQuaternion(): Nullable<Quaternion>;
  26646. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26647. /**
  26648. * The forward direction of that transform in world space.
  26649. */
  26650. get forward(): Vector3;
  26651. /**
  26652. * The up direction of that transform in world space.
  26653. */
  26654. get up(): Vector3;
  26655. /**
  26656. * The right direction of that transform in world space.
  26657. */
  26658. get right(): Vector3;
  26659. /**
  26660. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26661. * @param matrix the matrix to copy the pose from
  26662. * @returns this TransformNode.
  26663. */
  26664. updatePoseMatrix(matrix: Matrix): TransformNode;
  26665. /**
  26666. * Returns the mesh Pose matrix.
  26667. * @returns the pose matrix
  26668. */
  26669. getPoseMatrix(): Matrix;
  26670. /** @hidden */
  26671. _isSynchronized(): boolean;
  26672. /** @hidden */
  26673. _initCache(): void;
  26674. /**
  26675. * Flag the transform node as dirty (Forcing it to update everything)
  26676. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26677. * @returns this transform node
  26678. */
  26679. markAsDirty(property: string): TransformNode;
  26680. /**
  26681. * Returns the current mesh absolute position.
  26682. * Returns a Vector3.
  26683. */
  26684. get absolutePosition(): Vector3;
  26685. /**
  26686. * Returns the current mesh absolute scaling.
  26687. * Returns a Vector3.
  26688. */
  26689. get absoluteScaling(): Vector3;
  26690. /**
  26691. * Returns the current mesh absolute rotation.
  26692. * Returns a Quaternion.
  26693. */
  26694. get absoluteRotationQuaternion(): Quaternion;
  26695. /**
  26696. * Sets a new matrix to apply before all other transformation
  26697. * @param matrix defines the transform matrix
  26698. * @returns the current TransformNode
  26699. */
  26700. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26701. /**
  26702. * Sets a new pivot matrix to the current node
  26703. * @param matrix defines the new pivot matrix to use
  26704. * @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
  26705. * @returns the current TransformNode
  26706. */
  26707. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26708. /**
  26709. * Returns the mesh pivot matrix.
  26710. * Default : Identity.
  26711. * @returns the matrix
  26712. */
  26713. getPivotMatrix(): Matrix;
  26714. /**
  26715. * Instantiate (when possible) or clone that node with its hierarchy
  26716. * @param newParent defines the new parent to use for the instance (or clone)
  26717. * @param options defines options to configure how copy is done
  26718. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26719. * @returns an instance (or a clone) of the current node with its hiearchy
  26720. */
  26721. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26722. doNotInstantiate: boolean;
  26723. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26724. /**
  26725. * Prevents the World matrix to be computed any longer
  26726. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26727. * @returns the TransformNode.
  26728. */
  26729. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26730. /**
  26731. * Allows back the World matrix computation.
  26732. * @returns the TransformNode.
  26733. */
  26734. unfreezeWorldMatrix(): this;
  26735. /**
  26736. * True if the World matrix has been frozen.
  26737. */
  26738. get isWorldMatrixFrozen(): boolean;
  26739. /**
  26740. * Retuns the mesh absolute position in the World.
  26741. * @returns a Vector3.
  26742. */
  26743. getAbsolutePosition(): Vector3;
  26744. /**
  26745. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26746. * @param absolutePosition the absolute position to set
  26747. * @returns the TransformNode.
  26748. */
  26749. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26750. /**
  26751. * Sets the mesh position in its local space.
  26752. * @param vector3 the position to set in localspace
  26753. * @returns the TransformNode.
  26754. */
  26755. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26756. /**
  26757. * Returns the mesh position in the local space from the current World matrix values.
  26758. * @returns a new Vector3.
  26759. */
  26760. getPositionExpressedInLocalSpace(): Vector3;
  26761. /**
  26762. * Translates the mesh along the passed Vector3 in its local space.
  26763. * @param vector3 the distance to translate in localspace
  26764. * @returns the TransformNode.
  26765. */
  26766. locallyTranslate(vector3: Vector3): TransformNode;
  26767. private static _lookAtVectorCache;
  26768. /**
  26769. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26770. * @param targetPoint the position (must be in same space as current mesh) to look at
  26771. * @param yawCor optional yaw (y-axis) correction in radians
  26772. * @param pitchCor optional pitch (x-axis) correction in radians
  26773. * @param rollCor optional roll (z-axis) correction in radians
  26774. * @param space the choosen space of the target
  26775. * @returns the TransformNode.
  26776. */
  26777. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26778. /**
  26779. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26780. * This Vector3 is expressed in the World space.
  26781. * @param localAxis axis to rotate
  26782. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26783. */
  26784. getDirection(localAxis: Vector3): Vector3;
  26785. /**
  26786. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26787. * localAxis is expressed in the mesh local space.
  26788. * result is computed in the Wordl space from the mesh World matrix.
  26789. * @param localAxis axis to rotate
  26790. * @param result the resulting transformnode
  26791. * @returns this TransformNode.
  26792. */
  26793. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26794. /**
  26795. * Sets this transform node rotation to the given local axis.
  26796. * @param localAxis the axis in local space
  26797. * @param yawCor optional yaw (y-axis) correction in radians
  26798. * @param pitchCor optional pitch (x-axis) correction in radians
  26799. * @param rollCor optional roll (z-axis) correction in radians
  26800. * @returns this TransformNode
  26801. */
  26802. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26803. /**
  26804. * Sets a new pivot point to the current node
  26805. * @param point defines the new pivot point to use
  26806. * @param space defines if the point is in world or local space (local by default)
  26807. * @returns the current TransformNode
  26808. */
  26809. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26810. /**
  26811. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26812. * @returns the pivot point
  26813. */
  26814. getPivotPoint(): Vector3;
  26815. /**
  26816. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26817. * @param result the vector3 to store the result
  26818. * @returns this TransformNode.
  26819. */
  26820. getPivotPointToRef(result: Vector3): TransformNode;
  26821. /**
  26822. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26823. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26824. */
  26825. getAbsolutePivotPoint(): Vector3;
  26826. /**
  26827. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26828. * @param result vector3 to store the result
  26829. * @returns this TransformNode.
  26830. */
  26831. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26832. /**
  26833. * Defines the passed node as the parent of the current node.
  26834. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26835. * @see https://doc.babylonjs.com/how_to/parenting
  26836. * @param node the node ot set as the parent
  26837. * @returns this TransformNode.
  26838. */
  26839. setParent(node: Nullable<Node>): TransformNode;
  26840. private _nonUniformScaling;
  26841. /**
  26842. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26843. */
  26844. get nonUniformScaling(): boolean;
  26845. /** @hidden */
  26846. _updateNonUniformScalingState(value: boolean): boolean;
  26847. /**
  26848. * Attach the current TransformNode to another TransformNode associated with a bone
  26849. * @param bone Bone affecting the TransformNode
  26850. * @param affectedTransformNode TransformNode associated with the bone
  26851. * @returns this object
  26852. */
  26853. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26854. /**
  26855. * Detach the transform node if its associated with a bone
  26856. * @returns this object
  26857. */
  26858. detachFromBone(): TransformNode;
  26859. private static _rotationAxisCache;
  26860. /**
  26861. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26862. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26863. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26864. * The passed axis is also normalized.
  26865. * @param axis the axis to rotate around
  26866. * @param amount the amount to rotate in radians
  26867. * @param space Space to rotate in (Default: local)
  26868. * @returns the TransformNode.
  26869. */
  26870. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26871. /**
  26872. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26873. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26874. * The passed axis is also normalized. .
  26875. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26876. * @param point the point to rotate around
  26877. * @param axis the axis to rotate around
  26878. * @param amount the amount to rotate in radians
  26879. * @returns the TransformNode
  26880. */
  26881. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26882. /**
  26883. * Translates the mesh along the axis vector for the passed distance in the given space.
  26884. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26885. * @param axis the axis to translate in
  26886. * @param distance the distance to translate
  26887. * @param space Space to rotate in (Default: local)
  26888. * @returns the TransformNode.
  26889. */
  26890. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26891. /**
  26892. * Adds a rotation step to the mesh current rotation.
  26893. * x, y, z are Euler angles expressed in radians.
  26894. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26895. * This means this rotation is made in the mesh local space only.
  26896. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26897. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26898. * ```javascript
  26899. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26900. * ```
  26901. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26902. * 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.
  26903. * @param x Rotation to add
  26904. * @param y Rotation to add
  26905. * @param z Rotation to add
  26906. * @returns the TransformNode.
  26907. */
  26908. addRotation(x: number, y: number, z: number): TransformNode;
  26909. /**
  26910. * @hidden
  26911. */
  26912. protected _getEffectiveParent(): Nullable<Node>;
  26913. /**
  26914. * Computes the world matrix of the node
  26915. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26916. * @returns the world matrix
  26917. */
  26918. computeWorldMatrix(force?: boolean): Matrix;
  26919. /**
  26920. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26921. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26922. */
  26923. resetLocalMatrix(independentOfChildren?: boolean): void;
  26924. protected _afterComputeWorldMatrix(): void;
  26925. /**
  26926. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26927. * @param func callback function to add
  26928. *
  26929. * @returns the TransformNode.
  26930. */
  26931. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26932. /**
  26933. * Removes a registered callback function.
  26934. * @param func callback function to remove
  26935. * @returns the TransformNode.
  26936. */
  26937. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26938. /**
  26939. * Gets the position of the current mesh in camera space
  26940. * @param camera defines the camera to use
  26941. * @returns a position
  26942. */
  26943. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26944. /**
  26945. * Returns the distance from the mesh to the active camera
  26946. * @param camera defines the camera to use
  26947. * @returns the distance
  26948. */
  26949. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26950. /**
  26951. * Clone the current transform node
  26952. * @param name Name of the new clone
  26953. * @param newParent New parent for the clone
  26954. * @param doNotCloneChildren Do not clone children hierarchy
  26955. * @returns the new transform node
  26956. */
  26957. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26958. /**
  26959. * Serializes the objects information.
  26960. * @param currentSerializationObject defines the object to serialize in
  26961. * @returns the serialized object
  26962. */
  26963. serialize(currentSerializationObject?: any): any;
  26964. /**
  26965. * Returns a new TransformNode object parsed from the source provided.
  26966. * @param parsedTransformNode is the source.
  26967. * @param scene the scne the object belongs to
  26968. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26969. * @returns a new TransformNode object parsed from the source provided.
  26970. */
  26971. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26972. /**
  26973. * Get all child-transformNodes of this node
  26974. * @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
  26975. * @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
  26976. * @returns an array of TransformNode
  26977. */
  26978. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26979. /**
  26980. * Releases resources associated with this transform node.
  26981. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26982. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26983. */
  26984. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26985. /**
  26986. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26987. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26988. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26989. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26990. * @returns the current mesh
  26991. */
  26992. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  26993. private _syncAbsoluteScalingAndRotation;
  26994. }
  26995. }
  26996. declare module BABYLON {
  26997. /**
  26998. * Defines the types of pose enabled controllers that are supported
  26999. */
  27000. export enum PoseEnabledControllerType {
  27001. /**
  27002. * HTC Vive
  27003. */
  27004. VIVE = 0,
  27005. /**
  27006. * Oculus Rift
  27007. */
  27008. OCULUS = 1,
  27009. /**
  27010. * Windows mixed reality
  27011. */
  27012. WINDOWS = 2,
  27013. /**
  27014. * Samsung gear VR
  27015. */
  27016. GEAR_VR = 3,
  27017. /**
  27018. * Google Daydream
  27019. */
  27020. DAYDREAM = 4,
  27021. /**
  27022. * Generic
  27023. */
  27024. GENERIC = 5
  27025. }
  27026. /**
  27027. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27028. */
  27029. export interface MutableGamepadButton {
  27030. /**
  27031. * Value of the button/trigger
  27032. */
  27033. value: number;
  27034. /**
  27035. * If the button/trigger is currently touched
  27036. */
  27037. touched: boolean;
  27038. /**
  27039. * If the button/trigger is currently pressed
  27040. */
  27041. pressed: boolean;
  27042. }
  27043. /**
  27044. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27045. * @hidden
  27046. */
  27047. export interface ExtendedGamepadButton extends GamepadButton {
  27048. /**
  27049. * If the button/trigger is currently pressed
  27050. */
  27051. readonly pressed: boolean;
  27052. /**
  27053. * If the button/trigger is currently touched
  27054. */
  27055. readonly touched: boolean;
  27056. /**
  27057. * Value of the button/trigger
  27058. */
  27059. readonly value: number;
  27060. }
  27061. /** @hidden */
  27062. export interface _GamePadFactory {
  27063. /**
  27064. * Returns whether or not the current gamepad can be created for this type of controller.
  27065. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27066. * @returns true if it can be created, otherwise false
  27067. */
  27068. canCreate(gamepadInfo: any): boolean;
  27069. /**
  27070. * Creates a new instance of the Gamepad.
  27071. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27072. * @returns the new gamepad instance
  27073. */
  27074. create(gamepadInfo: any): Gamepad;
  27075. }
  27076. /**
  27077. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27078. */
  27079. export class PoseEnabledControllerHelper {
  27080. /** @hidden */
  27081. static _ControllerFactories: _GamePadFactory[];
  27082. /** @hidden */
  27083. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27084. /**
  27085. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27086. * @param vrGamepad the gamepad to initialized
  27087. * @returns a vr controller of the type the gamepad identified as
  27088. */
  27089. static InitiateController(vrGamepad: any): Gamepad;
  27090. }
  27091. /**
  27092. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27093. */
  27094. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27095. /**
  27096. * If the controller is used in a webXR session
  27097. */
  27098. isXR: boolean;
  27099. private _deviceRoomPosition;
  27100. private _deviceRoomRotationQuaternion;
  27101. /**
  27102. * The device position in babylon space
  27103. */
  27104. devicePosition: Vector3;
  27105. /**
  27106. * The device rotation in babylon space
  27107. */
  27108. deviceRotationQuaternion: Quaternion;
  27109. /**
  27110. * The scale factor of the device in babylon space
  27111. */
  27112. deviceScaleFactor: number;
  27113. /**
  27114. * (Likely devicePosition should be used instead) The device position in its room space
  27115. */
  27116. position: Vector3;
  27117. /**
  27118. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27119. */
  27120. rotationQuaternion: Quaternion;
  27121. /**
  27122. * The type of controller (Eg. Windows mixed reality)
  27123. */
  27124. controllerType: PoseEnabledControllerType;
  27125. protected _calculatedPosition: Vector3;
  27126. private _calculatedRotation;
  27127. /**
  27128. * The raw pose from the device
  27129. */
  27130. rawPose: DevicePose;
  27131. private _trackPosition;
  27132. private _maxRotationDistFromHeadset;
  27133. private _draggedRoomRotation;
  27134. /**
  27135. * @hidden
  27136. */
  27137. _disableTrackPosition(fixedPosition: Vector3): void;
  27138. /**
  27139. * Internal, the mesh attached to the controller
  27140. * @hidden
  27141. */
  27142. _mesh: Nullable<AbstractMesh>;
  27143. private _poseControlledCamera;
  27144. private _leftHandSystemQuaternion;
  27145. /**
  27146. * Internal, matrix used to convert room space to babylon space
  27147. * @hidden
  27148. */
  27149. _deviceToWorld: Matrix;
  27150. /**
  27151. * Node to be used when casting a ray from the controller
  27152. * @hidden
  27153. */
  27154. _pointingPoseNode: Nullable<TransformNode>;
  27155. /**
  27156. * Name of the child mesh that can be used to cast a ray from the controller
  27157. */
  27158. static readonly POINTING_POSE: string;
  27159. /**
  27160. * Creates a new PoseEnabledController from a gamepad
  27161. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27162. */
  27163. constructor(browserGamepad: any);
  27164. private _workingMatrix;
  27165. /**
  27166. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27167. */
  27168. update(): void;
  27169. /**
  27170. * Updates only the pose device and mesh without doing any button event checking
  27171. */
  27172. protected _updatePoseAndMesh(): void;
  27173. /**
  27174. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27175. * @param poseData raw pose fromthe device
  27176. */
  27177. updateFromDevice(poseData: DevicePose): void;
  27178. /**
  27179. * @hidden
  27180. */
  27181. _meshAttachedObservable: Observable<AbstractMesh>;
  27182. /**
  27183. * Attaches a mesh to the controller
  27184. * @param mesh the mesh to be attached
  27185. */
  27186. attachToMesh(mesh: AbstractMesh): void;
  27187. /**
  27188. * Attaches the controllers mesh to a camera
  27189. * @param camera the camera the mesh should be attached to
  27190. */
  27191. attachToPoseControlledCamera(camera: TargetCamera): void;
  27192. /**
  27193. * Disposes of the controller
  27194. */
  27195. dispose(): void;
  27196. /**
  27197. * The mesh that is attached to the controller
  27198. */
  27199. get mesh(): Nullable<AbstractMesh>;
  27200. /**
  27201. * Gets the ray of the controller in the direction the controller is pointing
  27202. * @param length the length the resulting ray should be
  27203. * @returns a ray in the direction the controller is pointing
  27204. */
  27205. getForwardRay(length?: number): Ray;
  27206. }
  27207. }
  27208. declare module BABYLON {
  27209. /**
  27210. * Defines the WebVRController object that represents controllers tracked in 3D space
  27211. */
  27212. export abstract class WebVRController extends PoseEnabledController {
  27213. /**
  27214. * Internal, the default controller model for the controller
  27215. */
  27216. protected _defaultModel: Nullable<AbstractMesh>;
  27217. /**
  27218. * Fired when the trigger state has changed
  27219. */
  27220. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27221. /**
  27222. * Fired when the main button state has changed
  27223. */
  27224. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27225. /**
  27226. * Fired when the secondary button state has changed
  27227. */
  27228. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27229. /**
  27230. * Fired when the pad state has changed
  27231. */
  27232. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27233. /**
  27234. * Fired when controllers stick values have changed
  27235. */
  27236. onPadValuesChangedObservable: Observable<StickValues>;
  27237. /**
  27238. * Array of button availible on the controller
  27239. */
  27240. protected _buttons: Array<MutableGamepadButton>;
  27241. private _onButtonStateChange;
  27242. /**
  27243. * Fired when a controller button's state has changed
  27244. * @param callback the callback containing the button that was modified
  27245. */
  27246. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27247. /**
  27248. * X and Y axis corresponding to the controllers joystick
  27249. */
  27250. pad: StickValues;
  27251. /**
  27252. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27253. */
  27254. hand: string;
  27255. /**
  27256. * The default controller model for the controller
  27257. */
  27258. get defaultModel(): Nullable<AbstractMesh>;
  27259. /**
  27260. * Creates a new WebVRController from a gamepad
  27261. * @param vrGamepad the gamepad that the WebVRController should be created from
  27262. */
  27263. constructor(vrGamepad: any);
  27264. /**
  27265. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27266. */
  27267. update(): void;
  27268. /**
  27269. * Function to be called when a button is modified
  27270. */
  27271. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27272. /**
  27273. * Loads a mesh and attaches it to the controller
  27274. * @param scene the scene the mesh should be added to
  27275. * @param meshLoaded callback for when the mesh has been loaded
  27276. */
  27277. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27278. private _setButtonValue;
  27279. private _changes;
  27280. private _checkChanges;
  27281. /**
  27282. * Disposes of th webVRCOntroller
  27283. */
  27284. dispose(): void;
  27285. }
  27286. }
  27287. declare module BABYLON {
  27288. /**
  27289. * The HemisphericLight simulates the ambient environment light,
  27290. * so the passed direction is the light reflection direction, not the incoming direction.
  27291. */
  27292. export class HemisphericLight extends Light {
  27293. /**
  27294. * The groundColor is the light in the opposite direction to the one specified during creation.
  27295. * 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.
  27296. */
  27297. groundColor: Color3;
  27298. /**
  27299. * The light reflection direction, not the incoming direction.
  27300. */
  27301. direction: Vector3;
  27302. /**
  27303. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27304. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27305. * The HemisphericLight can't cast shadows.
  27306. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27307. * @param name The friendly name of the light
  27308. * @param direction The direction of the light reflection
  27309. * @param scene The scene the light belongs to
  27310. */
  27311. constructor(name: string, direction: Vector3, scene: Scene);
  27312. protected _buildUniformLayout(): void;
  27313. /**
  27314. * Returns the string "HemisphericLight".
  27315. * @return The class name
  27316. */
  27317. getClassName(): string;
  27318. /**
  27319. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27320. * Returns the updated direction.
  27321. * @param target The target the direction should point to
  27322. * @return The computed direction
  27323. */
  27324. setDirectionToTarget(target: Vector3): Vector3;
  27325. /**
  27326. * Returns the shadow generator associated to the light.
  27327. * @returns Always null for hemispheric lights because it does not support shadows.
  27328. */
  27329. getShadowGenerator(): Nullable<IShadowGenerator>;
  27330. /**
  27331. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27332. * @param effect The effect to update
  27333. * @param lightIndex The index of the light in the effect to update
  27334. * @returns The hemispheric light
  27335. */
  27336. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27337. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27338. /**
  27339. * Computes the world matrix of the node
  27340. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27341. * @param useWasUpdatedFlag defines a reserved property
  27342. * @returns the world matrix
  27343. */
  27344. computeWorldMatrix(): Matrix;
  27345. /**
  27346. * Returns the integer 3.
  27347. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27348. */
  27349. getTypeID(): number;
  27350. /**
  27351. * Prepares the list of defines specific to the light type.
  27352. * @param defines the list of defines
  27353. * @param lightIndex defines the index of the light for the effect
  27354. */
  27355. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27356. }
  27357. }
  27358. declare module BABYLON {
  27359. /** @hidden */
  27360. export var vrMultiviewToSingleviewPixelShader: {
  27361. name: string;
  27362. shader: string;
  27363. };
  27364. }
  27365. declare module BABYLON {
  27366. /**
  27367. * Renders to multiple views with a single draw call
  27368. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27369. */
  27370. export class MultiviewRenderTarget extends RenderTargetTexture {
  27371. /**
  27372. * Creates a multiview render target
  27373. * @param scene scene used with the render target
  27374. * @param size the size of the render target (used for each view)
  27375. */
  27376. constructor(scene: Scene, size?: number | {
  27377. width: number;
  27378. height: number;
  27379. } | {
  27380. ratio: number;
  27381. });
  27382. /**
  27383. * @hidden
  27384. * @param faceIndex the face index, if its a cube texture
  27385. */
  27386. _bindFrameBuffer(faceIndex?: number): void;
  27387. /**
  27388. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27389. * @returns the view count
  27390. */
  27391. getViewCount(): number;
  27392. }
  27393. }
  27394. declare module BABYLON {
  27395. interface Engine {
  27396. /**
  27397. * Creates a new multiview render target
  27398. * @param width defines the width of the texture
  27399. * @param height defines the height of the texture
  27400. * @returns the created multiview texture
  27401. */
  27402. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27403. /**
  27404. * Binds a multiview framebuffer to be drawn to
  27405. * @param multiviewTexture texture to bind
  27406. */
  27407. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27408. }
  27409. interface Camera {
  27410. /**
  27411. * @hidden
  27412. * 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)
  27413. */
  27414. _useMultiviewToSingleView: boolean;
  27415. /**
  27416. * @hidden
  27417. * 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)
  27418. */
  27419. _multiviewTexture: Nullable<RenderTargetTexture>;
  27420. /**
  27421. * @hidden
  27422. * ensures the multiview texture of the camera exists and has the specified width/height
  27423. * @param width height to set on the multiview texture
  27424. * @param height width to set on the multiview texture
  27425. */
  27426. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27427. }
  27428. interface Scene {
  27429. /** @hidden */
  27430. _transformMatrixR: Matrix;
  27431. /** @hidden */
  27432. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27433. /** @hidden */
  27434. _createMultiviewUbo(): void;
  27435. /** @hidden */
  27436. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27437. /** @hidden */
  27438. _renderMultiviewToSingleView(camera: Camera): void;
  27439. }
  27440. }
  27441. declare module BABYLON {
  27442. /**
  27443. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27444. * This will not be used for webXR as it supports displaying texture arrays directly
  27445. */
  27446. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27447. /**
  27448. * Gets a string identifying the name of the class
  27449. * @returns "VRMultiviewToSingleviewPostProcess" string
  27450. */
  27451. getClassName(): string;
  27452. /**
  27453. * Initializes a VRMultiviewToSingleview
  27454. * @param name name of the post process
  27455. * @param camera camera to be applied to
  27456. * @param scaleFactor scaling factor to the size of the output texture
  27457. */
  27458. constructor(name: string, camera: Camera, scaleFactor: number);
  27459. }
  27460. }
  27461. declare module BABYLON {
  27462. /**
  27463. * Interface used to define additional presentation attributes
  27464. */
  27465. export interface IVRPresentationAttributes {
  27466. /**
  27467. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27468. */
  27469. highRefreshRate: boolean;
  27470. /**
  27471. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27472. */
  27473. foveationLevel: number;
  27474. }
  27475. interface Engine {
  27476. /** @hidden */
  27477. _vrDisplay: any;
  27478. /** @hidden */
  27479. _vrSupported: boolean;
  27480. /** @hidden */
  27481. _oldSize: Size;
  27482. /** @hidden */
  27483. _oldHardwareScaleFactor: number;
  27484. /** @hidden */
  27485. _vrExclusivePointerMode: boolean;
  27486. /** @hidden */
  27487. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27488. /** @hidden */
  27489. _onVRDisplayPointerRestricted: () => void;
  27490. /** @hidden */
  27491. _onVRDisplayPointerUnrestricted: () => void;
  27492. /** @hidden */
  27493. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27494. /** @hidden */
  27495. _onVrDisplayDisconnect: Nullable<() => void>;
  27496. /** @hidden */
  27497. _onVrDisplayPresentChange: Nullable<() => void>;
  27498. /**
  27499. * Observable signaled when VR display mode changes
  27500. */
  27501. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27502. /**
  27503. * Observable signaled when VR request present is complete
  27504. */
  27505. onVRRequestPresentComplete: Observable<boolean>;
  27506. /**
  27507. * Observable signaled when VR request present starts
  27508. */
  27509. onVRRequestPresentStart: Observable<Engine>;
  27510. /**
  27511. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27512. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27513. */
  27514. isInVRExclusivePointerMode: boolean;
  27515. /**
  27516. * Gets a boolean indicating if a webVR device was detected
  27517. * @returns true if a webVR device was detected
  27518. */
  27519. isVRDevicePresent(): boolean;
  27520. /**
  27521. * Gets the current webVR device
  27522. * @returns the current webVR device (or null)
  27523. */
  27524. getVRDevice(): any;
  27525. /**
  27526. * Initializes a webVR display and starts listening to display change events
  27527. * The onVRDisplayChangedObservable will be notified upon these changes
  27528. * @returns A promise containing a VRDisplay and if vr is supported
  27529. */
  27530. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27531. /** @hidden */
  27532. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27533. /**
  27534. * Gets or sets the presentation attributes used to configure VR rendering
  27535. */
  27536. vrPresentationAttributes?: IVRPresentationAttributes;
  27537. /**
  27538. * Call this function to switch to webVR mode
  27539. * Will do nothing if webVR is not supported or if there is no webVR device
  27540. * @param options the webvr options provided to the camera. mainly used for multiview
  27541. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27542. */
  27543. enableVR(options: WebVROptions): void;
  27544. /** @hidden */
  27545. _onVRFullScreenTriggered(): void;
  27546. }
  27547. }
  27548. declare module BABYLON {
  27549. /**
  27550. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27551. * IMPORTANT!! The data is right-hand data.
  27552. * @export
  27553. * @interface DevicePose
  27554. */
  27555. export interface DevicePose {
  27556. /**
  27557. * The position of the device, values in array are [x,y,z].
  27558. */
  27559. readonly position: Nullable<Float32Array>;
  27560. /**
  27561. * The linearVelocity of the device, values in array are [x,y,z].
  27562. */
  27563. readonly linearVelocity: Nullable<Float32Array>;
  27564. /**
  27565. * The linearAcceleration of the device, values in array are [x,y,z].
  27566. */
  27567. readonly linearAcceleration: Nullable<Float32Array>;
  27568. /**
  27569. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27570. */
  27571. readonly orientation: Nullable<Float32Array>;
  27572. /**
  27573. * The angularVelocity of the device, values in array are [x,y,z].
  27574. */
  27575. readonly angularVelocity: Nullable<Float32Array>;
  27576. /**
  27577. * The angularAcceleration of the device, values in array are [x,y,z].
  27578. */
  27579. readonly angularAcceleration: Nullable<Float32Array>;
  27580. }
  27581. /**
  27582. * Interface representing a pose controlled object in Babylon.
  27583. * A pose controlled object has both regular pose values as well as pose values
  27584. * from an external device such as a VR head mounted display
  27585. */
  27586. export interface PoseControlled {
  27587. /**
  27588. * The position of the object in babylon space.
  27589. */
  27590. position: Vector3;
  27591. /**
  27592. * The rotation quaternion of the object in babylon space.
  27593. */
  27594. rotationQuaternion: Quaternion;
  27595. /**
  27596. * The position of the device in babylon space.
  27597. */
  27598. devicePosition?: Vector3;
  27599. /**
  27600. * The rotation quaternion of the device in babylon space.
  27601. */
  27602. deviceRotationQuaternion: Quaternion;
  27603. /**
  27604. * The raw pose coming from the device.
  27605. */
  27606. rawPose: Nullable<DevicePose>;
  27607. /**
  27608. * The scale of the device to be used when translating from device space to babylon space.
  27609. */
  27610. deviceScaleFactor: number;
  27611. /**
  27612. * Updates the poseControlled values based on the input device pose.
  27613. * @param poseData the pose data to update the object with
  27614. */
  27615. updateFromDevice(poseData: DevicePose): void;
  27616. }
  27617. /**
  27618. * Set of options to customize the webVRCamera
  27619. */
  27620. export interface WebVROptions {
  27621. /**
  27622. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27623. */
  27624. trackPosition?: boolean;
  27625. /**
  27626. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27627. */
  27628. positionScale?: number;
  27629. /**
  27630. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27631. */
  27632. displayName?: string;
  27633. /**
  27634. * Should the native controller meshes be initialized. (default: true)
  27635. */
  27636. controllerMeshes?: boolean;
  27637. /**
  27638. * Creating a default HemiLight only on controllers. (default: true)
  27639. */
  27640. defaultLightingOnControllers?: boolean;
  27641. /**
  27642. * If you don't want to use the default VR button of the helper. (default: false)
  27643. */
  27644. useCustomVRButton?: boolean;
  27645. /**
  27646. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27647. */
  27648. customVRButton?: HTMLButtonElement;
  27649. /**
  27650. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27651. */
  27652. rayLength?: number;
  27653. /**
  27654. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27655. */
  27656. defaultHeight?: number;
  27657. /**
  27658. * If multiview should be used if availible (default: false)
  27659. */
  27660. useMultiview?: boolean;
  27661. }
  27662. /**
  27663. * This represents a WebVR camera.
  27664. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27665. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27666. */
  27667. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27668. private webVROptions;
  27669. /**
  27670. * @hidden
  27671. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27672. */
  27673. _vrDevice: any;
  27674. /**
  27675. * The rawPose of the vrDevice.
  27676. */
  27677. rawPose: Nullable<DevicePose>;
  27678. private _onVREnabled;
  27679. private _specsVersion;
  27680. private _attached;
  27681. private _frameData;
  27682. protected _descendants: Array<Node>;
  27683. private _deviceRoomPosition;
  27684. /** @hidden */
  27685. _deviceRoomRotationQuaternion: Quaternion;
  27686. private _standingMatrix;
  27687. /**
  27688. * Represents device position in babylon space.
  27689. */
  27690. devicePosition: Vector3;
  27691. /**
  27692. * Represents device rotation in babylon space.
  27693. */
  27694. deviceRotationQuaternion: Quaternion;
  27695. /**
  27696. * The scale of the device to be used when translating from device space to babylon space.
  27697. */
  27698. deviceScaleFactor: number;
  27699. private _deviceToWorld;
  27700. private _worldToDevice;
  27701. /**
  27702. * References to the webVR controllers for the vrDevice.
  27703. */
  27704. controllers: Array<WebVRController>;
  27705. /**
  27706. * Emits an event when a controller is attached.
  27707. */
  27708. onControllersAttachedObservable: Observable<WebVRController[]>;
  27709. /**
  27710. * Emits an event when a controller's mesh has been loaded;
  27711. */
  27712. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27713. /**
  27714. * Emits an event when the HMD's pose has been updated.
  27715. */
  27716. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27717. private _poseSet;
  27718. /**
  27719. * If the rig cameras be used as parent instead of this camera.
  27720. */
  27721. rigParenting: boolean;
  27722. private _lightOnControllers;
  27723. private _defaultHeight?;
  27724. /**
  27725. * Instantiates a WebVRFreeCamera.
  27726. * @param name The name of the WebVRFreeCamera
  27727. * @param position The starting anchor position for the camera
  27728. * @param scene The scene the camera belongs to
  27729. * @param webVROptions a set of customizable options for the webVRCamera
  27730. */
  27731. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27732. /**
  27733. * Gets the device distance from the ground in meters.
  27734. * @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.
  27735. */
  27736. deviceDistanceToRoomGround(): number;
  27737. /**
  27738. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27739. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27740. */
  27741. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27742. /**
  27743. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27744. * @returns A promise with a boolean set to if the standing matrix is supported.
  27745. */
  27746. useStandingMatrixAsync(): Promise<boolean>;
  27747. /**
  27748. * Disposes the camera
  27749. */
  27750. dispose(): void;
  27751. /**
  27752. * Gets a vrController by name.
  27753. * @param name The name of the controller to retreive
  27754. * @returns the controller matching the name specified or null if not found
  27755. */
  27756. getControllerByName(name: string): Nullable<WebVRController>;
  27757. private _leftController;
  27758. /**
  27759. * The controller corresponding to the users left hand.
  27760. */
  27761. get leftController(): Nullable<WebVRController>;
  27762. private _rightController;
  27763. /**
  27764. * The controller corresponding to the users right hand.
  27765. */
  27766. get rightController(): Nullable<WebVRController>;
  27767. /**
  27768. * Casts a ray forward from the vrCamera's gaze.
  27769. * @param length Length of the ray (default: 100)
  27770. * @returns the ray corresponding to the gaze
  27771. */
  27772. getForwardRay(length?: number): Ray;
  27773. /**
  27774. * @hidden
  27775. * Updates the camera based on device's frame data
  27776. */
  27777. _checkInputs(): void;
  27778. /**
  27779. * Updates the poseControlled values based on the input device pose.
  27780. * @param poseData Pose coming from the device
  27781. */
  27782. updateFromDevice(poseData: DevicePose): void;
  27783. private _detachIfAttached;
  27784. /**
  27785. * WebVR's attach control will start broadcasting frames to the device.
  27786. * Note that in certain browsers (chrome for example) this function must be called
  27787. * within a user-interaction callback. Example:
  27788. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27789. *
  27790. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27791. */
  27792. attachControl(noPreventDefault?: boolean): void;
  27793. /**
  27794. * Detach the current controls from the specified dom element.
  27795. */
  27796. detachControl(): void;
  27797. /**
  27798. * @returns the name of this class
  27799. */
  27800. getClassName(): string;
  27801. /**
  27802. * Calls resetPose on the vrDisplay
  27803. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27804. */
  27805. resetToCurrentRotation(): void;
  27806. /**
  27807. * @hidden
  27808. * Updates the rig cameras (left and right eye)
  27809. */
  27810. _updateRigCameras(): void;
  27811. private _workingVector;
  27812. private _oneVector;
  27813. private _workingMatrix;
  27814. private updateCacheCalled;
  27815. private _correctPositionIfNotTrackPosition;
  27816. /**
  27817. * @hidden
  27818. * Updates the cached values of the camera
  27819. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27820. */
  27821. _updateCache(ignoreParentClass?: boolean): void;
  27822. /**
  27823. * @hidden
  27824. * Get current device position in babylon world
  27825. */
  27826. _computeDevicePosition(): void;
  27827. /**
  27828. * Updates the current device position and rotation in the babylon world
  27829. */
  27830. update(): void;
  27831. /**
  27832. * @hidden
  27833. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27834. * @returns an identity matrix
  27835. */
  27836. _getViewMatrix(): Matrix;
  27837. private _tmpMatrix;
  27838. /**
  27839. * This function is called by the two RIG cameras.
  27840. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27841. * @hidden
  27842. */
  27843. _getWebVRViewMatrix(): Matrix;
  27844. /** @hidden */
  27845. _getWebVRProjectionMatrix(): Matrix;
  27846. private _onGamepadConnectedObserver;
  27847. private _onGamepadDisconnectedObserver;
  27848. private _updateCacheWhenTrackingDisabledObserver;
  27849. /**
  27850. * Initializes the controllers and their meshes
  27851. */
  27852. initControllers(): void;
  27853. }
  27854. }
  27855. declare module BABYLON {
  27856. /**
  27857. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27858. *
  27859. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27860. *
  27861. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27862. */
  27863. export class MaterialHelper {
  27864. /**
  27865. * Bind the current view position to an effect.
  27866. * @param effect The effect to be bound
  27867. * @param scene The scene the eyes position is used from
  27868. * @param variableName name of the shader variable that will hold the eye position
  27869. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  27870. * @return the computed eye position
  27871. */
  27872. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  27873. /**
  27874. * Helps preparing the defines values about the UVs in used in the effect.
  27875. * UVs are shared as much as we can accross channels in the shaders.
  27876. * @param texture The texture we are preparing the UVs for
  27877. * @param defines The defines to update
  27878. * @param key The channel key "diffuse", "specular"... used in the shader
  27879. */
  27880. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27881. /**
  27882. * Binds a texture matrix value to its corrsponding uniform
  27883. * @param texture The texture to bind the matrix for
  27884. * @param uniformBuffer The uniform buffer receivin the data
  27885. * @param key The channel key "diffuse", "specular"... used in the shader
  27886. */
  27887. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27888. /**
  27889. * Gets the current status of the fog (should it be enabled?)
  27890. * @param mesh defines the mesh to evaluate for fog support
  27891. * @param scene defines the hosting scene
  27892. * @returns true if fog must be enabled
  27893. */
  27894. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27895. /**
  27896. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27897. * @param mesh defines the current mesh
  27898. * @param scene defines the current scene
  27899. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27900. * @param pointsCloud defines if point cloud rendering has to be turned on
  27901. * @param fogEnabled defines if fog has to be turned on
  27902. * @param alphaTest defines if alpha testing has to be turned on
  27903. * @param defines defines the current list of defines
  27904. */
  27905. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27906. /**
  27907. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27908. * @param scene defines the current scene
  27909. * @param engine defines the current engine
  27910. * @param defines specifies the list of active defines
  27911. * @param useInstances defines if instances have to be turned on
  27912. * @param useClipPlane defines if clip plane have to be turned on
  27913. * @param useInstances defines if instances have to be turned on
  27914. * @param useThinInstances defines if thin instances have to be turned on
  27915. */
  27916. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27917. /**
  27918. * Prepares the defines for bones
  27919. * @param mesh The mesh containing the geometry data we will draw
  27920. * @param defines The defines to update
  27921. */
  27922. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27923. /**
  27924. * Prepares the defines for morph targets
  27925. * @param mesh The mesh containing the geometry data we will draw
  27926. * @param defines The defines to update
  27927. */
  27928. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27929. /**
  27930. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27931. * @param mesh The mesh containing the geometry data we will draw
  27932. * @param defines The defines to update
  27933. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27934. * @param useBones Precise whether bones should be used or not (override mesh info)
  27935. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27936. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27937. * @returns false if defines are considered not dirty and have not been checked
  27938. */
  27939. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27940. /**
  27941. * Prepares the defines related to multiview
  27942. * @param scene The scene we are intending to draw
  27943. * @param defines The defines to update
  27944. */
  27945. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27946. /**
  27947. * Prepares the defines related to the prepass
  27948. * @param scene The scene we are intending to draw
  27949. * @param defines The defines to update
  27950. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27951. */
  27952. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27953. /**
  27954. * Prepares the defines related to the light information passed in parameter
  27955. * @param scene The scene we are intending to draw
  27956. * @param mesh The mesh the effect is compiling for
  27957. * @param light The light the effect is compiling for
  27958. * @param lightIndex The index of the light
  27959. * @param defines The defines to update
  27960. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27961. * @param state Defines the current state regarding what is needed (normals, etc...)
  27962. */
  27963. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27964. needNormals: boolean;
  27965. needRebuild: boolean;
  27966. shadowEnabled: boolean;
  27967. specularEnabled: boolean;
  27968. lightmapMode: boolean;
  27969. }): void;
  27970. /**
  27971. * Prepares the defines related to the light information passed in parameter
  27972. * @param scene The scene we are intending to draw
  27973. * @param mesh The mesh the effect is compiling for
  27974. * @param defines The defines to update
  27975. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27976. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27977. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27978. * @returns true if normals will be required for the rest of the effect
  27979. */
  27980. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27981. /**
  27982. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27983. * @param lightIndex defines the light index
  27984. * @param uniformsList The uniform list
  27985. * @param samplersList The sampler list
  27986. * @param projectedLightTexture defines if projected texture must be used
  27987. * @param uniformBuffersList defines an optional list of uniform buffers
  27988. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  27989. */
  27990. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  27991. /**
  27992. * Prepares the uniforms and samplers list to be used in the effect
  27993. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  27994. * @param samplersList The sampler list
  27995. * @param defines The defines helping in the list generation
  27996. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  27997. */
  27998. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  27999. /**
  28000. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28001. * @param defines The defines to update while falling back
  28002. * @param fallbacks The authorized effect fallbacks
  28003. * @param maxSimultaneousLights The maximum number of lights allowed
  28004. * @param rank the current rank of the Effect
  28005. * @returns The newly affected rank
  28006. */
  28007. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28008. private static _TmpMorphInfluencers;
  28009. /**
  28010. * Prepares the list of attributes required for morph targets according to the effect defines.
  28011. * @param attribs The current list of supported attribs
  28012. * @param mesh The mesh to prepare the morph targets attributes for
  28013. * @param influencers The number of influencers
  28014. */
  28015. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28016. /**
  28017. * Prepares the list of attributes required for morph targets according to the effect defines.
  28018. * @param attribs The current list of supported attribs
  28019. * @param mesh The mesh to prepare the morph targets attributes for
  28020. * @param defines The current Defines of the effect
  28021. */
  28022. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28023. /**
  28024. * Prepares the list of attributes required for bones according to the effect defines.
  28025. * @param attribs The current list of supported attribs
  28026. * @param mesh The mesh to prepare the bones attributes for
  28027. * @param defines The current Defines of the effect
  28028. * @param fallbacks The current efffect fallback strategy
  28029. */
  28030. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28031. /**
  28032. * Check and prepare the list of attributes required for instances according to the effect defines.
  28033. * @param attribs The current list of supported attribs
  28034. * @param defines The current MaterialDefines of the effect
  28035. */
  28036. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28037. /**
  28038. * Add the list of attributes required for instances to the attribs array.
  28039. * @param attribs The current list of supported attribs
  28040. */
  28041. static PushAttributesForInstances(attribs: string[]): void;
  28042. /**
  28043. * Binds the light information to the effect.
  28044. * @param light The light containing the generator
  28045. * @param effect The effect we are binding the data to
  28046. * @param lightIndex The light index in the effect used to render
  28047. */
  28048. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28049. /**
  28050. * Binds the lights information from the scene to the effect for the given mesh.
  28051. * @param light Light to bind
  28052. * @param lightIndex Light index
  28053. * @param scene The scene where the light belongs to
  28054. * @param effect The effect we are binding the data to
  28055. * @param useSpecular Defines if specular is supported
  28056. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28057. */
  28058. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28059. /**
  28060. * Binds the lights information from the scene to the effect for the given mesh.
  28061. * @param scene The scene the lights belongs to
  28062. * @param mesh The mesh we are binding the information to render
  28063. * @param effect The effect we are binding the data to
  28064. * @param defines The generated defines for the effect
  28065. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28066. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28067. */
  28068. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28069. private static _tempFogColor;
  28070. /**
  28071. * Binds the fog information from the scene to the effect for the given mesh.
  28072. * @param scene The scene the lights belongs to
  28073. * @param mesh The mesh we are binding the information to render
  28074. * @param effect The effect we are binding the data to
  28075. * @param linearSpace Defines if the fog effect is applied in linear space
  28076. */
  28077. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28078. /**
  28079. * Binds the bones information from the mesh to the effect.
  28080. * @param mesh The mesh we are binding the information to render
  28081. * @param effect The effect we are binding the data to
  28082. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28083. */
  28084. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28085. private static _CopyBonesTransformationMatrices;
  28086. /**
  28087. * Binds the morph targets information from the mesh to the effect.
  28088. * @param abstractMesh The mesh we are binding the information to render
  28089. * @param effect The effect we are binding the data to
  28090. */
  28091. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28092. /**
  28093. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28094. * @param defines The generated defines used in the effect
  28095. * @param effect The effect we are binding the data to
  28096. * @param scene The scene we are willing to render with logarithmic scale for
  28097. */
  28098. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28099. /**
  28100. * Binds the clip plane information from the scene to the effect.
  28101. * @param scene The scene the clip plane information are extracted from
  28102. * @param effect The effect we are binding the data to
  28103. */
  28104. static BindClipPlane(effect: Effect, scene: Scene): void;
  28105. }
  28106. }
  28107. declare module BABYLON {
  28108. /** @hidden */
  28109. export var bayerDitherFunctions: {
  28110. name: string;
  28111. shader: string;
  28112. };
  28113. }
  28114. declare module BABYLON {
  28115. /** @hidden */
  28116. export var shadowMapFragmentDeclaration: {
  28117. name: string;
  28118. shader: string;
  28119. };
  28120. }
  28121. declare module BABYLON {
  28122. /** @hidden */
  28123. export var shadowMapFragment: {
  28124. name: string;
  28125. shader: string;
  28126. };
  28127. }
  28128. declare module BABYLON {
  28129. /** @hidden */
  28130. export var shadowMapPixelShader: {
  28131. name: string;
  28132. shader: string;
  28133. };
  28134. }
  28135. declare module BABYLON {
  28136. /** @hidden */
  28137. export var shadowMapVertexDeclaration: {
  28138. name: string;
  28139. shader: string;
  28140. };
  28141. }
  28142. declare module BABYLON {
  28143. /** @hidden */
  28144. export var shadowMapVertexNormalBias: {
  28145. name: string;
  28146. shader: string;
  28147. };
  28148. }
  28149. declare module BABYLON {
  28150. /** @hidden */
  28151. export var shadowMapVertexMetric: {
  28152. name: string;
  28153. shader: string;
  28154. };
  28155. }
  28156. declare module BABYLON {
  28157. /** @hidden */
  28158. export var shadowMapVertexShader: {
  28159. name: string;
  28160. shader: string;
  28161. };
  28162. }
  28163. declare module BABYLON {
  28164. /** @hidden */
  28165. export var depthBoxBlurPixelShader: {
  28166. name: string;
  28167. shader: string;
  28168. };
  28169. }
  28170. declare module BABYLON {
  28171. /** @hidden */
  28172. export var shadowMapFragmentSoftTransparentShadow: {
  28173. name: string;
  28174. shader: string;
  28175. };
  28176. }
  28177. declare module BABYLON {
  28178. /**
  28179. * Creates an instance based on a source mesh.
  28180. */
  28181. export class InstancedMesh extends AbstractMesh {
  28182. private _sourceMesh;
  28183. private _currentLOD;
  28184. /** @hidden */
  28185. _indexInSourceMeshInstanceArray: number;
  28186. constructor(name: string, source: Mesh);
  28187. /**
  28188. * Returns the string "InstancedMesh".
  28189. */
  28190. getClassName(): string;
  28191. /** Gets the list of lights affecting that mesh */
  28192. get lightSources(): Light[];
  28193. _resyncLightSources(): void;
  28194. _resyncLightSource(light: Light): void;
  28195. _removeLightSource(light: Light, dispose: boolean): void;
  28196. /**
  28197. * If the source mesh receives shadows
  28198. */
  28199. get receiveShadows(): boolean;
  28200. /**
  28201. * The material of the source mesh
  28202. */
  28203. get material(): Nullable<Material>;
  28204. /**
  28205. * Visibility of the source mesh
  28206. */
  28207. get visibility(): number;
  28208. /**
  28209. * Skeleton of the source mesh
  28210. */
  28211. get skeleton(): Nullable<Skeleton>;
  28212. /**
  28213. * Rendering ground id of the source mesh
  28214. */
  28215. get renderingGroupId(): number;
  28216. set renderingGroupId(value: number);
  28217. /**
  28218. * Returns the total number of vertices (integer).
  28219. */
  28220. getTotalVertices(): number;
  28221. /**
  28222. * Returns a positive integer : the total number of indices in this mesh geometry.
  28223. * @returns the numner of indices or zero if the mesh has no geometry.
  28224. */
  28225. getTotalIndices(): number;
  28226. /**
  28227. * The source mesh of the instance
  28228. */
  28229. get sourceMesh(): Mesh;
  28230. /**
  28231. * Creates a new InstancedMesh object from the mesh model.
  28232. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28233. * @param name defines the name of the new instance
  28234. * @returns a new InstancedMesh
  28235. */
  28236. createInstance(name: string): InstancedMesh;
  28237. /**
  28238. * Is this node ready to be used/rendered
  28239. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28240. * @return {boolean} is it ready
  28241. */
  28242. isReady(completeCheck?: boolean): boolean;
  28243. /**
  28244. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28245. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28246. * @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.
  28247. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28248. */
  28249. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28250. /**
  28251. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28252. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28253. * The `data` are either a numeric array either a Float32Array.
  28254. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28255. * 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).
  28256. * Note that a new underlying VertexBuffer object is created each call.
  28257. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28258. *
  28259. * Possible `kind` values :
  28260. * - VertexBuffer.PositionKind
  28261. * - VertexBuffer.UVKind
  28262. * - VertexBuffer.UV2Kind
  28263. * - VertexBuffer.UV3Kind
  28264. * - VertexBuffer.UV4Kind
  28265. * - VertexBuffer.UV5Kind
  28266. * - VertexBuffer.UV6Kind
  28267. * - VertexBuffer.ColorKind
  28268. * - VertexBuffer.MatricesIndicesKind
  28269. * - VertexBuffer.MatricesIndicesExtraKind
  28270. * - VertexBuffer.MatricesWeightsKind
  28271. * - VertexBuffer.MatricesWeightsExtraKind
  28272. *
  28273. * Returns the Mesh.
  28274. */
  28275. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28276. /**
  28277. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28278. * If the mesh has no geometry, it is simply returned as it is.
  28279. * The `data` are either a numeric array either a Float32Array.
  28280. * No new underlying VertexBuffer object is created.
  28281. * 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.
  28282. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28283. *
  28284. * Possible `kind` values :
  28285. * - VertexBuffer.PositionKind
  28286. * - VertexBuffer.UVKind
  28287. * - VertexBuffer.UV2Kind
  28288. * - VertexBuffer.UV3Kind
  28289. * - VertexBuffer.UV4Kind
  28290. * - VertexBuffer.UV5Kind
  28291. * - VertexBuffer.UV6Kind
  28292. * - VertexBuffer.ColorKind
  28293. * - VertexBuffer.MatricesIndicesKind
  28294. * - VertexBuffer.MatricesIndicesExtraKind
  28295. * - VertexBuffer.MatricesWeightsKind
  28296. * - VertexBuffer.MatricesWeightsExtraKind
  28297. *
  28298. * Returns the Mesh.
  28299. */
  28300. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28301. /**
  28302. * Sets the mesh indices.
  28303. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28304. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28305. * This method creates a new index buffer each call.
  28306. * Returns the Mesh.
  28307. */
  28308. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28309. /**
  28310. * Boolean : True if the mesh owns the requested kind of data.
  28311. */
  28312. isVerticesDataPresent(kind: string): boolean;
  28313. /**
  28314. * Returns an array of indices (IndicesArray).
  28315. */
  28316. getIndices(): Nullable<IndicesArray>;
  28317. get _positions(): Nullable<Vector3[]>;
  28318. /**
  28319. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28320. * This means the mesh underlying bounding box and sphere are recomputed.
  28321. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28322. * @returns the current mesh
  28323. */
  28324. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28325. /** @hidden */
  28326. _preActivate(): InstancedMesh;
  28327. /** @hidden */
  28328. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28329. /** @hidden */
  28330. _postActivate(): void;
  28331. getWorldMatrix(): Matrix;
  28332. get isAnInstance(): boolean;
  28333. /**
  28334. * Returns the current associated LOD AbstractMesh.
  28335. */
  28336. getLOD(camera: Camera): AbstractMesh;
  28337. /** @hidden */
  28338. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28339. /** @hidden */
  28340. _syncSubMeshes(): InstancedMesh;
  28341. /** @hidden */
  28342. _generatePointsArray(): boolean;
  28343. /** @hidden */
  28344. _updateBoundingInfo(): AbstractMesh;
  28345. /**
  28346. * Creates a new InstancedMesh from the current mesh.
  28347. * - name (string) : the cloned mesh name
  28348. * - newParent (optional Node) : the optional Node to parent the clone to.
  28349. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28350. *
  28351. * Returns the clone.
  28352. */
  28353. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28354. /**
  28355. * Disposes the InstancedMesh.
  28356. * Returns nothing.
  28357. */
  28358. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28359. }
  28360. interface Mesh {
  28361. /**
  28362. * Register a custom buffer that will be instanced
  28363. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28364. * @param kind defines the buffer kind
  28365. * @param stride defines the stride in floats
  28366. */
  28367. registerInstancedBuffer(kind: string, stride: number): void;
  28368. /**
  28369. * true to use the edge renderer for all instances of this mesh
  28370. */
  28371. edgesShareWithInstances: boolean;
  28372. /** @hidden */
  28373. _userInstancedBuffersStorage: {
  28374. data: {
  28375. [key: string]: Float32Array;
  28376. };
  28377. sizes: {
  28378. [key: string]: number;
  28379. };
  28380. vertexBuffers: {
  28381. [key: string]: Nullable<VertexBuffer>;
  28382. };
  28383. strides: {
  28384. [key: string]: number;
  28385. };
  28386. };
  28387. }
  28388. interface AbstractMesh {
  28389. /**
  28390. * Object used to store instanced buffers defined by user
  28391. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28392. */
  28393. instancedBuffers: {
  28394. [key: string]: any;
  28395. };
  28396. }
  28397. }
  28398. declare module BABYLON {
  28399. /**
  28400. * Defines the options associated with the creation of a shader material.
  28401. */
  28402. export interface IShaderMaterialOptions {
  28403. /**
  28404. * Does the material work in alpha blend mode
  28405. */
  28406. needAlphaBlending: boolean;
  28407. /**
  28408. * Does the material work in alpha test mode
  28409. */
  28410. needAlphaTesting: boolean;
  28411. /**
  28412. * The list of attribute names used in the shader
  28413. */
  28414. attributes: string[];
  28415. /**
  28416. * The list of unifrom names used in the shader
  28417. */
  28418. uniforms: string[];
  28419. /**
  28420. * The list of UBO names used in the shader
  28421. */
  28422. uniformBuffers: string[];
  28423. /**
  28424. * The list of sampler names used in the shader
  28425. */
  28426. samplers: string[];
  28427. /**
  28428. * The list of defines used in the shader
  28429. */
  28430. defines: string[];
  28431. }
  28432. /**
  28433. * 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.
  28434. *
  28435. * This returned material effects how the mesh will look based on the code in the shaders.
  28436. *
  28437. * @see https://doc.babylonjs.com/how_to/shader_material
  28438. */
  28439. export class ShaderMaterial extends Material {
  28440. private _shaderPath;
  28441. private _options;
  28442. private _textures;
  28443. private _textureArrays;
  28444. private _floats;
  28445. private _ints;
  28446. private _floatsArrays;
  28447. private _colors3;
  28448. private _colors3Arrays;
  28449. private _colors4;
  28450. private _colors4Arrays;
  28451. private _vectors2;
  28452. private _vectors3;
  28453. private _vectors4;
  28454. private _matrices;
  28455. private _matrixArrays;
  28456. private _matrices3x3;
  28457. private _matrices2x2;
  28458. private _vectors2Arrays;
  28459. private _vectors3Arrays;
  28460. private _vectors4Arrays;
  28461. private _cachedWorldViewMatrix;
  28462. private _cachedWorldViewProjectionMatrix;
  28463. private _renderId;
  28464. private _multiview;
  28465. private _cachedDefines;
  28466. /** Define the Url to load snippets */
  28467. static SnippetUrl: string;
  28468. /** Snippet ID if the material was created from the snippet server */
  28469. snippetId: string;
  28470. /**
  28471. * Instantiate a new shader material.
  28472. * 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.
  28473. * This returned material effects how the mesh will look based on the code in the shaders.
  28474. * @see https://doc.babylonjs.com/how_to/shader_material
  28475. * @param name Define the name of the material in the scene
  28476. * @param scene Define the scene the material belongs to
  28477. * @param shaderPath Defines the route to the shader code in one of three ways:
  28478. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28479. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28480. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28481. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28482. * @param options Define the options used to create the shader
  28483. */
  28484. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28485. /**
  28486. * Gets the shader path used to define the shader code
  28487. * It can be modified to trigger a new compilation
  28488. */
  28489. get shaderPath(): any;
  28490. /**
  28491. * Sets the shader path used to define the shader code
  28492. * It can be modified to trigger a new compilation
  28493. */
  28494. set shaderPath(shaderPath: any);
  28495. /**
  28496. * Gets the options used to compile the shader.
  28497. * They can be modified to trigger a new compilation
  28498. */
  28499. get options(): IShaderMaterialOptions;
  28500. /**
  28501. * Gets the current class name of the material e.g. "ShaderMaterial"
  28502. * Mainly use in serialization.
  28503. * @returns the class name
  28504. */
  28505. getClassName(): string;
  28506. /**
  28507. * Specifies if the material will require alpha blending
  28508. * @returns a boolean specifying if alpha blending is needed
  28509. */
  28510. needAlphaBlending(): boolean;
  28511. /**
  28512. * Specifies if this material should be rendered in alpha test mode
  28513. * @returns a boolean specifying if an alpha test is needed.
  28514. */
  28515. needAlphaTesting(): boolean;
  28516. private _checkUniform;
  28517. /**
  28518. * Set a texture in the shader.
  28519. * @param name Define the name of the uniform samplers as defined in the shader
  28520. * @param texture Define the texture to bind to this sampler
  28521. * @return the material itself allowing "fluent" like uniform updates
  28522. */
  28523. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28524. /**
  28525. * Set a texture array in the shader.
  28526. * @param name Define the name of the uniform sampler array as defined in the shader
  28527. * @param textures Define the list of textures to bind to this sampler
  28528. * @return the material itself allowing "fluent" like uniform updates
  28529. */
  28530. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28531. /**
  28532. * Set a float in the shader.
  28533. * @param name Define the name of the uniform as defined in the shader
  28534. * @param value Define the value to give to the uniform
  28535. * @return the material itself allowing "fluent" like uniform updates
  28536. */
  28537. setFloat(name: string, value: number): ShaderMaterial;
  28538. /**
  28539. * Set a int in the shader.
  28540. * @param name Define the name of the uniform as defined in the shader
  28541. * @param value Define the value to give to the uniform
  28542. * @return the material itself allowing "fluent" like uniform updates
  28543. */
  28544. setInt(name: string, value: number): ShaderMaterial;
  28545. /**
  28546. * Set an array of floats in the shader.
  28547. * @param name Define the name of the uniform as defined in the shader
  28548. * @param value Define the value to give to the uniform
  28549. * @return the material itself allowing "fluent" like uniform updates
  28550. */
  28551. setFloats(name: string, value: number[]): ShaderMaterial;
  28552. /**
  28553. * Set a vec3 in the shader from a Color3.
  28554. * @param name Define the name of the uniform as defined in the shader
  28555. * @param value Define the value to give to the uniform
  28556. * @return the material itself allowing "fluent" like uniform updates
  28557. */
  28558. setColor3(name: string, value: Color3): ShaderMaterial;
  28559. /**
  28560. * Set a vec3 array in the shader from a Color3 array.
  28561. * @param name Define the name of the uniform as defined in the shader
  28562. * @param value Define the value to give to the uniform
  28563. * @return the material itself allowing "fluent" like uniform updates
  28564. */
  28565. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28566. /**
  28567. * Set a vec4 in the shader from a Color4.
  28568. * @param name Define the name of the uniform as defined in the shader
  28569. * @param value Define the value to give to the uniform
  28570. * @return the material itself allowing "fluent" like uniform updates
  28571. */
  28572. setColor4(name: string, value: Color4): ShaderMaterial;
  28573. /**
  28574. * Set a vec4 array in the shader from a Color4 array.
  28575. * @param name Define the name of the uniform as defined in the shader
  28576. * @param value Define the value to give to the uniform
  28577. * @return the material itself allowing "fluent" like uniform updates
  28578. */
  28579. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28580. /**
  28581. * Set a vec2 in the shader from a Vector2.
  28582. * @param name Define the name of the uniform as defined in the shader
  28583. * @param value Define the value to give to the uniform
  28584. * @return the material itself allowing "fluent" like uniform updates
  28585. */
  28586. setVector2(name: string, value: Vector2): ShaderMaterial;
  28587. /**
  28588. * Set a vec3 in the shader from a Vector3.
  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. setVector3(name: string, value: Vector3): ShaderMaterial;
  28594. /**
  28595. * Set a vec4 in the shader from a Vector4.
  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. setVector4(name: string, value: Vector4): ShaderMaterial;
  28601. /**
  28602. * Set a mat4 in the shader from a Matrix.
  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. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28608. /**
  28609. * Set a float32Array in the shader from a matrix array.
  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. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28615. /**
  28616. * Set a mat3 in the shader from a Float32Array.
  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. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28622. /**
  28623. * Set a mat2 in the shader from a Float32Array.
  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. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28629. /**
  28630. * Set a vec2 array in the shader from a number 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. setArray2(name: string, value: number[]): ShaderMaterial;
  28636. /**
  28637. * Set a vec3 array in the shader from a number array.
  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. setArray3(name: string, value: number[]): ShaderMaterial;
  28643. /**
  28644. * Set a vec4 array in the shader from a number array.
  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. setArray4(name: string, value: number[]): ShaderMaterial;
  28650. private _checkCache;
  28651. /**
  28652. * Specifies that the submesh is ready to be used
  28653. * @param mesh defines the mesh to check
  28654. * @param subMesh defines which submesh to check
  28655. * @param useInstances specifies that instances should be used
  28656. * @returns a boolean indicating that the submesh is ready or not
  28657. */
  28658. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28659. /**
  28660. * Checks if the material is ready to render the requested mesh
  28661. * @param mesh Define the mesh to render
  28662. * @param useInstances Define whether or not the material is used with instances
  28663. * @returns true if ready, otherwise false
  28664. */
  28665. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28666. /**
  28667. * Binds the world matrix to the material
  28668. * @param world defines the world transformation matrix
  28669. * @param effectOverride - If provided, use this effect instead of internal effect
  28670. */
  28671. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28672. /**
  28673. * Binds the submesh to this material by preparing the effect and shader to draw
  28674. * @param world defines the world transformation matrix
  28675. * @param mesh defines the mesh containing the submesh
  28676. * @param subMesh defines the submesh to bind the material to
  28677. */
  28678. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28679. /**
  28680. * Binds the material to the mesh
  28681. * @param world defines the world transformation matrix
  28682. * @param mesh defines the mesh to bind the material to
  28683. * @param effectOverride - If provided, use this effect instead of internal effect
  28684. */
  28685. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  28686. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  28687. /**
  28688. * Gets the active textures from the material
  28689. * @returns an array of textures
  28690. */
  28691. getActiveTextures(): BaseTexture[];
  28692. /**
  28693. * Specifies if the material uses a texture
  28694. * @param texture defines the texture to check against the material
  28695. * @returns a boolean specifying if the material uses the texture
  28696. */
  28697. hasTexture(texture: BaseTexture): boolean;
  28698. /**
  28699. * Makes a duplicate of the material, and gives it a new name
  28700. * @param name defines the new name for the duplicated material
  28701. * @returns the cloned material
  28702. */
  28703. clone(name: string): ShaderMaterial;
  28704. /**
  28705. * Disposes the material
  28706. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28707. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28708. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  28709. */
  28710. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  28711. /**
  28712. * Serializes this material in a JSON representation
  28713. * @returns the serialized material object
  28714. */
  28715. serialize(): any;
  28716. /**
  28717. * Creates a shader material from parsed shader material data
  28718. * @param source defines the JSON represnetation of the material
  28719. * @param scene defines the hosting scene
  28720. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28721. * @returns a new material
  28722. */
  28723. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28724. /**
  28725. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28726. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28727. * @param url defines the url to load from
  28728. * @param scene defines the hosting scene
  28729. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28730. * @returns a promise that will resolve to the new ShaderMaterial
  28731. */
  28732. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28733. /**
  28734. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28735. * @param snippetId defines the snippet to load
  28736. * @param scene defines the hosting scene
  28737. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28738. * @returns a promise that will resolve to the new ShaderMaterial
  28739. */
  28740. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28741. }
  28742. }
  28743. declare module BABYLON {
  28744. /** @hidden */
  28745. export var colorPixelShader: {
  28746. name: string;
  28747. shader: string;
  28748. };
  28749. }
  28750. declare module BABYLON {
  28751. /** @hidden */
  28752. export var colorVertexShader: {
  28753. name: string;
  28754. shader: string;
  28755. };
  28756. }
  28757. declare module BABYLON {
  28758. /**
  28759. * Line mesh
  28760. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28761. */
  28762. export class LinesMesh extends Mesh {
  28763. /**
  28764. * If vertex color should be applied to the mesh
  28765. */
  28766. readonly useVertexColor?: boolean | undefined;
  28767. /**
  28768. * If vertex alpha should be applied to the mesh
  28769. */
  28770. readonly useVertexAlpha?: boolean | undefined;
  28771. /**
  28772. * Color of the line (Default: White)
  28773. */
  28774. color: Color3;
  28775. /**
  28776. * Alpha of the line (Default: 1)
  28777. */
  28778. alpha: number;
  28779. /**
  28780. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28781. * This margin is expressed in world space coordinates, so its value may vary.
  28782. * Default value is 0.1
  28783. */
  28784. intersectionThreshold: number;
  28785. private _colorShader;
  28786. private color4;
  28787. /**
  28788. * Creates a new LinesMesh
  28789. * @param name defines the name
  28790. * @param scene defines the hosting scene
  28791. * @param parent defines the parent mesh if any
  28792. * @param source defines the optional source LinesMesh used to clone data from
  28793. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28794. * When false, achieved by calling a clone(), also passing False.
  28795. * This will make creation of children, recursive.
  28796. * @param useVertexColor defines if this LinesMesh supports vertex color
  28797. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28798. */
  28799. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28800. /**
  28801. * If vertex color should be applied to the mesh
  28802. */
  28803. useVertexColor?: boolean | undefined,
  28804. /**
  28805. * If vertex alpha should be applied to the mesh
  28806. */
  28807. useVertexAlpha?: boolean | undefined);
  28808. private _addClipPlaneDefine;
  28809. private _removeClipPlaneDefine;
  28810. isReady(): boolean;
  28811. /**
  28812. * Returns the string "LineMesh"
  28813. */
  28814. getClassName(): string;
  28815. /**
  28816. * @hidden
  28817. */
  28818. get material(): Material;
  28819. /**
  28820. * @hidden
  28821. */
  28822. set material(value: Material);
  28823. /**
  28824. * @hidden
  28825. */
  28826. get checkCollisions(): boolean;
  28827. set checkCollisions(value: boolean);
  28828. /** @hidden */
  28829. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28830. /** @hidden */
  28831. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28832. /**
  28833. * Disposes of the line mesh
  28834. * @param doNotRecurse If children should be disposed
  28835. */
  28836. dispose(doNotRecurse?: boolean): void;
  28837. /**
  28838. * Returns a new LineMesh object cloned from the current one.
  28839. */
  28840. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28841. /**
  28842. * Creates a new InstancedLinesMesh object from the mesh model.
  28843. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28844. * @param name defines the name of the new instance
  28845. * @returns a new InstancedLinesMesh
  28846. */
  28847. createInstance(name: string): InstancedLinesMesh;
  28848. }
  28849. /**
  28850. * Creates an instance based on a source LinesMesh
  28851. */
  28852. export class InstancedLinesMesh extends InstancedMesh {
  28853. /**
  28854. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28855. * This margin is expressed in world space coordinates, so its value may vary.
  28856. * Initilized with the intersectionThreshold value of the source LinesMesh
  28857. */
  28858. intersectionThreshold: number;
  28859. constructor(name: string, source: LinesMesh);
  28860. /**
  28861. * Returns the string "InstancedLinesMesh".
  28862. */
  28863. getClassName(): string;
  28864. }
  28865. }
  28866. declare module BABYLON {
  28867. /** @hidden */
  28868. export var linePixelShader: {
  28869. name: string;
  28870. shader: string;
  28871. };
  28872. }
  28873. declare module BABYLON {
  28874. /** @hidden */
  28875. export var lineVertexShader: {
  28876. name: string;
  28877. shader: string;
  28878. };
  28879. }
  28880. declare module BABYLON {
  28881. interface Scene {
  28882. /** @hidden */
  28883. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28884. }
  28885. interface AbstractMesh {
  28886. /**
  28887. * Gets the edgesRenderer associated with the mesh
  28888. */
  28889. edgesRenderer: Nullable<EdgesRenderer>;
  28890. }
  28891. interface LinesMesh {
  28892. /**
  28893. * Enables the edge rendering mode on the mesh.
  28894. * This mode makes the mesh edges visible
  28895. * @param epsilon defines the maximal distance between two angles to detect a face
  28896. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28897. * @returns the currentAbstractMesh
  28898. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28899. */
  28900. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28901. }
  28902. interface InstancedLinesMesh {
  28903. /**
  28904. * Enables the edge rendering mode on the mesh.
  28905. * This mode makes the mesh edges visible
  28906. * @param epsilon defines the maximal distance between two angles to detect a face
  28907. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28908. * @returns the current InstancedLinesMesh
  28909. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28910. */
  28911. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28912. }
  28913. /**
  28914. * Defines the minimum contract an Edges renderer should follow.
  28915. */
  28916. export interface IEdgesRenderer extends IDisposable {
  28917. /**
  28918. * Gets or sets a boolean indicating if the edgesRenderer is active
  28919. */
  28920. isEnabled: boolean;
  28921. /**
  28922. * Renders the edges of the attached mesh,
  28923. */
  28924. render(): void;
  28925. /**
  28926. * Checks wether or not the edges renderer is ready to render.
  28927. * @return true if ready, otherwise false.
  28928. */
  28929. isReady(): boolean;
  28930. /**
  28931. * List of instances to render in case the source mesh has instances
  28932. */
  28933. customInstances: SmartArray<Matrix>;
  28934. }
  28935. /**
  28936. * Defines the additional options of the edges renderer
  28937. */
  28938. export interface IEdgesRendererOptions {
  28939. /**
  28940. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28941. * If not defined, the default value is true
  28942. */
  28943. useAlternateEdgeFinder?: boolean;
  28944. /**
  28945. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28946. * If not defined, the default value is true.
  28947. * 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)
  28948. * This option is used only if useAlternateEdgeFinder = true
  28949. */
  28950. useFastVertexMerger?: boolean;
  28951. /**
  28952. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28953. * The default value is 1e-6
  28954. * This option is used only if useAlternateEdgeFinder = true
  28955. */
  28956. epsilonVertexMerge?: number;
  28957. /**
  28958. * 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
  28959. * 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.
  28960. * This option is used only if useAlternateEdgeFinder = true
  28961. */
  28962. applyTessellation?: boolean;
  28963. /**
  28964. * 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
  28965. * The default value is 1e-6
  28966. * This option is used only if useAlternateEdgeFinder = true
  28967. */
  28968. epsilonVertexAligned?: number;
  28969. }
  28970. /**
  28971. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28972. */
  28973. export class EdgesRenderer implements IEdgesRenderer {
  28974. /**
  28975. * Define the size of the edges with an orthographic camera
  28976. */
  28977. edgesWidthScalerForOrthographic: number;
  28978. /**
  28979. * Define the size of the edges with a perspective camera
  28980. */
  28981. edgesWidthScalerForPerspective: number;
  28982. protected _source: AbstractMesh;
  28983. protected _linesPositions: number[];
  28984. protected _linesNormals: number[];
  28985. protected _linesIndices: number[];
  28986. protected _epsilon: number;
  28987. protected _indicesCount: number;
  28988. protected _lineShader: ShaderMaterial;
  28989. protected _ib: DataBuffer;
  28990. protected _buffers: {
  28991. [key: string]: Nullable<VertexBuffer>;
  28992. };
  28993. protected _buffersForInstances: {
  28994. [key: string]: Nullable<VertexBuffer>;
  28995. };
  28996. protected _checkVerticesInsteadOfIndices: boolean;
  28997. protected _options: Nullable<IEdgesRendererOptions>;
  28998. private _meshRebuildObserver;
  28999. private _meshDisposeObserver;
  29000. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29001. isEnabled: boolean;
  29002. /** Gets the vertices generated by the edge renderer */
  29003. get linesPositions(): Immutable<Array<number>>;
  29004. /** Gets the normals generated by the edge renderer */
  29005. get linesNormals(): Immutable<Array<number>>;
  29006. /** Gets the indices generated by the edge renderer */
  29007. get linesIndices(): Immutable<Array<number>>;
  29008. /**
  29009. * List of instances to render in case the source mesh has instances
  29010. */
  29011. customInstances: SmartArray<Matrix>;
  29012. private static GetShader;
  29013. /**
  29014. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29015. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29016. * @param source Mesh used to create edges
  29017. * @param epsilon sum of angles in adjacency to check for edge
  29018. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29019. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29020. * @param options The options to apply when generating the edges
  29021. */
  29022. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29023. protected _prepareRessources(): void;
  29024. /** @hidden */
  29025. _rebuild(): void;
  29026. /**
  29027. * Releases the required resources for the edges renderer
  29028. */
  29029. dispose(): void;
  29030. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29031. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29032. /**
  29033. * Checks if the pair of p0 and p1 is en edge
  29034. * @param faceIndex
  29035. * @param edge
  29036. * @param faceNormals
  29037. * @param p0
  29038. * @param p1
  29039. * @private
  29040. */
  29041. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29042. /**
  29043. * push line into the position, normal and index buffer
  29044. * @protected
  29045. */
  29046. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29047. /**
  29048. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29049. */
  29050. private _tessellateTriangle;
  29051. private _generateEdgesLinesAlternate;
  29052. /**
  29053. * Generates lines edges from adjacencjes
  29054. * @private
  29055. */
  29056. _generateEdgesLines(): void;
  29057. /**
  29058. * Checks wether or not the edges renderer is ready to render.
  29059. * @return true if ready, otherwise false.
  29060. */
  29061. isReady(): boolean;
  29062. /**
  29063. * Renders the edges of the attached mesh,
  29064. */
  29065. render(): void;
  29066. }
  29067. /**
  29068. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29069. */
  29070. export class LineEdgesRenderer extends EdgesRenderer {
  29071. /**
  29072. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29073. * @param source LineMesh used to generate edges
  29074. * @param epsilon not important (specified angle for edge detection)
  29075. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29076. */
  29077. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29078. /**
  29079. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29080. */
  29081. _generateEdgesLines(): void;
  29082. }
  29083. }
  29084. declare module BABYLON {
  29085. /**
  29086. * This represents the object necessary to create a rendering group.
  29087. * This is exclusively used and created by the rendering manager.
  29088. * To modify the behavior, you use the available helpers in your scene or meshes.
  29089. * @hidden
  29090. */
  29091. export class RenderingGroup {
  29092. index: number;
  29093. private static _zeroVector;
  29094. private _scene;
  29095. private _opaqueSubMeshes;
  29096. private _transparentSubMeshes;
  29097. private _alphaTestSubMeshes;
  29098. private _depthOnlySubMeshes;
  29099. private _particleSystems;
  29100. private _spriteManagers;
  29101. private _opaqueSortCompareFn;
  29102. private _alphaTestSortCompareFn;
  29103. private _transparentSortCompareFn;
  29104. private _renderOpaque;
  29105. private _renderAlphaTest;
  29106. private _renderTransparent;
  29107. /** @hidden */
  29108. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29109. onBeforeTransparentRendering: () => void;
  29110. /**
  29111. * Set the opaque sort comparison function.
  29112. * If null the sub meshes will be render in the order they were created
  29113. */
  29114. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29115. /**
  29116. * Set the alpha test sort comparison function.
  29117. * If null the sub meshes will be render in the order they were created
  29118. */
  29119. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29120. /**
  29121. * Set the transparent sort comparison function.
  29122. * If null the sub meshes will be render in the order they were created
  29123. */
  29124. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29125. /**
  29126. * Creates a new rendering group.
  29127. * @param index The rendering group index
  29128. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29129. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29130. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29131. */
  29132. 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>);
  29133. /**
  29134. * Render all the sub meshes contained in the group.
  29135. * @param customRenderFunction Used to override the default render behaviour of the group.
  29136. * @returns true if rendered some submeshes.
  29137. */
  29138. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29139. /**
  29140. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29141. * @param subMeshes The submeshes to render
  29142. */
  29143. private renderOpaqueSorted;
  29144. /**
  29145. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29146. * @param subMeshes The submeshes to render
  29147. */
  29148. private renderAlphaTestSorted;
  29149. /**
  29150. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29151. * @param subMeshes The submeshes to render
  29152. */
  29153. private renderTransparentSorted;
  29154. /**
  29155. * Renders the submeshes in a specified order.
  29156. * @param subMeshes The submeshes to sort before render
  29157. * @param sortCompareFn The comparison function use to sort
  29158. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29159. * @param transparent Specifies to activate blending if true
  29160. */
  29161. private static renderSorted;
  29162. /**
  29163. * Renders the submeshes in the order they were dispatched (no sort applied).
  29164. * @param subMeshes The submeshes to render
  29165. */
  29166. private static renderUnsorted;
  29167. /**
  29168. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29169. * are rendered back to front if in the same alpha index.
  29170. *
  29171. * @param a The first submesh
  29172. * @param b The second submesh
  29173. * @returns The result of the comparison
  29174. */
  29175. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29176. /**
  29177. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29178. * are rendered back to front.
  29179. *
  29180. * @param a The first submesh
  29181. * @param b The second submesh
  29182. * @returns The result of the comparison
  29183. */
  29184. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29185. /**
  29186. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29187. * are rendered front to back (prevent overdraw).
  29188. *
  29189. * @param a The first submesh
  29190. * @param b The second submesh
  29191. * @returns The result of the comparison
  29192. */
  29193. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29194. /**
  29195. * Resets the different lists of submeshes to prepare a new frame.
  29196. */
  29197. prepare(): void;
  29198. dispose(): void;
  29199. /**
  29200. * Inserts the submesh in its correct queue depending on its material.
  29201. * @param subMesh The submesh to dispatch
  29202. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29203. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29204. */
  29205. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29206. dispatchSprites(spriteManager: ISpriteManager): void;
  29207. dispatchParticles(particleSystem: IParticleSystem): void;
  29208. private _renderParticles;
  29209. private _renderSprites;
  29210. }
  29211. }
  29212. declare module BABYLON {
  29213. /**
  29214. * Interface describing the different options available in the rendering manager
  29215. * regarding Auto Clear between groups.
  29216. */
  29217. export interface IRenderingManagerAutoClearSetup {
  29218. /**
  29219. * Defines whether or not autoclear is enable.
  29220. */
  29221. autoClear: boolean;
  29222. /**
  29223. * Defines whether or not to autoclear the depth buffer.
  29224. */
  29225. depth: boolean;
  29226. /**
  29227. * Defines whether or not to autoclear the stencil buffer.
  29228. */
  29229. stencil: boolean;
  29230. }
  29231. /**
  29232. * This class is used by the onRenderingGroupObservable
  29233. */
  29234. export class RenderingGroupInfo {
  29235. /**
  29236. * The Scene that being rendered
  29237. */
  29238. scene: Scene;
  29239. /**
  29240. * The camera currently used for the rendering pass
  29241. */
  29242. camera: Nullable<Camera>;
  29243. /**
  29244. * The ID of the renderingGroup being processed
  29245. */
  29246. renderingGroupId: number;
  29247. }
  29248. /**
  29249. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29250. * It is enable to manage the different groups as well as the different necessary sort functions.
  29251. * This should not be used directly aside of the few static configurations
  29252. */
  29253. export class RenderingManager {
  29254. /**
  29255. * The max id used for rendering groups (not included)
  29256. */
  29257. static MAX_RENDERINGGROUPS: number;
  29258. /**
  29259. * The min id used for rendering groups (included)
  29260. */
  29261. static MIN_RENDERINGGROUPS: number;
  29262. /**
  29263. * Used to globally prevent autoclearing scenes.
  29264. */
  29265. static AUTOCLEAR: boolean;
  29266. /**
  29267. * @hidden
  29268. */
  29269. _useSceneAutoClearSetup: boolean;
  29270. private _scene;
  29271. private _renderingGroups;
  29272. private _depthStencilBufferAlreadyCleaned;
  29273. private _autoClearDepthStencil;
  29274. private _customOpaqueSortCompareFn;
  29275. private _customAlphaTestSortCompareFn;
  29276. private _customTransparentSortCompareFn;
  29277. private _renderingGroupInfo;
  29278. /**
  29279. * Instantiates a new rendering group for a particular scene
  29280. * @param scene Defines the scene the groups belongs to
  29281. */
  29282. constructor(scene: Scene);
  29283. private _clearDepthStencilBuffer;
  29284. /**
  29285. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29286. * @hidden
  29287. */
  29288. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29289. /**
  29290. * Resets the different information of the group to prepare a new frame
  29291. * @hidden
  29292. */
  29293. reset(): void;
  29294. /**
  29295. * Dispose and release the group and its associated resources.
  29296. * @hidden
  29297. */
  29298. dispose(): void;
  29299. /**
  29300. * Clear the info related to rendering groups preventing retention points during dispose.
  29301. */
  29302. freeRenderingGroups(): void;
  29303. private _prepareRenderingGroup;
  29304. /**
  29305. * Add a sprite manager to the rendering manager in order to render it this frame.
  29306. * @param spriteManager Define the sprite manager to render
  29307. */
  29308. dispatchSprites(spriteManager: ISpriteManager): void;
  29309. /**
  29310. * Add a particle system to the rendering manager in order to render it this frame.
  29311. * @param particleSystem Define the particle system to render
  29312. */
  29313. dispatchParticles(particleSystem: IParticleSystem): void;
  29314. /**
  29315. * Add a submesh to the manager in order to render it this frame
  29316. * @param subMesh The submesh to dispatch
  29317. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29318. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29319. */
  29320. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29321. /**
  29322. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29323. * This allowed control for front to back rendering or reversly depending of the special needs.
  29324. *
  29325. * @param renderingGroupId The rendering group id corresponding to its index
  29326. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29327. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29328. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29329. */
  29330. 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;
  29331. /**
  29332. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29333. *
  29334. * @param renderingGroupId The rendering group id corresponding to its index
  29335. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29336. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29337. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29338. */
  29339. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29340. /**
  29341. * Gets the current auto clear configuration for one rendering group of the rendering
  29342. * manager.
  29343. * @param index the rendering group index to get the information for
  29344. * @returns The auto clear setup for the requested rendering group
  29345. */
  29346. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29347. }
  29348. }
  29349. declare module BABYLON {
  29350. /**
  29351. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29352. */
  29353. export interface ICustomShaderOptions {
  29354. /**
  29355. * Gets or sets the custom shader name to use
  29356. */
  29357. shaderName: string;
  29358. /**
  29359. * The list of attribute names used in the shader
  29360. */
  29361. attributes?: string[];
  29362. /**
  29363. * The list of unifrom names used in the shader
  29364. */
  29365. uniforms?: string[];
  29366. /**
  29367. * The list of sampler names used in the shader
  29368. */
  29369. samplers?: string[];
  29370. /**
  29371. * The list of defines used in the shader
  29372. */
  29373. defines?: string[];
  29374. }
  29375. /**
  29376. * Interface to implement to create a shadow generator compatible with BJS.
  29377. */
  29378. export interface IShadowGenerator {
  29379. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29380. id: string;
  29381. /**
  29382. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29383. * @returns The render target texture if present otherwise, null
  29384. */
  29385. getShadowMap(): Nullable<RenderTargetTexture>;
  29386. /**
  29387. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29388. * @param subMesh The submesh we want to render in the shadow map
  29389. * @param useInstances Defines wether will draw in the map using instances
  29390. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29391. * @returns true if ready otherwise, false
  29392. */
  29393. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29394. /**
  29395. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29396. * @param defines Defines of the material we want to update
  29397. * @param lightIndex Index of the light in the enabled light list of the material
  29398. */
  29399. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29400. /**
  29401. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29402. * defined in the generator but impacting the effect).
  29403. * It implies the unifroms available on the materials are the standard BJS ones.
  29404. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29405. * @param effect The effect we are binfing the information for
  29406. */
  29407. bindShadowLight(lightIndex: string, effect: Effect): void;
  29408. /**
  29409. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29410. * (eq to shadow prjection matrix * light transform matrix)
  29411. * @returns The transform matrix used to create the shadow map
  29412. */
  29413. getTransformMatrix(): Matrix;
  29414. /**
  29415. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29416. * Cube and 2D textures for instance.
  29417. */
  29418. recreateShadowMap(): void;
  29419. /**
  29420. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29421. * @param onCompiled Callback triggered at the and of the effects compilation
  29422. * @param options Sets of optional options forcing the compilation with different modes
  29423. */
  29424. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29425. useInstances: boolean;
  29426. }>): void;
  29427. /**
  29428. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29429. * @param options Sets of optional options forcing the compilation with different modes
  29430. * @returns A promise that resolves when the compilation completes
  29431. */
  29432. forceCompilationAsync(options?: Partial<{
  29433. useInstances: boolean;
  29434. }>): Promise<void>;
  29435. /**
  29436. * Serializes the shadow generator setup to a json object.
  29437. * @returns The serialized JSON object
  29438. */
  29439. serialize(): any;
  29440. /**
  29441. * Disposes the Shadow map and related Textures and effects.
  29442. */
  29443. dispose(): void;
  29444. }
  29445. /**
  29446. * Default implementation IShadowGenerator.
  29447. * This is the main object responsible of generating shadows in the framework.
  29448. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29449. */
  29450. export class ShadowGenerator implements IShadowGenerator {
  29451. private static _Counter;
  29452. /**
  29453. * Name of the shadow generator class
  29454. */
  29455. static CLASSNAME: string;
  29456. /**
  29457. * Shadow generator mode None: no filtering applied.
  29458. */
  29459. static readonly FILTER_NONE: number;
  29460. /**
  29461. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29462. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29463. */
  29464. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29465. /**
  29466. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29467. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29468. */
  29469. static readonly FILTER_POISSONSAMPLING: number;
  29470. /**
  29471. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29472. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29473. */
  29474. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29475. /**
  29476. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29477. * edge artifacts on steep falloff.
  29478. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29479. */
  29480. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29481. /**
  29482. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29483. * edge artifacts on steep falloff.
  29484. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29485. */
  29486. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29487. /**
  29488. * Shadow generator mode PCF: Percentage Closer Filtering
  29489. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29490. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29491. */
  29492. static readonly FILTER_PCF: number;
  29493. /**
  29494. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29495. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29496. * Contact Hardening
  29497. */
  29498. static readonly FILTER_PCSS: number;
  29499. /**
  29500. * Reserved for PCF and PCSS
  29501. * Highest Quality.
  29502. *
  29503. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29504. *
  29505. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29506. */
  29507. static readonly QUALITY_HIGH: number;
  29508. /**
  29509. * Reserved for PCF and PCSS
  29510. * Good tradeoff for quality/perf cross devices
  29511. *
  29512. * Execute PCF on a 3*3 kernel.
  29513. *
  29514. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29515. */
  29516. static readonly QUALITY_MEDIUM: number;
  29517. /**
  29518. * Reserved for PCF and PCSS
  29519. * The lowest quality but the fastest.
  29520. *
  29521. * Execute PCF on a 1*1 kernel.
  29522. *
  29523. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29524. */
  29525. static readonly QUALITY_LOW: number;
  29526. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29527. id: string;
  29528. /** Gets or sets the custom shader name to use */
  29529. customShaderOptions: ICustomShaderOptions;
  29530. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29531. customAllowRendering: (subMesh: SubMesh) => boolean;
  29532. /**
  29533. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29534. */
  29535. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29536. /**
  29537. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29538. */
  29539. onAfterShadowMapRenderObservable: Observable<Effect>;
  29540. /**
  29541. * Observable triggered before a mesh is rendered in the shadow map.
  29542. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29543. */
  29544. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29545. /**
  29546. * Observable triggered after a mesh is rendered in the shadow map.
  29547. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29548. */
  29549. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29550. protected _bias: number;
  29551. /**
  29552. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29553. */
  29554. get bias(): number;
  29555. /**
  29556. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29557. */
  29558. set bias(bias: number);
  29559. protected _normalBias: number;
  29560. /**
  29561. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29562. */
  29563. get normalBias(): number;
  29564. /**
  29565. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29566. */
  29567. set normalBias(normalBias: number);
  29568. protected _blurBoxOffset: number;
  29569. /**
  29570. * Gets the blur box offset: offset applied during the blur pass.
  29571. * Only useful if useKernelBlur = false
  29572. */
  29573. get blurBoxOffset(): number;
  29574. /**
  29575. * Sets the blur box offset: offset applied during the blur pass.
  29576. * Only useful if useKernelBlur = false
  29577. */
  29578. set blurBoxOffset(value: number);
  29579. protected _blurScale: number;
  29580. /**
  29581. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29582. * 2 means half of the size.
  29583. */
  29584. get blurScale(): number;
  29585. /**
  29586. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29587. * 2 means half of the size.
  29588. */
  29589. set blurScale(value: number);
  29590. protected _blurKernel: number;
  29591. /**
  29592. * Gets the blur kernel: kernel size of the blur pass.
  29593. * Only useful if useKernelBlur = true
  29594. */
  29595. get blurKernel(): number;
  29596. /**
  29597. * Sets the blur kernel: kernel size of the blur pass.
  29598. * Only useful if useKernelBlur = true
  29599. */
  29600. set blurKernel(value: number);
  29601. protected _useKernelBlur: boolean;
  29602. /**
  29603. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29604. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29605. */
  29606. get useKernelBlur(): boolean;
  29607. /**
  29608. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29609. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29610. */
  29611. set useKernelBlur(value: boolean);
  29612. protected _depthScale: number;
  29613. /**
  29614. * Gets the depth scale used in ESM mode.
  29615. */
  29616. get depthScale(): number;
  29617. /**
  29618. * Sets the depth scale used in ESM mode.
  29619. * This can override the scale stored on the light.
  29620. */
  29621. set depthScale(value: number);
  29622. protected _validateFilter(filter: number): number;
  29623. protected _filter: number;
  29624. /**
  29625. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29626. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29627. */
  29628. get filter(): number;
  29629. /**
  29630. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29631. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29632. */
  29633. set filter(value: number);
  29634. /**
  29635. * Gets if the current filter is set to Poisson Sampling.
  29636. */
  29637. get usePoissonSampling(): boolean;
  29638. /**
  29639. * Sets the current filter to Poisson Sampling.
  29640. */
  29641. set usePoissonSampling(value: boolean);
  29642. /**
  29643. * Gets if the current filter is set to ESM.
  29644. */
  29645. get useExponentialShadowMap(): boolean;
  29646. /**
  29647. * Sets the current filter is to ESM.
  29648. */
  29649. set useExponentialShadowMap(value: boolean);
  29650. /**
  29651. * Gets if the current filter is set to filtered ESM.
  29652. */
  29653. get useBlurExponentialShadowMap(): boolean;
  29654. /**
  29655. * Gets if the current filter is set to filtered ESM.
  29656. */
  29657. set useBlurExponentialShadowMap(value: boolean);
  29658. /**
  29659. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29660. * exponential to prevent steep falloff artifacts).
  29661. */
  29662. get useCloseExponentialShadowMap(): boolean;
  29663. /**
  29664. * Sets the current filter to "close ESM" (using the inverse of the
  29665. * exponential to prevent steep falloff artifacts).
  29666. */
  29667. set useCloseExponentialShadowMap(value: boolean);
  29668. /**
  29669. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29670. * exponential to prevent steep falloff artifacts).
  29671. */
  29672. get useBlurCloseExponentialShadowMap(): boolean;
  29673. /**
  29674. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29675. * exponential to prevent steep falloff artifacts).
  29676. */
  29677. set useBlurCloseExponentialShadowMap(value: boolean);
  29678. /**
  29679. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29680. */
  29681. get usePercentageCloserFiltering(): boolean;
  29682. /**
  29683. * Sets the current filter to "PCF" (percentage closer filtering).
  29684. */
  29685. set usePercentageCloserFiltering(value: boolean);
  29686. protected _filteringQuality: number;
  29687. /**
  29688. * Gets the PCF or PCSS Quality.
  29689. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29690. */
  29691. get filteringQuality(): number;
  29692. /**
  29693. * Sets the PCF or PCSS Quality.
  29694. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29695. */
  29696. set filteringQuality(filteringQuality: number);
  29697. /**
  29698. * Gets if the current filter is set to "PCSS" (contact hardening).
  29699. */
  29700. get useContactHardeningShadow(): boolean;
  29701. /**
  29702. * Sets the current filter to "PCSS" (contact hardening).
  29703. */
  29704. set useContactHardeningShadow(value: boolean);
  29705. protected _contactHardeningLightSizeUVRatio: number;
  29706. /**
  29707. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29708. * Using a ratio helps keeping shape stability independently of the map size.
  29709. *
  29710. * It does not account for the light projection as it was having too much
  29711. * instability during the light setup or during light position changes.
  29712. *
  29713. * Only valid if useContactHardeningShadow is true.
  29714. */
  29715. get contactHardeningLightSizeUVRatio(): number;
  29716. /**
  29717. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29718. * Using a ratio helps keeping shape stability independently of the map size.
  29719. *
  29720. * It does not account for the light projection as it was having too much
  29721. * instability during the light setup or during light position changes.
  29722. *
  29723. * Only valid if useContactHardeningShadow is true.
  29724. */
  29725. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29726. protected _darkness: number;
  29727. /** Gets or sets the actual darkness of a shadow */
  29728. get darkness(): number;
  29729. set darkness(value: number);
  29730. /**
  29731. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29732. * 0 means strongest and 1 would means no shadow.
  29733. * @returns the darkness.
  29734. */
  29735. getDarkness(): number;
  29736. /**
  29737. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29738. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29739. * @returns the shadow generator allowing fluent coding.
  29740. */
  29741. setDarkness(darkness: number): ShadowGenerator;
  29742. protected _transparencyShadow: boolean;
  29743. /** Gets or sets the ability to have transparent shadow */
  29744. get transparencyShadow(): boolean;
  29745. set transparencyShadow(value: boolean);
  29746. /**
  29747. * Sets the ability to have transparent shadow (boolean).
  29748. * @param transparent True if transparent else False
  29749. * @returns the shadow generator allowing fluent coding
  29750. */
  29751. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29752. /**
  29753. * Enables or disables shadows with varying strength based on the transparency
  29754. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29755. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29756. * mesh.visibility * alphaTexture.a
  29757. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29758. */
  29759. enableSoftTransparentShadow: boolean;
  29760. protected _shadowMap: Nullable<RenderTargetTexture>;
  29761. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29762. /**
  29763. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29764. * @returns The render target texture if present otherwise, null
  29765. */
  29766. getShadowMap(): Nullable<RenderTargetTexture>;
  29767. /**
  29768. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29769. * @returns The render target texture if the shadow map is present otherwise, null
  29770. */
  29771. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29772. /**
  29773. * Gets the class name of that object
  29774. * @returns "ShadowGenerator"
  29775. */
  29776. getClassName(): string;
  29777. /**
  29778. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29779. * @param mesh Mesh to add
  29780. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29781. * @returns the Shadow Generator itself
  29782. */
  29783. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29784. /**
  29785. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29786. * @param mesh Mesh to remove
  29787. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29788. * @returns the Shadow Generator itself
  29789. */
  29790. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29791. /**
  29792. * Controls the extent to which the shadows fade out at the edge of the frustum
  29793. */
  29794. frustumEdgeFalloff: number;
  29795. protected _light: IShadowLight;
  29796. /**
  29797. * Returns the associated light object.
  29798. * @returns the light generating the shadow
  29799. */
  29800. getLight(): IShadowLight;
  29801. /**
  29802. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29803. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29804. * It might on the other hand introduce peter panning.
  29805. */
  29806. forceBackFacesOnly: boolean;
  29807. protected _scene: Scene;
  29808. protected _lightDirection: Vector3;
  29809. protected _viewMatrix: Matrix;
  29810. protected _projectionMatrix: Matrix;
  29811. protected _transformMatrix: Matrix;
  29812. protected _cachedPosition: Vector3;
  29813. protected _cachedDirection: Vector3;
  29814. protected _cachedDefines: string;
  29815. protected _currentRenderID: number;
  29816. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29817. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29818. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29819. protected _blurPostProcesses: PostProcess[];
  29820. protected _mapSize: number;
  29821. protected _currentFaceIndex: number;
  29822. protected _currentFaceIndexCache: number;
  29823. protected _textureType: number;
  29824. protected _defaultTextureMatrix: Matrix;
  29825. protected _storedUniqueId: Nullable<number>;
  29826. protected _nameForCustomEffect: string;
  29827. /** @hidden */
  29828. static _SceneComponentInitialization: (scene: Scene) => void;
  29829. /**
  29830. * Gets or sets the size of the texture what stores the shadows
  29831. */
  29832. get mapSize(): number;
  29833. set mapSize(size: number);
  29834. /**
  29835. * Creates a ShadowGenerator object.
  29836. * A ShadowGenerator is the required tool to use the shadows.
  29837. * Each light casting shadows needs to use its own ShadowGenerator.
  29838. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29839. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29840. * @param light The light object generating the shadows.
  29841. * @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.
  29842. */
  29843. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29844. protected _initializeGenerator(): void;
  29845. protected _createTargetRenderTexture(): void;
  29846. protected _initializeShadowMap(): void;
  29847. protected _initializeBlurRTTAndPostProcesses(): void;
  29848. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29849. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29850. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29851. protected _applyFilterValues(): void;
  29852. /**
  29853. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29854. * @param onCompiled Callback triggered at the and of the effects compilation
  29855. * @param options Sets of optional options forcing the compilation with different modes
  29856. */
  29857. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29858. useInstances: boolean;
  29859. }>): void;
  29860. /**
  29861. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29862. * @param options Sets of optional options forcing the compilation with different modes
  29863. * @returns A promise that resolves when the compilation completes
  29864. */
  29865. forceCompilationAsync(options?: Partial<{
  29866. useInstances: boolean;
  29867. }>): Promise<void>;
  29868. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29869. private _prepareShadowDefines;
  29870. /**
  29871. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29872. * @param subMesh The submesh we want to render in the shadow map
  29873. * @param useInstances Defines wether will draw in the map using instances
  29874. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29875. * @returns true if ready otherwise, false
  29876. */
  29877. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29878. /**
  29879. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29880. * @param defines Defines of the material we want to update
  29881. * @param lightIndex Index of the light in the enabled light list of the material
  29882. */
  29883. prepareDefines(defines: any, lightIndex: number): void;
  29884. /**
  29885. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29886. * defined in the generator but impacting the effect).
  29887. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29888. * @param effect The effect we are binfing the information for
  29889. */
  29890. bindShadowLight(lightIndex: string, effect: Effect): void;
  29891. /**
  29892. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29893. * (eq to shadow prjection matrix * light transform matrix)
  29894. * @returns The transform matrix used to create the shadow map
  29895. */
  29896. getTransformMatrix(): Matrix;
  29897. /**
  29898. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29899. * Cube and 2D textures for instance.
  29900. */
  29901. recreateShadowMap(): void;
  29902. protected _disposeBlurPostProcesses(): void;
  29903. protected _disposeRTTandPostProcesses(): void;
  29904. /**
  29905. * Disposes the ShadowGenerator.
  29906. * Returns nothing.
  29907. */
  29908. dispose(): void;
  29909. /**
  29910. * Serializes the shadow generator setup to a json object.
  29911. * @returns The serialized JSON object
  29912. */
  29913. serialize(): any;
  29914. /**
  29915. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29916. * @param parsedShadowGenerator The JSON object to parse
  29917. * @param scene The scene to create the shadow map for
  29918. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29919. * @returns The parsed shadow generator
  29920. */
  29921. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29922. }
  29923. }
  29924. declare module BABYLON {
  29925. /**
  29926. * Options to be used when creating a shadow depth material
  29927. */
  29928. export interface IIOptionShadowDepthMaterial {
  29929. /** Variables in the vertex shader code that need to have their names remapped.
  29930. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29931. * "var_name" should be either: worldPos or vNormalW
  29932. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29933. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29934. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29935. */
  29936. remappedVariables?: string[];
  29937. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29938. standalone?: boolean;
  29939. }
  29940. /**
  29941. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29942. */
  29943. export class ShadowDepthWrapper {
  29944. private _scene;
  29945. private _options?;
  29946. private _baseMaterial;
  29947. private _onEffectCreatedObserver;
  29948. private _subMeshToEffect;
  29949. private _subMeshToDepthEffect;
  29950. private _meshes;
  29951. /** @hidden */
  29952. _matriceNames: any;
  29953. /** Gets the standalone status of the wrapper */
  29954. get standalone(): boolean;
  29955. /** Gets the base material the wrapper is built upon */
  29956. get baseMaterial(): Material;
  29957. /**
  29958. * Instantiate a new shadow depth wrapper.
  29959. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29960. * generate the shadow depth map. For more information, please refer to the documentation:
  29961. * https://doc.babylonjs.com/babylon101/shadows
  29962. * @param baseMaterial Material to wrap
  29963. * @param scene Define the scene the material belongs to
  29964. * @param options Options used to create the wrapper
  29965. */
  29966. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29967. /**
  29968. * Gets the effect to use to generate the depth map
  29969. * @param subMesh subMesh to get the effect for
  29970. * @param shadowGenerator shadow generator to get the effect for
  29971. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29972. */
  29973. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29974. /**
  29975. * Specifies that the submesh is ready to be used for depth rendering
  29976. * @param subMesh submesh to check
  29977. * @param defines the list of defines to take into account when checking the effect
  29978. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29979. * @param useInstances specifies that instances should be used
  29980. * @returns a boolean indicating that the submesh is ready or not
  29981. */
  29982. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29983. /**
  29984. * Disposes the resources
  29985. */
  29986. dispose(): void;
  29987. private _makeEffect;
  29988. }
  29989. }
  29990. declare module BABYLON {
  29991. /**
  29992. * Options for compiling materials.
  29993. */
  29994. export interface IMaterialCompilationOptions {
  29995. /**
  29996. * Defines whether clip planes are enabled.
  29997. */
  29998. clipPlane: boolean;
  29999. /**
  30000. * Defines whether instances are enabled.
  30001. */
  30002. useInstances: boolean;
  30003. }
  30004. /**
  30005. * Options passed when calling customShaderNameResolve
  30006. */
  30007. export interface ICustomShaderNameResolveOptions {
  30008. /**
  30009. * 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
  30010. */
  30011. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30012. }
  30013. /**
  30014. * Base class for the main features of a material in Babylon.js
  30015. */
  30016. export class Material implements IAnimatable {
  30017. /**
  30018. * Returns the triangle fill mode
  30019. */
  30020. static readonly TriangleFillMode: number;
  30021. /**
  30022. * Returns the wireframe mode
  30023. */
  30024. static readonly WireFrameFillMode: number;
  30025. /**
  30026. * Returns the point fill mode
  30027. */
  30028. static readonly PointFillMode: number;
  30029. /**
  30030. * Returns the point list draw mode
  30031. */
  30032. static readonly PointListDrawMode: number;
  30033. /**
  30034. * Returns the line list draw mode
  30035. */
  30036. static readonly LineListDrawMode: number;
  30037. /**
  30038. * Returns the line loop draw mode
  30039. */
  30040. static readonly LineLoopDrawMode: number;
  30041. /**
  30042. * Returns the line strip draw mode
  30043. */
  30044. static readonly LineStripDrawMode: number;
  30045. /**
  30046. * Returns the triangle strip draw mode
  30047. */
  30048. static readonly TriangleStripDrawMode: number;
  30049. /**
  30050. * Returns the triangle fan draw mode
  30051. */
  30052. static readonly TriangleFanDrawMode: number;
  30053. /**
  30054. * Stores the clock-wise side orientation
  30055. */
  30056. static readonly ClockWiseSideOrientation: number;
  30057. /**
  30058. * Stores the counter clock-wise side orientation
  30059. */
  30060. static readonly CounterClockWiseSideOrientation: number;
  30061. /**
  30062. * The dirty texture flag value
  30063. */
  30064. static readonly TextureDirtyFlag: number;
  30065. /**
  30066. * The dirty light flag value
  30067. */
  30068. static readonly LightDirtyFlag: number;
  30069. /**
  30070. * The dirty fresnel flag value
  30071. */
  30072. static readonly FresnelDirtyFlag: number;
  30073. /**
  30074. * The dirty attribute flag value
  30075. */
  30076. static readonly AttributesDirtyFlag: number;
  30077. /**
  30078. * The dirty misc flag value
  30079. */
  30080. static readonly MiscDirtyFlag: number;
  30081. /**
  30082. * The dirty prepass flag value
  30083. */
  30084. static readonly PrePassDirtyFlag: number;
  30085. /**
  30086. * The all dirty flag value
  30087. */
  30088. static readonly AllDirtyFlag: number;
  30089. /**
  30090. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30091. */
  30092. static readonly MATERIAL_OPAQUE: number;
  30093. /**
  30094. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30095. */
  30096. static readonly MATERIAL_ALPHATEST: number;
  30097. /**
  30098. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30099. */
  30100. static readonly MATERIAL_ALPHABLEND: number;
  30101. /**
  30102. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30103. * They are also discarded below the alpha cutoff threshold to improve performances.
  30104. */
  30105. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30106. /**
  30107. * The Whiteout method is used to blend normals.
  30108. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30109. */
  30110. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30111. /**
  30112. * The Reoriented Normal Mapping method is used to blend normals.
  30113. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30114. */
  30115. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30116. /**
  30117. * Custom callback helping to override the default shader used in the material.
  30118. */
  30119. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30120. /**
  30121. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30122. */
  30123. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30124. /**
  30125. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30126. * This means that the material can keep using a previous shader while a new one is being compiled.
  30127. * This is mostly used when shader parallel compilation is supported (true by default)
  30128. */
  30129. allowShaderHotSwapping: boolean;
  30130. /**
  30131. * The ID of the material
  30132. */
  30133. id: string;
  30134. /**
  30135. * Gets or sets the unique id of the material
  30136. */
  30137. uniqueId: number;
  30138. /**
  30139. * The name of the material
  30140. */
  30141. name: string;
  30142. /**
  30143. * Gets or sets user defined metadata
  30144. */
  30145. metadata: any;
  30146. /**
  30147. * For internal use only. Please do not use.
  30148. */
  30149. reservedDataStore: any;
  30150. /**
  30151. * Specifies if the ready state should be checked on each call
  30152. */
  30153. checkReadyOnEveryCall: boolean;
  30154. /**
  30155. * Specifies if the ready state should be checked once
  30156. */
  30157. checkReadyOnlyOnce: boolean;
  30158. /**
  30159. * The state of the material
  30160. */
  30161. state: string;
  30162. /**
  30163. * If the material can be rendered to several textures with MRT extension
  30164. */
  30165. get canRenderToMRT(): boolean;
  30166. /**
  30167. * The alpha value of the material
  30168. */
  30169. protected _alpha: number;
  30170. /**
  30171. * List of inspectable custom properties (used by the Inspector)
  30172. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30173. */
  30174. inspectableCustomProperties: IInspectable[];
  30175. /**
  30176. * Sets the alpha value of the material
  30177. */
  30178. set alpha(value: number);
  30179. /**
  30180. * Gets the alpha value of the material
  30181. */
  30182. get alpha(): number;
  30183. /**
  30184. * Specifies if back face culling is enabled
  30185. */
  30186. protected _backFaceCulling: boolean;
  30187. /**
  30188. * Sets the back-face culling state
  30189. */
  30190. set backFaceCulling(value: boolean);
  30191. /**
  30192. * Gets the back-face culling state
  30193. */
  30194. get backFaceCulling(): boolean;
  30195. /**
  30196. * Stores the value for side orientation
  30197. */
  30198. sideOrientation: number;
  30199. /**
  30200. * Callback triggered when the material is compiled
  30201. */
  30202. onCompiled: Nullable<(effect: Effect) => void>;
  30203. /**
  30204. * Callback triggered when an error occurs
  30205. */
  30206. onError: Nullable<(effect: Effect, errors: string) => void>;
  30207. /**
  30208. * Callback triggered to get the render target textures
  30209. */
  30210. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30211. /**
  30212. * Gets a boolean indicating that current material needs to register RTT
  30213. */
  30214. get hasRenderTargetTextures(): boolean;
  30215. /**
  30216. * Specifies if the material should be serialized
  30217. */
  30218. doNotSerialize: boolean;
  30219. /**
  30220. * @hidden
  30221. */
  30222. _storeEffectOnSubMeshes: boolean;
  30223. /**
  30224. * Stores the animations for the material
  30225. */
  30226. animations: Nullable<Array<Animation>>;
  30227. /**
  30228. * An event triggered when the material is disposed
  30229. */
  30230. onDisposeObservable: Observable<Material>;
  30231. /**
  30232. * An observer which watches for dispose events
  30233. */
  30234. private _onDisposeObserver;
  30235. private _onUnBindObservable;
  30236. /**
  30237. * Called during a dispose event
  30238. */
  30239. set onDispose(callback: () => void);
  30240. private _onBindObservable;
  30241. /**
  30242. * An event triggered when the material is bound
  30243. */
  30244. get onBindObservable(): Observable<AbstractMesh>;
  30245. /**
  30246. * An observer which watches for bind events
  30247. */
  30248. private _onBindObserver;
  30249. /**
  30250. * Called during a bind event
  30251. */
  30252. set onBind(callback: (Mesh: AbstractMesh) => void);
  30253. /**
  30254. * An event triggered when the material is unbound
  30255. */
  30256. get onUnBindObservable(): Observable<Material>;
  30257. protected _onEffectCreatedObservable: Nullable<Observable<{
  30258. effect: Effect;
  30259. subMesh: Nullable<SubMesh>;
  30260. }>>;
  30261. /**
  30262. * An event triggered when the effect is (re)created
  30263. */
  30264. get onEffectCreatedObservable(): Observable<{
  30265. effect: Effect;
  30266. subMesh: Nullable<SubMesh>;
  30267. }>;
  30268. /**
  30269. * Stores the value of the alpha mode
  30270. */
  30271. private _alphaMode;
  30272. /**
  30273. * Sets the value of the alpha mode.
  30274. *
  30275. * | Value | Type | Description |
  30276. * | --- | --- | --- |
  30277. * | 0 | ALPHA_DISABLE | |
  30278. * | 1 | ALPHA_ADD | |
  30279. * | 2 | ALPHA_COMBINE | |
  30280. * | 3 | ALPHA_SUBTRACT | |
  30281. * | 4 | ALPHA_MULTIPLY | |
  30282. * | 5 | ALPHA_MAXIMIZED | |
  30283. * | 6 | ALPHA_ONEONE | |
  30284. * | 7 | ALPHA_PREMULTIPLIED | |
  30285. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30286. * | 9 | ALPHA_INTERPOLATE | |
  30287. * | 10 | ALPHA_SCREENMODE | |
  30288. *
  30289. */
  30290. set alphaMode(value: number);
  30291. /**
  30292. * Gets the value of the alpha mode
  30293. */
  30294. get alphaMode(): number;
  30295. /**
  30296. * Stores the state of the need depth pre-pass value
  30297. */
  30298. private _needDepthPrePass;
  30299. /**
  30300. * Sets the need depth pre-pass value
  30301. */
  30302. set needDepthPrePass(value: boolean);
  30303. /**
  30304. * Gets the depth pre-pass value
  30305. */
  30306. get needDepthPrePass(): boolean;
  30307. /**
  30308. * Specifies if depth writing should be disabled
  30309. */
  30310. disableDepthWrite: boolean;
  30311. /**
  30312. * Specifies if color writing should be disabled
  30313. */
  30314. disableColorWrite: boolean;
  30315. /**
  30316. * Specifies if depth writing should be forced
  30317. */
  30318. forceDepthWrite: boolean;
  30319. /**
  30320. * Specifies the depth function that should be used. 0 means the default engine function
  30321. */
  30322. depthFunction: number;
  30323. /**
  30324. * Specifies if there should be a separate pass for culling
  30325. */
  30326. separateCullingPass: boolean;
  30327. /**
  30328. * Stores the state specifing if fog should be enabled
  30329. */
  30330. private _fogEnabled;
  30331. /**
  30332. * Sets the state for enabling fog
  30333. */
  30334. set fogEnabled(value: boolean);
  30335. /**
  30336. * Gets the value of the fog enabled state
  30337. */
  30338. get fogEnabled(): boolean;
  30339. /**
  30340. * Stores the size of points
  30341. */
  30342. pointSize: number;
  30343. /**
  30344. * Stores the z offset value
  30345. */
  30346. zOffset: number;
  30347. get wireframe(): boolean;
  30348. /**
  30349. * Sets the state of wireframe mode
  30350. */
  30351. set wireframe(value: boolean);
  30352. /**
  30353. * Gets the value specifying if point clouds are enabled
  30354. */
  30355. get pointsCloud(): boolean;
  30356. /**
  30357. * Sets the state of point cloud mode
  30358. */
  30359. set pointsCloud(value: boolean);
  30360. /**
  30361. * Gets the material fill mode
  30362. */
  30363. get fillMode(): number;
  30364. /**
  30365. * Sets the material fill mode
  30366. */
  30367. set fillMode(value: number);
  30368. /**
  30369. * @hidden
  30370. * Stores the effects for the material
  30371. */
  30372. _effect: Nullable<Effect>;
  30373. /**
  30374. * Specifies if uniform buffers should be used
  30375. */
  30376. private _useUBO;
  30377. /**
  30378. * Stores a reference to the scene
  30379. */
  30380. private _scene;
  30381. private _needToBindSceneUbo;
  30382. /**
  30383. * Stores the fill mode state
  30384. */
  30385. private _fillMode;
  30386. /**
  30387. * Specifies if the depth write state should be cached
  30388. */
  30389. private _cachedDepthWriteState;
  30390. /**
  30391. * Specifies if the color write state should be cached
  30392. */
  30393. private _cachedColorWriteState;
  30394. /**
  30395. * Specifies if the depth function state should be cached
  30396. */
  30397. private _cachedDepthFunctionState;
  30398. /**
  30399. * Stores the uniform buffer
  30400. */
  30401. protected _uniformBuffer: UniformBuffer;
  30402. /** @hidden */
  30403. _indexInSceneMaterialArray: number;
  30404. /** @hidden */
  30405. meshMap: Nullable<{
  30406. [id: string]: AbstractMesh | undefined;
  30407. }>;
  30408. /**
  30409. * Creates a material instance
  30410. * @param name defines the name of the material
  30411. * @param scene defines the scene to reference
  30412. * @param doNotAdd specifies if the material should be added to the scene
  30413. */
  30414. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30415. /**
  30416. * Returns a string representation of the current material
  30417. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30418. * @returns a string with material information
  30419. */
  30420. toString(fullDetails?: boolean): string;
  30421. /**
  30422. * Gets the class name of the material
  30423. * @returns a string with the class name of the material
  30424. */
  30425. getClassName(): string;
  30426. /**
  30427. * Specifies if updates for the material been locked
  30428. */
  30429. get isFrozen(): boolean;
  30430. /**
  30431. * Locks updates for the material
  30432. */
  30433. freeze(): void;
  30434. /**
  30435. * Unlocks updates for the material
  30436. */
  30437. unfreeze(): void;
  30438. /**
  30439. * Specifies if the material is ready to be used
  30440. * @param mesh defines the mesh to check
  30441. * @param useInstances specifies if instances should be used
  30442. * @returns a boolean indicating if the material is ready to be used
  30443. */
  30444. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30445. /**
  30446. * Specifies that the submesh is ready to be used
  30447. * @param mesh defines the mesh to check
  30448. * @param subMesh defines which submesh to check
  30449. * @param useInstances specifies that instances should be used
  30450. * @returns a boolean indicating that the submesh is ready or not
  30451. */
  30452. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30453. /**
  30454. * Returns the material effect
  30455. * @returns the effect associated with the material
  30456. */
  30457. getEffect(): Nullable<Effect>;
  30458. /**
  30459. * Returns the current scene
  30460. * @returns a Scene
  30461. */
  30462. getScene(): Scene;
  30463. /**
  30464. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30465. */
  30466. protected _forceAlphaTest: boolean;
  30467. /**
  30468. * The transparency mode of the material.
  30469. */
  30470. protected _transparencyMode: Nullable<number>;
  30471. /**
  30472. * Gets the current transparency mode.
  30473. */
  30474. get transparencyMode(): Nullable<number>;
  30475. /**
  30476. * Sets the transparency mode of the material.
  30477. *
  30478. * | Value | Type | Description |
  30479. * | ----- | ----------------------------------- | ----------- |
  30480. * | 0 | OPAQUE | |
  30481. * | 1 | ALPHATEST | |
  30482. * | 2 | ALPHABLEND | |
  30483. * | 3 | ALPHATESTANDBLEND | |
  30484. *
  30485. */
  30486. set transparencyMode(value: Nullable<number>);
  30487. /**
  30488. * Returns true if alpha blending should be disabled.
  30489. */
  30490. protected get _disableAlphaBlending(): boolean;
  30491. /**
  30492. * Specifies whether or not this material should be rendered in alpha blend mode.
  30493. * @returns a boolean specifying if alpha blending is needed
  30494. */
  30495. needAlphaBlending(): boolean;
  30496. /**
  30497. * Specifies if the mesh will require alpha blending
  30498. * @param mesh defines the mesh to check
  30499. * @returns a boolean specifying if alpha blending is needed for the mesh
  30500. */
  30501. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30502. /**
  30503. * Specifies whether or not this material should be rendered in alpha test mode.
  30504. * @returns a boolean specifying if an alpha test is needed.
  30505. */
  30506. needAlphaTesting(): boolean;
  30507. /**
  30508. * Specifies if material alpha testing should be turned on for the mesh
  30509. * @param mesh defines the mesh to check
  30510. */
  30511. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30512. /**
  30513. * Gets the texture used for the alpha test
  30514. * @returns the texture to use for alpha testing
  30515. */
  30516. getAlphaTestTexture(): Nullable<BaseTexture>;
  30517. /**
  30518. * Marks the material to indicate that it needs to be re-calculated
  30519. */
  30520. markDirty(): void;
  30521. /** @hidden */
  30522. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30523. /**
  30524. * Binds the material to the mesh
  30525. * @param world defines the world transformation matrix
  30526. * @param mesh defines the mesh to bind the material to
  30527. */
  30528. bind(world: Matrix, mesh?: Mesh): void;
  30529. /**
  30530. * Binds the submesh to the material
  30531. * @param world defines the world transformation matrix
  30532. * @param mesh defines the mesh containing the submesh
  30533. * @param subMesh defines the submesh to bind the material to
  30534. */
  30535. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30536. /**
  30537. * Binds the world matrix to the material
  30538. * @param world defines the world transformation matrix
  30539. */
  30540. bindOnlyWorldMatrix(world: Matrix): void;
  30541. /**
  30542. * Update the scene ubo before it can be used in rendering processing
  30543. * @param scene the scene to retrieve the ubo from
  30544. * @returns the scene UniformBuffer
  30545. */
  30546. finalizeSceneUbo(scene: Scene): UniformBuffer;
  30547. /**
  30548. * Binds the scene's uniform buffer to the effect.
  30549. * @param effect defines the effect to bind to the scene uniform buffer
  30550. * @param sceneUbo defines the uniform buffer storing scene data
  30551. */
  30552. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30553. /**
  30554. * Binds the view matrix to the effect
  30555. * @param effect defines the effect to bind the view matrix to
  30556. */
  30557. bindView(effect: Effect): void;
  30558. /**
  30559. * Binds the view projection and projection matrices to the effect
  30560. * @param effect defines the effect to bind the view projection and projection matrices to
  30561. */
  30562. bindViewProjection(effect: Effect): void;
  30563. /**
  30564. * Binds the view matrix to the effect
  30565. * @param effect defines the effect to bind the view matrix to
  30566. * @param variableName name of the shader variable that will hold the eye position
  30567. */
  30568. bindEyePosition(effect: Effect, variableName?: string): void;
  30569. /**
  30570. * Processes to execute after binding the material to a mesh
  30571. * @param mesh defines the rendered mesh
  30572. */
  30573. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30574. /**
  30575. * Unbinds the material from the mesh
  30576. */
  30577. unbind(): void;
  30578. /**
  30579. * Gets the active textures from the material
  30580. * @returns an array of textures
  30581. */
  30582. getActiveTextures(): BaseTexture[];
  30583. /**
  30584. * Specifies if the material uses a texture
  30585. * @param texture defines the texture to check against the material
  30586. * @returns a boolean specifying if the material uses the texture
  30587. */
  30588. hasTexture(texture: BaseTexture): boolean;
  30589. /**
  30590. * Makes a duplicate of the material, and gives it a new name
  30591. * @param name defines the new name for the duplicated material
  30592. * @returns the cloned material
  30593. */
  30594. clone(name: string): Nullable<Material>;
  30595. /**
  30596. * Gets the meshes bound to the material
  30597. * @returns an array of meshes bound to the material
  30598. */
  30599. getBindedMeshes(): AbstractMesh[];
  30600. /**
  30601. * Force shader compilation
  30602. * @param mesh defines the mesh associated with this material
  30603. * @param onCompiled defines a function to execute once the material is compiled
  30604. * @param options defines the options to configure the compilation
  30605. * @param onError defines a function to execute if the material fails compiling
  30606. */
  30607. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30608. /**
  30609. * Force shader compilation
  30610. * @param mesh defines the mesh that will use this material
  30611. * @param options defines additional options for compiling the shaders
  30612. * @returns a promise that resolves when the compilation completes
  30613. */
  30614. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30615. private static readonly _AllDirtyCallBack;
  30616. private static readonly _ImageProcessingDirtyCallBack;
  30617. private static readonly _TextureDirtyCallBack;
  30618. private static readonly _FresnelDirtyCallBack;
  30619. private static readonly _MiscDirtyCallBack;
  30620. private static readonly _PrePassDirtyCallBack;
  30621. private static readonly _LightsDirtyCallBack;
  30622. private static readonly _AttributeDirtyCallBack;
  30623. private static _FresnelAndMiscDirtyCallBack;
  30624. private static _TextureAndMiscDirtyCallBack;
  30625. private static readonly _DirtyCallbackArray;
  30626. private static readonly _RunDirtyCallBacks;
  30627. /**
  30628. * Marks a define in the material to indicate that it needs to be re-computed
  30629. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30630. */
  30631. markAsDirty(flag: number): void;
  30632. /**
  30633. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30634. * @param func defines a function which checks material defines against the submeshes
  30635. */
  30636. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30637. /**
  30638. * Indicates that the scene should check if the rendering now needs a prepass
  30639. */
  30640. protected _markScenePrePassDirty(): void;
  30641. /**
  30642. * Indicates that we need to re-calculated for all submeshes
  30643. */
  30644. protected _markAllSubMeshesAsAllDirty(): void;
  30645. /**
  30646. * Indicates that image processing needs to be re-calculated for all submeshes
  30647. */
  30648. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30649. /**
  30650. * Indicates that textures need to be re-calculated for all submeshes
  30651. */
  30652. protected _markAllSubMeshesAsTexturesDirty(): void;
  30653. /**
  30654. * Indicates that fresnel needs to be re-calculated for all submeshes
  30655. */
  30656. protected _markAllSubMeshesAsFresnelDirty(): void;
  30657. /**
  30658. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30659. */
  30660. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30661. /**
  30662. * Indicates that lights need to be re-calculated for all submeshes
  30663. */
  30664. protected _markAllSubMeshesAsLightsDirty(): void;
  30665. /**
  30666. * Indicates that attributes need to be re-calculated for all submeshes
  30667. */
  30668. protected _markAllSubMeshesAsAttributesDirty(): void;
  30669. /**
  30670. * Indicates that misc needs to be re-calculated for all submeshes
  30671. */
  30672. protected _markAllSubMeshesAsMiscDirty(): void;
  30673. /**
  30674. * Indicates that prepass needs to be re-calculated for all submeshes
  30675. */
  30676. protected _markAllSubMeshesAsPrePassDirty(): void;
  30677. /**
  30678. * Indicates that textures and misc need to be re-calculated for all submeshes
  30679. */
  30680. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30681. /**
  30682. * Sets the required values to the prepass renderer.
  30683. * @param prePassRenderer defines the prepass renderer to setup.
  30684. * @returns true if the pre pass is needed.
  30685. */
  30686. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30687. /**
  30688. * Disposes the material
  30689. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30690. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30691. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30692. */
  30693. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30694. /** @hidden */
  30695. private releaseVertexArrayObject;
  30696. /**
  30697. * Serializes this material
  30698. * @returns the serialized material object
  30699. */
  30700. serialize(): any;
  30701. /**
  30702. * Creates a material from parsed material data
  30703. * @param parsedMaterial defines parsed material data
  30704. * @param scene defines the hosting scene
  30705. * @param rootUrl defines the root URL to use to load textures
  30706. * @returns a new material
  30707. */
  30708. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30709. }
  30710. }
  30711. declare module BABYLON {
  30712. /**
  30713. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30714. * separate meshes. This can be use to improve performances.
  30715. * @see https://doc.babylonjs.com/how_to/multi_materials
  30716. */
  30717. export class MultiMaterial extends Material {
  30718. private _subMaterials;
  30719. /**
  30720. * Gets or Sets the list of Materials used within the multi material.
  30721. * They need to be ordered according to the submeshes order in the associated mesh
  30722. */
  30723. get subMaterials(): Nullable<Material>[];
  30724. set subMaterials(value: Nullable<Material>[]);
  30725. /**
  30726. * Function used to align with Node.getChildren()
  30727. * @returns the list of Materials used within the multi material
  30728. */
  30729. getChildren(): Nullable<Material>[];
  30730. /**
  30731. * Instantiates a new Multi Material
  30732. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30733. * separate meshes. This can be use to improve performances.
  30734. * @see https://doc.babylonjs.com/how_to/multi_materials
  30735. * @param name Define the name in the scene
  30736. * @param scene Define the scene the material belongs to
  30737. */
  30738. constructor(name: string, scene: Scene);
  30739. private _hookArray;
  30740. /**
  30741. * Get one of the submaterial by its index in the submaterials array
  30742. * @param index The index to look the sub material at
  30743. * @returns The Material if the index has been defined
  30744. */
  30745. getSubMaterial(index: number): Nullable<Material>;
  30746. /**
  30747. * Get the list of active textures for the whole sub materials list.
  30748. * @returns All the textures that will be used during the rendering
  30749. */
  30750. getActiveTextures(): BaseTexture[];
  30751. /**
  30752. * Specifies if any sub-materials of this multi-material use a given texture.
  30753. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30754. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30755. */
  30756. hasTexture(texture: BaseTexture): boolean;
  30757. /**
  30758. * Gets the current class name of the material e.g. "MultiMaterial"
  30759. * Mainly use in serialization.
  30760. * @returns the class name
  30761. */
  30762. getClassName(): string;
  30763. /**
  30764. * Checks if the material is ready to render the requested sub mesh
  30765. * @param mesh Define the mesh the submesh belongs to
  30766. * @param subMesh Define the sub mesh to look readyness for
  30767. * @param useInstances Define whether or not the material is used with instances
  30768. * @returns true if ready, otherwise false
  30769. */
  30770. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30771. /**
  30772. * Clones the current material and its related sub materials
  30773. * @param name Define the name of the newly cloned material
  30774. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30775. * @returns the cloned material
  30776. */
  30777. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30778. /**
  30779. * Serializes the materials into a JSON representation.
  30780. * @returns the JSON representation
  30781. */
  30782. serialize(): any;
  30783. /**
  30784. * Dispose the material and release its associated resources
  30785. * @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)
  30786. * @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)
  30787. * @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)
  30788. */
  30789. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30790. /**
  30791. * Creates a MultiMaterial from parsed MultiMaterial data.
  30792. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30793. * @param scene defines the hosting scene
  30794. * @returns a new MultiMaterial
  30795. */
  30796. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30797. }
  30798. }
  30799. declare module BABYLON {
  30800. /** @hidden */
  30801. export interface ICustomEffect {
  30802. effect: Effect;
  30803. defines: string;
  30804. }
  30805. /**
  30806. * Defines a subdivision inside a mesh
  30807. */
  30808. export class SubMesh implements ICullable {
  30809. /** the material index to use */
  30810. materialIndex: number;
  30811. /** vertex index start */
  30812. verticesStart: number;
  30813. /** vertices count */
  30814. verticesCount: number;
  30815. /** index start */
  30816. indexStart: number;
  30817. /** indices count */
  30818. indexCount: number;
  30819. /** @hidden */
  30820. _materialDefines: Nullable<MaterialDefines>;
  30821. /** @hidden */
  30822. _materialEffect: Nullable<Effect>;
  30823. /** @hidden */
  30824. _effectOverride: Nullable<Effect>;
  30825. private _customEffects;
  30826. /**
  30827. * Gets material defines used by the effect associated to the sub mesh
  30828. */
  30829. get materialDefines(): Nullable<MaterialDefines>;
  30830. /**
  30831. * Sets material defines used by the effect associated to the sub mesh
  30832. */
  30833. set materialDefines(defines: Nullable<MaterialDefines>);
  30834. /** @hidden */
  30835. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  30836. /** @hidden */
  30837. _removeCustomEffect(name: string): void;
  30838. /**
  30839. * Gets associated effect
  30840. */
  30841. get effect(): Nullable<Effect>;
  30842. /**
  30843. * Sets associated effect (effect used to render this submesh)
  30844. * @param effect defines the effect to associate with
  30845. * @param defines defines the set of defines used to compile this effect
  30846. */
  30847. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30848. /** @hidden */
  30849. _linesIndexCount: number;
  30850. private _mesh;
  30851. private _renderingMesh;
  30852. private _boundingInfo;
  30853. private _linesIndexBuffer;
  30854. /** @hidden */
  30855. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30856. /** @hidden */
  30857. _trianglePlanes: Plane[];
  30858. /** @hidden */
  30859. _lastColliderTransformMatrix: Nullable<Matrix>;
  30860. /** @hidden */
  30861. _renderId: number;
  30862. /** @hidden */
  30863. _alphaIndex: number;
  30864. /** @hidden */
  30865. _distanceToCamera: number;
  30866. /** @hidden */
  30867. _id: number;
  30868. private _currentMaterial;
  30869. /**
  30870. * Add a new submesh to a mesh
  30871. * @param materialIndex defines the material index to use
  30872. * @param verticesStart defines vertex index start
  30873. * @param verticesCount defines vertices count
  30874. * @param indexStart defines index start
  30875. * @param indexCount defines indices count
  30876. * @param mesh defines the parent mesh
  30877. * @param renderingMesh defines an optional rendering mesh
  30878. * @param createBoundingBox defines if bounding box should be created for this submesh
  30879. * @returns the new submesh
  30880. */
  30881. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30882. /**
  30883. * Creates a new submesh
  30884. * @param materialIndex defines the material index to use
  30885. * @param verticesStart defines vertex index start
  30886. * @param verticesCount defines vertices count
  30887. * @param indexStart defines index start
  30888. * @param indexCount defines indices count
  30889. * @param mesh defines the parent mesh
  30890. * @param renderingMesh defines an optional rendering mesh
  30891. * @param createBoundingBox defines if bounding box should be created for this submesh
  30892. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30893. */
  30894. constructor(
  30895. /** the material index to use */
  30896. materialIndex: number,
  30897. /** vertex index start */
  30898. verticesStart: number,
  30899. /** vertices count */
  30900. verticesCount: number,
  30901. /** index start */
  30902. indexStart: number,
  30903. /** indices count */
  30904. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30905. /**
  30906. * Returns true if this submesh covers the entire parent mesh
  30907. * @ignorenaming
  30908. */
  30909. get IsGlobal(): boolean;
  30910. /**
  30911. * Returns the submesh BoudingInfo object
  30912. * @returns current bounding info (or mesh's one if the submesh is global)
  30913. */
  30914. getBoundingInfo(): BoundingInfo;
  30915. /**
  30916. * Sets the submesh BoundingInfo
  30917. * @param boundingInfo defines the new bounding info to use
  30918. * @returns the SubMesh
  30919. */
  30920. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30921. /**
  30922. * Returns the mesh of the current submesh
  30923. * @return the parent mesh
  30924. */
  30925. getMesh(): AbstractMesh;
  30926. /**
  30927. * Returns the rendering mesh of the submesh
  30928. * @returns the rendering mesh (could be different from parent mesh)
  30929. */
  30930. getRenderingMesh(): Mesh;
  30931. /**
  30932. * Returns the replacement mesh of the submesh
  30933. * @returns the replacement mesh (could be different from parent mesh)
  30934. */
  30935. getReplacementMesh(): Nullable<AbstractMesh>;
  30936. /**
  30937. * Returns the effective mesh of the submesh
  30938. * @returns the effective mesh (could be different from parent mesh)
  30939. */
  30940. getEffectiveMesh(): AbstractMesh;
  30941. /**
  30942. * Returns the submesh material
  30943. * @returns null or the current material
  30944. */
  30945. getMaterial(): Nullable<Material>;
  30946. private _IsMultiMaterial;
  30947. /**
  30948. * Sets a new updated BoundingInfo object to the submesh
  30949. * @param data defines an optional position array to use to determine the bounding info
  30950. * @returns the SubMesh
  30951. */
  30952. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30953. /** @hidden */
  30954. _checkCollision(collider: Collider): boolean;
  30955. /**
  30956. * Updates the submesh BoundingInfo
  30957. * @param world defines the world matrix to use to update the bounding info
  30958. * @returns the submesh
  30959. */
  30960. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30961. /**
  30962. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30963. * @param frustumPlanes defines the frustum planes
  30964. * @returns true if the submesh is intersecting with the frustum
  30965. */
  30966. isInFrustum(frustumPlanes: Plane[]): boolean;
  30967. /**
  30968. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30969. * @param frustumPlanes defines the frustum planes
  30970. * @returns true if the submesh is inside the frustum
  30971. */
  30972. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30973. /**
  30974. * Renders the submesh
  30975. * @param enableAlphaMode defines if alpha needs to be used
  30976. * @returns the submesh
  30977. */
  30978. render(enableAlphaMode: boolean): SubMesh;
  30979. /**
  30980. * @hidden
  30981. */
  30982. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30983. /**
  30984. * Checks if the submesh intersects with a ray
  30985. * @param ray defines the ray to test
  30986. * @returns true is the passed ray intersects the submesh bounding box
  30987. */
  30988. canIntersects(ray: Ray): boolean;
  30989. /**
  30990. * Intersects current submesh with a ray
  30991. * @param ray defines the ray to test
  30992. * @param positions defines mesh's positions array
  30993. * @param indices defines mesh's indices array
  30994. * @param fastCheck defines if the first intersection will be used (and not the closest)
  30995. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  30996. * @returns intersection info or null if no intersection
  30997. */
  30998. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  30999. /** @hidden */
  31000. private _intersectLines;
  31001. /** @hidden */
  31002. private _intersectUnIndexedLines;
  31003. /** @hidden */
  31004. private _intersectTriangles;
  31005. /** @hidden */
  31006. private _intersectUnIndexedTriangles;
  31007. /** @hidden */
  31008. _rebuild(): void;
  31009. /**
  31010. * Creates a new submesh from the passed mesh
  31011. * @param newMesh defines the new hosting mesh
  31012. * @param newRenderingMesh defines an optional rendering mesh
  31013. * @returns the new submesh
  31014. */
  31015. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31016. /**
  31017. * Release associated resources
  31018. */
  31019. dispose(): void;
  31020. /**
  31021. * Gets the class name
  31022. * @returns the string "SubMesh".
  31023. */
  31024. getClassName(): string;
  31025. /**
  31026. * Creates a new submesh from indices data
  31027. * @param materialIndex the index of the main mesh material
  31028. * @param startIndex the index where to start the copy in the mesh indices array
  31029. * @param indexCount the number of indices to copy then from the startIndex
  31030. * @param mesh the main mesh to create the submesh from
  31031. * @param renderingMesh the optional rendering mesh
  31032. * @returns a new submesh
  31033. */
  31034. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31035. }
  31036. }
  31037. declare module BABYLON {
  31038. /**
  31039. * Class used to represent data loading progression
  31040. */
  31041. export class SceneLoaderFlags {
  31042. private static _ForceFullSceneLoadingForIncremental;
  31043. private static _ShowLoadingScreen;
  31044. private static _CleanBoneMatrixWeights;
  31045. private static _loggingLevel;
  31046. /**
  31047. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31048. */
  31049. static get ForceFullSceneLoadingForIncremental(): boolean;
  31050. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31051. /**
  31052. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31053. */
  31054. static get ShowLoadingScreen(): boolean;
  31055. static set ShowLoadingScreen(value: boolean);
  31056. /**
  31057. * Defines the current logging level (while loading the scene)
  31058. * @ignorenaming
  31059. */
  31060. static get loggingLevel(): number;
  31061. static set loggingLevel(value: number);
  31062. /**
  31063. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31064. */
  31065. static get CleanBoneMatrixWeights(): boolean;
  31066. static set CleanBoneMatrixWeights(value: boolean);
  31067. }
  31068. }
  31069. declare module BABYLON {
  31070. /**
  31071. * Class used to store geometry data (vertex buffers + index buffer)
  31072. */
  31073. export class Geometry implements IGetSetVerticesData {
  31074. /**
  31075. * Gets or sets the ID of the geometry
  31076. */
  31077. id: string;
  31078. /**
  31079. * Gets or sets the unique ID of the geometry
  31080. */
  31081. uniqueId: number;
  31082. /**
  31083. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31084. */
  31085. delayLoadState: number;
  31086. /**
  31087. * Gets the file containing the data to load when running in delay load state
  31088. */
  31089. delayLoadingFile: Nullable<string>;
  31090. /**
  31091. * Callback called when the geometry is updated
  31092. */
  31093. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31094. private _scene;
  31095. private _engine;
  31096. private _meshes;
  31097. private _totalVertices;
  31098. /** @hidden */
  31099. _indices: IndicesArray;
  31100. /** @hidden */
  31101. _vertexBuffers: {
  31102. [key: string]: VertexBuffer;
  31103. };
  31104. private _isDisposed;
  31105. private _extend;
  31106. private _boundingBias;
  31107. /** @hidden */
  31108. _delayInfo: Array<string>;
  31109. private _indexBuffer;
  31110. private _indexBufferIsUpdatable;
  31111. /** @hidden */
  31112. _boundingInfo: Nullable<BoundingInfo>;
  31113. /** @hidden */
  31114. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31115. /** @hidden */
  31116. _softwareSkinningFrameId: number;
  31117. private _vertexArrayObjects;
  31118. private _updatable;
  31119. /** @hidden */
  31120. _positions: Nullable<Vector3[]>;
  31121. private _positionsCache;
  31122. /**
  31123. * 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
  31124. */
  31125. get boundingBias(): Vector2;
  31126. /**
  31127. * 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
  31128. */
  31129. set boundingBias(value: Vector2);
  31130. /**
  31131. * Static function used to attach a new empty geometry to a mesh
  31132. * @param mesh defines the mesh to attach the geometry to
  31133. * @returns the new Geometry
  31134. */
  31135. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31136. /** Get the list of meshes using this geometry */
  31137. get meshes(): Mesh[];
  31138. /**
  31139. * 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
  31140. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31141. */
  31142. useBoundingInfoFromGeometry: boolean;
  31143. /**
  31144. * Creates a new geometry
  31145. * @param id defines the unique ID
  31146. * @param scene defines the hosting scene
  31147. * @param vertexData defines the VertexData used to get geometry data
  31148. * @param updatable defines if geometry must be updatable (false by default)
  31149. * @param mesh defines the mesh that will be associated with the geometry
  31150. */
  31151. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31152. /**
  31153. * Gets the current extend of the geometry
  31154. */
  31155. get extend(): {
  31156. minimum: Vector3;
  31157. maximum: Vector3;
  31158. };
  31159. /**
  31160. * Gets the hosting scene
  31161. * @returns the hosting Scene
  31162. */
  31163. getScene(): Scene;
  31164. /**
  31165. * Gets the hosting engine
  31166. * @returns the hosting Engine
  31167. */
  31168. getEngine(): Engine;
  31169. /**
  31170. * Defines if the geometry is ready to use
  31171. * @returns true if the geometry is ready to be used
  31172. */
  31173. isReady(): boolean;
  31174. /**
  31175. * Gets a value indicating that the geometry should not be serialized
  31176. */
  31177. get doNotSerialize(): boolean;
  31178. /** @hidden */
  31179. _rebuild(): void;
  31180. /**
  31181. * Affects all geometry data in one call
  31182. * @param vertexData defines the geometry data
  31183. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31184. */
  31185. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31186. /**
  31187. * Set specific vertex data
  31188. * @param kind defines the data kind (Position, normal, etc...)
  31189. * @param data defines the vertex data to use
  31190. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31191. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31192. */
  31193. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31194. /**
  31195. * Removes a specific vertex data
  31196. * @param kind defines the data kind (Position, normal, etc...)
  31197. */
  31198. removeVerticesData(kind: string): void;
  31199. /**
  31200. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31201. * @param buffer defines the vertex buffer to use
  31202. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31203. */
  31204. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31205. /**
  31206. * Update a specific vertex buffer
  31207. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31208. * It will do nothing if the buffer is not updatable
  31209. * @param kind defines the data kind (Position, normal, etc...)
  31210. * @param data defines the data to use
  31211. * @param offset defines the offset in the target buffer where to store the data
  31212. * @param useBytes set to true if the offset is in bytes
  31213. */
  31214. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31215. /**
  31216. * Update a specific vertex buffer
  31217. * This function will create a new buffer if the current one is not updatable
  31218. * @param kind defines the data kind (Position, normal, etc...)
  31219. * @param data defines the data to use
  31220. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31221. */
  31222. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31223. private _updateBoundingInfo;
  31224. /** @hidden */
  31225. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31226. /**
  31227. * Gets total number of vertices
  31228. * @returns the total number of vertices
  31229. */
  31230. getTotalVertices(): number;
  31231. /**
  31232. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31233. * @param kind defines the data kind (Position, normal, etc...)
  31234. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31235. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31236. * @returns a float array containing vertex data
  31237. */
  31238. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31239. /**
  31240. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31241. * @param kind defines the data kind (Position, normal, etc...)
  31242. * @returns true if the vertex buffer with the specified kind is updatable
  31243. */
  31244. isVertexBufferUpdatable(kind: string): boolean;
  31245. /**
  31246. * Gets a specific vertex buffer
  31247. * @param kind defines the data kind (Position, normal, etc...)
  31248. * @returns a VertexBuffer
  31249. */
  31250. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31251. /**
  31252. * Returns all vertex buffers
  31253. * @return an object holding all vertex buffers indexed by kind
  31254. */
  31255. getVertexBuffers(): Nullable<{
  31256. [key: string]: VertexBuffer;
  31257. }>;
  31258. /**
  31259. * Gets a boolean indicating if specific vertex buffer is present
  31260. * @param kind defines the data kind (Position, normal, etc...)
  31261. * @returns true if data is present
  31262. */
  31263. isVerticesDataPresent(kind: string): boolean;
  31264. /**
  31265. * Gets a list of all attached data kinds (Position, normal, etc...)
  31266. * @returns a list of string containing all kinds
  31267. */
  31268. getVerticesDataKinds(): string[];
  31269. /**
  31270. * Update index buffer
  31271. * @param indices defines the indices to store in the index buffer
  31272. * @param offset defines the offset in the target buffer where to store the data
  31273. * @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)
  31274. */
  31275. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31276. /**
  31277. * Creates a new index buffer
  31278. * @param indices defines the indices to store in the index buffer
  31279. * @param totalVertices defines the total number of vertices (could be null)
  31280. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31281. */
  31282. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31283. /**
  31284. * Return the total number of indices
  31285. * @returns the total number of indices
  31286. */
  31287. getTotalIndices(): number;
  31288. /**
  31289. * Gets the index buffer array
  31290. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31291. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31292. * @returns the index buffer array
  31293. */
  31294. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31295. /**
  31296. * Gets the index buffer
  31297. * @return the index buffer
  31298. */
  31299. getIndexBuffer(): Nullable<DataBuffer>;
  31300. /** @hidden */
  31301. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31302. /**
  31303. * Release the associated resources for a specific mesh
  31304. * @param mesh defines the source mesh
  31305. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31306. */
  31307. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31308. /**
  31309. * Apply current geometry to a given mesh
  31310. * @param mesh defines the mesh to apply geometry to
  31311. */
  31312. applyToMesh(mesh: Mesh): void;
  31313. private _updateExtend;
  31314. private _applyToMesh;
  31315. private notifyUpdate;
  31316. /**
  31317. * Load the geometry if it was flagged as delay loaded
  31318. * @param scene defines the hosting scene
  31319. * @param onLoaded defines a callback called when the geometry is loaded
  31320. */
  31321. load(scene: Scene, onLoaded?: () => void): void;
  31322. private _queueLoad;
  31323. /**
  31324. * Invert the geometry to move from a right handed system to a left handed one.
  31325. */
  31326. toLeftHanded(): void;
  31327. /** @hidden */
  31328. _resetPointsArrayCache(): void;
  31329. /** @hidden */
  31330. _generatePointsArray(): boolean;
  31331. /**
  31332. * Gets a value indicating if the geometry is disposed
  31333. * @returns true if the geometry was disposed
  31334. */
  31335. isDisposed(): boolean;
  31336. private _disposeVertexArrayObjects;
  31337. /**
  31338. * Free all associated resources
  31339. */
  31340. dispose(): void;
  31341. /**
  31342. * Clone the current geometry into a new geometry
  31343. * @param id defines the unique ID of the new geometry
  31344. * @returns a new geometry object
  31345. */
  31346. copy(id: string): Geometry;
  31347. /**
  31348. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31349. * @return a JSON representation of the current geometry data (without the vertices data)
  31350. */
  31351. serialize(): any;
  31352. private toNumberArray;
  31353. /**
  31354. * Serialize all vertices data into a JSON oject
  31355. * @returns a JSON representation of the current geometry data
  31356. */
  31357. serializeVerticeData(): any;
  31358. /**
  31359. * Extracts a clone of a mesh geometry
  31360. * @param mesh defines the source mesh
  31361. * @param id defines the unique ID of the new geometry object
  31362. * @returns the new geometry object
  31363. */
  31364. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31365. /**
  31366. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31367. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31368. * Be aware Math.random() could cause collisions, but:
  31369. * "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"
  31370. * @returns a string containing a new GUID
  31371. */
  31372. static RandomId(): string;
  31373. /** @hidden */
  31374. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31375. private static _CleanMatricesWeights;
  31376. /**
  31377. * Create a new geometry from persisted data (Using .babylon file format)
  31378. * @param parsedVertexData defines the persisted data
  31379. * @param scene defines the hosting scene
  31380. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31381. * @returns the new geometry object
  31382. */
  31383. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31384. }
  31385. }
  31386. declare module BABYLON {
  31387. /**
  31388. * Defines a target to use with MorphTargetManager
  31389. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31390. */
  31391. export class MorphTarget implements IAnimatable {
  31392. /** defines the name of the target */
  31393. name: string;
  31394. /**
  31395. * Gets or sets the list of animations
  31396. */
  31397. animations: Animation[];
  31398. private _scene;
  31399. private _positions;
  31400. private _normals;
  31401. private _tangents;
  31402. private _uvs;
  31403. private _influence;
  31404. private _uniqueId;
  31405. /**
  31406. * Observable raised when the influence changes
  31407. */
  31408. onInfluenceChanged: Observable<boolean>;
  31409. /** @hidden */
  31410. _onDataLayoutChanged: Observable<void>;
  31411. /**
  31412. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31413. */
  31414. get influence(): number;
  31415. set influence(influence: number);
  31416. /**
  31417. * Gets or sets the id of the morph Target
  31418. */
  31419. id: string;
  31420. private _animationPropertiesOverride;
  31421. /**
  31422. * Gets or sets the animation properties override
  31423. */
  31424. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31425. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31426. /**
  31427. * Creates a new MorphTarget
  31428. * @param name defines the name of the target
  31429. * @param influence defines the influence to use
  31430. * @param scene defines the scene the morphtarget belongs to
  31431. */
  31432. constructor(
  31433. /** defines the name of the target */
  31434. name: string, influence?: number, scene?: Nullable<Scene>);
  31435. /**
  31436. * Gets the unique ID of this manager
  31437. */
  31438. get uniqueId(): number;
  31439. /**
  31440. * Gets a boolean defining if the target contains position data
  31441. */
  31442. get hasPositions(): boolean;
  31443. /**
  31444. * Gets a boolean defining if the target contains normal data
  31445. */
  31446. get hasNormals(): boolean;
  31447. /**
  31448. * Gets a boolean defining if the target contains tangent data
  31449. */
  31450. get hasTangents(): boolean;
  31451. /**
  31452. * Gets a boolean defining if the target contains texture coordinates data
  31453. */
  31454. get hasUVs(): boolean;
  31455. /**
  31456. * Affects position data to this target
  31457. * @param data defines the position data to use
  31458. */
  31459. setPositions(data: Nullable<FloatArray>): void;
  31460. /**
  31461. * Gets the position data stored in this target
  31462. * @returns a FloatArray containing the position data (or null if not present)
  31463. */
  31464. getPositions(): Nullable<FloatArray>;
  31465. /**
  31466. * Affects normal data to this target
  31467. * @param data defines the normal data to use
  31468. */
  31469. setNormals(data: Nullable<FloatArray>): void;
  31470. /**
  31471. * Gets the normal data stored in this target
  31472. * @returns a FloatArray containing the normal data (or null if not present)
  31473. */
  31474. getNormals(): Nullable<FloatArray>;
  31475. /**
  31476. * Affects tangent data to this target
  31477. * @param data defines the tangent data to use
  31478. */
  31479. setTangents(data: Nullable<FloatArray>): void;
  31480. /**
  31481. * Gets the tangent data stored in this target
  31482. * @returns a FloatArray containing the tangent data (or null if not present)
  31483. */
  31484. getTangents(): Nullable<FloatArray>;
  31485. /**
  31486. * Affects texture coordinates data to this target
  31487. * @param data defines the texture coordinates data to use
  31488. */
  31489. setUVs(data: Nullable<FloatArray>): void;
  31490. /**
  31491. * Gets the texture coordinates data stored in this target
  31492. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31493. */
  31494. getUVs(): Nullable<FloatArray>;
  31495. /**
  31496. * Clone the current target
  31497. * @returns a new MorphTarget
  31498. */
  31499. clone(): MorphTarget;
  31500. /**
  31501. * Serializes the current target into a Serialization object
  31502. * @returns the serialized object
  31503. */
  31504. serialize(): any;
  31505. /**
  31506. * Returns the string "MorphTarget"
  31507. * @returns "MorphTarget"
  31508. */
  31509. getClassName(): string;
  31510. /**
  31511. * Creates a new target from serialized data
  31512. * @param serializationObject defines the serialized data to use
  31513. * @returns a new MorphTarget
  31514. */
  31515. static Parse(serializationObject: any): MorphTarget;
  31516. /**
  31517. * Creates a MorphTarget from mesh data
  31518. * @param mesh defines the source mesh
  31519. * @param name defines the name to use for the new target
  31520. * @param influence defines the influence to attach to the target
  31521. * @returns a new MorphTarget
  31522. */
  31523. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31524. }
  31525. }
  31526. declare module BABYLON {
  31527. /**
  31528. * This class is used to deform meshes using morphing between different targets
  31529. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31530. */
  31531. export class MorphTargetManager {
  31532. private _targets;
  31533. private _targetInfluenceChangedObservers;
  31534. private _targetDataLayoutChangedObservers;
  31535. private _activeTargets;
  31536. private _scene;
  31537. private _influences;
  31538. private _supportsNormals;
  31539. private _supportsTangents;
  31540. private _supportsUVs;
  31541. private _vertexCount;
  31542. private _uniqueId;
  31543. private _tempInfluences;
  31544. /**
  31545. * Gets or sets a boolean indicating if normals must be morphed
  31546. */
  31547. enableNormalMorphing: boolean;
  31548. /**
  31549. * Gets or sets a boolean indicating if tangents must be morphed
  31550. */
  31551. enableTangentMorphing: boolean;
  31552. /**
  31553. * Gets or sets a boolean indicating if UV must be morphed
  31554. */
  31555. enableUVMorphing: boolean;
  31556. /**
  31557. * Creates a new MorphTargetManager
  31558. * @param scene defines the current scene
  31559. */
  31560. constructor(scene?: Nullable<Scene>);
  31561. /**
  31562. * Gets the unique ID of this manager
  31563. */
  31564. get uniqueId(): number;
  31565. /**
  31566. * Gets the number of vertices handled by this manager
  31567. */
  31568. get vertexCount(): number;
  31569. /**
  31570. * Gets a boolean indicating if this manager supports morphing of normals
  31571. */
  31572. get supportsNormals(): boolean;
  31573. /**
  31574. * Gets a boolean indicating if this manager supports morphing of tangents
  31575. */
  31576. get supportsTangents(): boolean;
  31577. /**
  31578. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31579. */
  31580. get supportsUVs(): boolean;
  31581. /**
  31582. * Gets the number of targets stored in this manager
  31583. */
  31584. get numTargets(): number;
  31585. /**
  31586. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31587. */
  31588. get numInfluencers(): number;
  31589. /**
  31590. * Gets the list of influences (one per target)
  31591. */
  31592. get influences(): Float32Array;
  31593. /**
  31594. * Gets the active target at specified index. An active target is a target with an influence > 0
  31595. * @param index defines the index to check
  31596. * @returns the requested target
  31597. */
  31598. getActiveTarget(index: number): MorphTarget;
  31599. /**
  31600. * Gets the target at specified index
  31601. * @param index defines the index to check
  31602. * @returns the requested target
  31603. */
  31604. getTarget(index: number): MorphTarget;
  31605. /**
  31606. * Add a new target to this manager
  31607. * @param target defines the target to add
  31608. */
  31609. addTarget(target: MorphTarget): void;
  31610. /**
  31611. * Removes a target from the manager
  31612. * @param target defines the target to remove
  31613. */
  31614. removeTarget(target: MorphTarget): void;
  31615. /**
  31616. * Clone the current manager
  31617. * @returns a new MorphTargetManager
  31618. */
  31619. clone(): MorphTargetManager;
  31620. /**
  31621. * Serializes the current manager into a Serialization object
  31622. * @returns the serialized object
  31623. */
  31624. serialize(): any;
  31625. private _syncActiveTargets;
  31626. /**
  31627. * Syncrhonize the targets with all the meshes using this morph target manager
  31628. */
  31629. synchronize(): void;
  31630. /**
  31631. * Creates a new MorphTargetManager from serialized data
  31632. * @param serializationObject defines the serialized data
  31633. * @param scene defines the hosting scene
  31634. * @returns the new MorphTargetManager
  31635. */
  31636. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31637. }
  31638. }
  31639. declare module BABYLON {
  31640. /**
  31641. * Class used to represent a specific level of detail of a mesh
  31642. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31643. */
  31644. export class MeshLODLevel {
  31645. /** Defines the distance where this level should start being displayed */
  31646. distance: number;
  31647. /** Defines the mesh to use to render this level */
  31648. mesh: Nullable<Mesh>;
  31649. /**
  31650. * Creates a new LOD level
  31651. * @param distance defines the distance where this level should star being displayed
  31652. * @param mesh defines the mesh to use to render this level
  31653. */
  31654. constructor(
  31655. /** Defines the distance where this level should start being displayed */
  31656. distance: number,
  31657. /** Defines the mesh to use to render this level */
  31658. mesh: Nullable<Mesh>);
  31659. }
  31660. }
  31661. declare module BABYLON {
  31662. /**
  31663. * Helper class used to generate a canvas to manipulate images
  31664. */
  31665. export class CanvasGenerator {
  31666. /**
  31667. * Create a new canvas (or offscreen canvas depending on the context)
  31668. * @param width defines the expected width
  31669. * @param height defines the expected height
  31670. * @return a new canvas or offscreen canvas
  31671. */
  31672. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31673. }
  31674. }
  31675. declare module BABYLON {
  31676. /**
  31677. * Mesh representing the gorund
  31678. */
  31679. export class GroundMesh extends Mesh {
  31680. /** If octree should be generated */
  31681. generateOctree: boolean;
  31682. private _heightQuads;
  31683. /** @hidden */
  31684. _subdivisionsX: number;
  31685. /** @hidden */
  31686. _subdivisionsY: number;
  31687. /** @hidden */
  31688. _width: number;
  31689. /** @hidden */
  31690. _height: number;
  31691. /** @hidden */
  31692. _minX: number;
  31693. /** @hidden */
  31694. _maxX: number;
  31695. /** @hidden */
  31696. _minZ: number;
  31697. /** @hidden */
  31698. _maxZ: number;
  31699. constructor(name: string, scene: Scene);
  31700. /**
  31701. * "GroundMesh"
  31702. * @returns "GroundMesh"
  31703. */
  31704. getClassName(): string;
  31705. /**
  31706. * The minimum of x and y subdivisions
  31707. */
  31708. get subdivisions(): number;
  31709. /**
  31710. * X subdivisions
  31711. */
  31712. get subdivisionsX(): number;
  31713. /**
  31714. * Y subdivisions
  31715. */
  31716. get subdivisionsY(): number;
  31717. /**
  31718. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31719. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31720. * @param chunksCount the number of subdivisions for x and y
  31721. * @param octreeBlocksSize (Default: 32)
  31722. */
  31723. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31724. /**
  31725. * Returns a height (y) value in the Worl system :
  31726. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31727. * @param x x coordinate
  31728. * @param z z coordinate
  31729. * @returns the ground y position if (x, z) are outside the ground surface.
  31730. */
  31731. getHeightAtCoordinates(x: number, z: number): number;
  31732. /**
  31733. * Returns a normalized vector (Vector3) orthogonal to the ground
  31734. * at the ground coordinates (x, z) expressed in the World system.
  31735. * @param x x coordinate
  31736. * @param z z coordinate
  31737. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31738. */
  31739. getNormalAtCoordinates(x: number, z: number): Vector3;
  31740. /**
  31741. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31742. * at the ground coordinates (x, z) expressed in the World system.
  31743. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31744. * @param x x coordinate
  31745. * @param z z coordinate
  31746. * @param ref vector to store the result
  31747. * @returns the GroundMesh.
  31748. */
  31749. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31750. /**
  31751. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31752. * if the ground has been updated.
  31753. * This can be used in the render loop.
  31754. * @returns the GroundMesh.
  31755. */
  31756. updateCoordinateHeights(): GroundMesh;
  31757. private _getFacetAt;
  31758. private _initHeightQuads;
  31759. private _computeHeightQuads;
  31760. /**
  31761. * Serializes this ground mesh
  31762. * @param serializationObject object to write serialization to
  31763. */
  31764. serialize(serializationObject: any): void;
  31765. /**
  31766. * Parses a serialized ground mesh
  31767. * @param parsedMesh the serialized mesh
  31768. * @param scene the scene to create the ground mesh in
  31769. * @returns the created ground mesh
  31770. */
  31771. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31772. }
  31773. }
  31774. declare module BABYLON {
  31775. /**
  31776. * Interface for Physics-Joint data
  31777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31778. */
  31779. export interface PhysicsJointData {
  31780. /**
  31781. * The main pivot of the joint
  31782. */
  31783. mainPivot?: Vector3;
  31784. /**
  31785. * The connected pivot of the joint
  31786. */
  31787. connectedPivot?: Vector3;
  31788. /**
  31789. * The main axis of the joint
  31790. */
  31791. mainAxis?: Vector3;
  31792. /**
  31793. * The connected axis of the joint
  31794. */
  31795. connectedAxis?: Vector3;
  31796. /**
  31797. * The collision of the joint
  31798. */
  31799. collision?: boolean;
  31800. /**
  31801. * Native Oimo/Cannon/Energy data
  31802. */
  31803. nativeParams?: any;
  31804. }
  31805. /**
  31806. * This is a holder class for the physics joint created by the physics plugin
  31807. * It holds a set of functions to control the underlying joint
  31808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31809. */
  31810. export class PhysicsJoint {
  31811. /**
  31812. * The type of the physics joint
  31813. */
  31814. type: number;
  31815. /**
  31816. * The data for the physics joint
  31817. */
  31818. jointData: PhysicsJointData;
  31819. private _physicsJoint;
  31820. protected _physicsPlugin: IPhysicsEnginePlugin;
  31821. /**
  31822. * Initializes the physics joint
  31823. * @param type The type of the physics joint
  31824. * @param jointData The data for the physics joint
  31825. */
  31826. constructor(
  31827. /**
  31828. * The type of the physics joint
  31829. */
  31830. type: number,
  31831. /**
  31832. * The data for the physics joint
  31833. */
  31834. jointData: PhysicsJointData);
  31835. /**
  31836. * Gets the physics joint
  31837. */
  31838. get physicsJoint(): any;
  31839. /**
  31840. * Sets the physics joint
  31841. */
  31842. set physicsJoint(newJoint: any);
  31843. /**
  31844. * Sets the physics plugin
  31845. */
  31846. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31847. /**
  31848. * Execute a function that is physics-plugin specific.
  31849. * @param {Function} func the function that will be executed.
  31850. * It accepts two parameters: the physics world and the physics joint
  31851. */
  31852. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31853. /**
  31854. * Distance-Joint type
  31855. */
  31856. static DistanceJoint: number;
  31857. /**
  31858. * Hinge-Joint type
  31859. */
  31860. static HingeJoint: number;
  31861. /**
  31862. * Ball-and-Socket joint type
  31863. */
  31864. static BallAndSocketJoint: number;
  31865. /**
  31866. * Wheel-Joint type
  31867. */
  31868. static WheelJoint: number;
  31869. /**
  31870. * Slider-Joint type
  31871. */
  31872. static SliderJoint: number;
  31873. /**
  31874. * Prismatic-Joint type
  31875. */
  31876. static PrismaticJoint: number;
  31877. /**
  31878. * Universal-Joint type
  31879. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31880. */
  31881. static UniversalJoint: number;
  31882. /**
  31883. * Hinge-Joint 2 type
  31884. */
  31885. static Hinge2Joint: number;
  31886. /**
  31887. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31888. */
  31889. static PointToPointJoint: number;
  31890. /**
  31891. * Spring-Joint type
  31892. */
  31893. static SpringJoint: number;
  31894. /**
  31895. * Lock-Joint type
  31896. */
  31897. static LockJoint: number;
  31898. }
  31899. /**
  31900. * A class representing a physics distance joint
  31901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31902. */
  31903. export class DistanceJoint extends PhysicsJoint {
  31904. /**
  31905. *
  31906. * @param jointData The data for the Distance-Joint
  31907. */
  31908. constructor(jointData: DistanceJointData);
  31909. /**
  31910. * Update the predefined distance.
  31911. * @param maxDistance The maximum preferred distance
  31912. * @param minDistance The minimum preferred distance
  31913. */
  31914. updateDistance(maxDistance: number, minDistance?: number): void;
  31915. }
  31916. /**
  31917. * Represents a Motor-Enabled Joint
  31918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31919. */
  31920. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31921. /**
  31922. * Initializes the Motor-Enabled Joint
  31923. * @param type The type of the joint
  31924. * @param jointData The physica joint data for the joint
  31925. */
  31926. constructor(type: number, jointData: PhysicsJointData);
  31927. /**
  31928. * Set the motor values.
  31929. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31930. * @param force the force to apply
  31931. * @param maxForce max force for this motor.
  31932. */
  31933. setMotor(force?: number, maxForce?: number): void;
  31934. /**
  31935. * Set the motor's limits.
  31936. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31937. * @param upperLimit The upper limit of the motor
  31938. * @param lowerLimit The lower limit of the motor
  31939. */
  31940. setLimit(upperLimit: number, lowerLimit?: number): void;
  31941. }
  31942. /**
  31943. * This class represents a single physics Hinge-Joint
  31944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31945. */
  31946. export class HingeJoint extends MotorEnabledJoint {
  31947. /**
  31948. * Initializes the Hinge-Joint
  31949. * @param jointData The joint data for the Hinge-Joint
  31950. */
  31951. constructor(jointData: PhysicsJointData);
  31952. /**
  31953. * Set the motor values.
  31954. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31955. * @param {number} force the force to apply
  31956. * @param {number} maxForce max force for this motor.
  31957. */
  31958. setMotor(force?: number, maxForce?: number): void;
  31959. /**
  31960. * Set the motor's limits.
  31961. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31962. * @param upperLimit The upper limit of the motor
  31963. * @param lowerLimit The lower limit of the motor
  31964. */
  31965. setLimit(upperLimit: number, lowerLimit?: number): void;
  31966. }
  31967. /**
  31968. * This class represents a dual hinge physics joint (same as wheel joint)
  31969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31970. */
  31971. export class Hinge2Joint extends MotorEnabledJoint {
  31972. /**
  31973. * Initializes the Hinge2-Joint
  31974. * @param jointData The joint data for the Hinge2-Joint
  31975. */
  31976. constructor(jointData: PhysicsJointData);
  31977. /**
  31978. * Set the motor values.
  31979. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31980. * @param {number} targetSpeed the speed the motor is to reach
  31981. * @param {number} maxForce max force for this motor.
  31982. * @param {motorIndex} the motor's index, 0 or 1.
  31983. */
  31984. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31985. /**
  31986. * Set the motor limits.
  31987. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31988. * @param {number} upperLimit the upper limit
  31989. * @param {number} lowerLimit lower limit
  31990. * @param {motorIndex} the motor's index, 0 or 1.
  31991. */
  31992. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31993. }
  31994. /**
  31995. * Interface for a motor enabled joint
  31996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31997. */
  31998. export interface IMotorEnabledJoint {
  31999. /**
  32000. * Physics joint
  32001. */
  32002. physicsJoint: any;
  32003. /**
  32004. * Sets the motor of the motor-enabled joint
  32005. * @param force The force of the motor
  32006. * @param maxForce The maximum force of the motor
  32007. * @param motorIndex The index of the motor
  32008. */
  32009. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32010. /**
  32011. * Sets the limit of the motor
  32012. * @param upperLimit The upper limit of the motor
  32013. * @param lowerLimit The lower limit of the motor
  32014. * @param motorIndex The index of the motor
  32015. */
  32016. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32017. }
  32018. /**
  32019. * Joint data for a Distance-Joint
  32020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32021. */
  32022. export interface DistanceJointData extends PhysicsJointData {
  32023. /**
  32024. * Max distance the 2 joint objects can be apart
  32025. */
  32026. maxDistance: number;
  32027. }
  32028. /**
  32029. * Joint data from a spring joint
  32030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32031. */
  32032. export interface SpringJointData extends PhysicsJointData {
  32033. /**
  32034. * Length of the spring
  32035. */
  32036. length: number;
  32037. /**
  32038. * Stiffness of the spring
  32039. */
  32040. stiffness: number;
  32041. /**
  32042. * Damping of the spring
  32043. */
  32044. damping: number;
  32045. /** this callback will be called when applying the force to the impostors. */
  32046. forceApplicationCallback: () => void;
  32047. }
  32048. }
  32049. declare module BABYLON {
  32050. /**
  32051. * Holds the data for the raycast result
  32052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32053. */
  32054. export class PhysicsRaycastResult {
  32055. private _hasHit;
  32056. private _hitDistance;
  32057. private _hitNormalWorld;
  32058. private _hitPointWorld;
  32059. private _rayFromWorld;
  32060. private _rayToWorld;
  32061. /**
  32062. * Gets if there was a hit
  32063. */
  32064. get hasHit(): boolean;
  32065. /**
  32066. * Gets the distance from the hit
  32067. */
  32068. get hitDistance(): number;
  32069. /**
  32070. * Gets the hit normal/direction in the world
  32071. */
  32072. get hitNormalWorld(): Vector3;
  32073. /**
  32074. * Gets the hit point in the world
  32075. */
  32076. get hitPointWorld(): Vector3;
  32077. /**
  32078. * Gets the ray "start point" of the ray in the world
  32079. */
  32080. get rayFromWorld(): Vector3;
  32081. /**
  32082. * Gets the ray "end point" of the ray in the world
  32083. */
  32084. get rayToWorld(): Vector3;
  32085. /**
  32086. * Sets the hit data (normal & point in world space)
  32087. * @param hitNormalWorld defines the normal in world space
  32088. * @param hitPointWorld defines the point in world space
  32089. */
  32090. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32091. /**
  32092. * Sets the distance from the start point to the hit point
  32093. * @param distance
  32094. */
  32095. setHitDistance(distance: number): void;
  32096. /**
  32097. * Calculates the distance manually
  32098. */
  32099. calculateHitDistance(): void;
  32100. /**
  32101. * Resets all the values to default
  32102. * @param from The from point on world space
  32103. * @param to The to point on world space
  32104. */
  32105. reset(from?: Vector3, to?: Vector3): void;
  32106. }
  32107. /**
  32108. * Interface for the size containing width and height
  32109. */
  32110. interface IXYZ {
  32111. /**
  32112. * X
  32113. */
  32114. x: number;
  32115. /**
  32116. * Y
  32117. */
  32118. y: number;
  32119. /**
  32120. * Z
  32121. */
  32122. z: number;
  32123. }
  32124. }
  32125. declare module BABYLON {
  32126. /**
  32127. * Interface used to describe a physics joint
  32128. */
  32129. export interface PhysicsImpostorJoint {
  32130. /** Defines the main impostor to which the joint is linked */
  32131. mainImpostor: PhysicsImpostor;
  32132. /** Defines the impostor that is connected to the main impostor using this joint */
  32133. connectedImpostor: PhysicsImpostor;
  32134. /** Defines the joint itself */
  32135. joint: PhysicsJoint;
  32136. }
  32137. /** @hidden */
  32138. export interface IPhysicsEnginePlugin {
  32139. world: any;
  32140. name: string;
  32141. setGravity(gravity: Vector3): void;
  32142. setTimeStep(timeStep: number): void;
  32143. getTimeStep(): number;
  32144. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32145. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32146. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32147. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32148. removePhysicsBody(impostor: PhysicsImpostor): void;
  32149. generateJoint(joint: PhysicsImpostorJoint): void;
  32150. removeJoint(joint: PhysicsImpostorJoint): void;
  32151. isSupported(): boolean;
  32152. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32153. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32154. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32155. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32156. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32157. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32158. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32159. getBodyMass(impostor: PhysicsImpostor): number;
  32160. getBodyFriction(impostor: PhysicsImpostor): number;
  32161. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32162. getBodyRestitution(impostor: PhysicsImpostor): number;
  32163. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32164. getBodyPressure?(impostor: PhysicsImpostor): number;
  32165. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32166. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32167. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32168. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32169. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32170. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32171. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32172. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32173. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32174. sleepBody(impostor: PhysicsImpostor): void;
  32175. wakeUpBody(impostor: PhysicsImpostor): void;
  32176. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32177. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32178. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32179. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32180. getRadius(impostor: PhysicsImpostor): number;
  32181. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32182. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32183. dispose(): void;
  32184. }
  32185. /**
  32186. * Interface used to define a physics engine
  32187. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32188. */
  32189. export interface IPhysicsEngine {
  32190. /**
  32191. * Gets the gravity vector used by the simulation
  32192. */
  32193. gravity: Vector3;
  32194. /**
  32195. * Sets the gravity vector used by the simulation
  32196. * @param gravity defines the gravity vector to use
  32197. */
  32198. setGravity(gravity: Vector3): void;
  32199. /**
  32200. * Set the time step of the physics engine.
  32201. * Default is 1/60.
  32202. * To slow it down, enter 1/600 for example.
  32203. * To speed it up, 1/30
  32204. * @param newTimeStep the new timestep to apply to this world.
  32205. */
  32206. setTimeStep(newTimeStep: number): void;
  32207. /**
  32208. * Get the time step of the physics engine.
  32209. * @returns the current time step
  32210. */
  32211. getTimeStep(): number;
  32212. /**
  32213. * Set the sub time step of the physics engine.
  32214. * Default is 0 meaning there is no sub steps
  32215. * To increase physics resolution precision, set a small value (like 1 ms)
  32216. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32217. */
  32218. setSubTimeStep(subTimeStep: number): void;
  32219. /**
  32220. * Get the sub time step of the physics engine.
  32221. * @returns the current sub time step
  32222. */
  32223. getSubTimeStep(): number;
  32224. /**
  32225. * Release all resources
  32226. */
  32227. dispose(): void;
  32228. /**
  32229. * Gets the name of the current physics plugin
  32230. * @returns the name of the plugin
  32231. */
  32232. getPhysicsPluginName(): string;
  32233. /**
  32234. * Adding a new impostor for the impostor tracking.
  32235. * This will be done by the impostor itself.
  32236. * @param impostor the impostor to add
  32237. */
  32238. addImpostor(impostor: PhysicsImpostor): void;
  32239. /**
  32240. * Remove an impostor from the engine.
  32241. * This impostor and its mesh will not longer be updated by the physics engine.
  32242. * @param impostor the impostor to remove
  32243. */
  32244. removeImpostor(impostor: PhysicsImpostor): void;
  32245. /**
  32246. * Add a joint to the physics engine
  32247. * @param mainImpostor defines the main impostor to which the joint is added.
  32248. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32249. * @param joint defines the joint that will connect both impostors.
  32250. */
  32251. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32252. /**
  32253. * Removes a joint from the simulation
  32254. * @param mainImpostor defines the impostor used with the joint
  32255. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32256. * @param joint defines the joint to remove
  32257. */
  32258. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32259. /**
  32260. * Gets the current plugin used to run the simulation
  32261. * @returns current plugin
  32262. */
  32263. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32264. /**
  32265. * Gets the list of physic impostors
  32266. * @returns an array of PhysicsImpostor
  32267. */
  32268. getImpostors(): Array<PhysicsImpostor>;
  32269. /**
  32270. * Gets the impostor for a physics enabled object
  32271. * @param object defines the object impersonated by the impostor
  32272. * @returns the PhysicsImpostor or null if not found
  32273. */
  32274. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32275. /**
  32276. * Gets the impostor for a physics body object
  32277. * @param body defines physics body used by the impostor
  32278. * @returns the PhysicsImpostor or null if not found
  32279. */
  32280. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32281. /**
  32282. * Does a raycast in the physics world
  32283. * @param from when should the ray start?
  32284. * @param to when should the ray end?
  32285. * @returns PhysicsRaycastResult
  32286. */
  32287. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32288. /**
  32289. * Called by the scene. No need to call it.
  32290. * @param delta defines the timespam between frames
  32291. */
  32292. _step(delta: number): void;
  32293. }
  32294. }
  32295. declare module BABYLON {
  32296. /**
  32297. * The interface for the physics imposter parameters
  32298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32299. */
  32300. export interface PhysicsImpostorParameters {
  32301. /**
  32302. * The mass of the physics imposter
  32303. */
  32304. mass: number;
  32305. /**
  32306. * The friction of the physics imposter
  32307. */
  32308. friction?: number;
  32309. /**
  32310. * The coefficient of restitution of the physics imposter
  32311. */
  32312. restitution?: number;
  32313. /**
  32314. * The native options of the physics imposter
  32315. */
  32316. nativeOptions?: any;
  32317. /**
  32318. * Specifies if the parent should be ignored
  32319. */
  32320. ignoreParent?: boolean;
  32321. /**
  32322. * Specifies if bi-directional transformations should be disabled
  32323. */
  32324. disableBidirectionalTransformation?: boolean;
  32325. /**
  32326. * The pressure inside the physics imposter, soft object only
  32327. */
  32328. pressure?: number;
  32329. /**
  32330. * The stiffness the physics imposter, soft object only
  32331. */
  32332. stiffness?: number;
  32333. /**
  32334. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32335. */
  32336. velocityIterations?: number;
  32337. /**
  32338. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32339. */
  32340. positionIterations?: number;
  32341. /**
  32342. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32343. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32344. * Add to fix multiple points
  32345. */
  32346. fixedPoints?: number;
  32347. /**
  32348. * The collision margin around a soft object
  32349. */
  32350. margin?: number;
  32351. /**
  32352. * The collision margin around a soft object
  32353. */
  32354. damping?: number;
  32355. /**
  32356. * The path for a rope based on an extrusion
  32357. */
  32358. path?: any;
  32359. /**
  32360. * The shape of an extrusion used for a rope based on an extrusion
  32361. */
  32362. shape?: any;
  32363. }
  32364. /**
  32365. * Interface for a physics-enabled object
  32366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32367. */
  32368. export interface IPhysicsEnabledObject {
  32369. /**
  32370. * The position of the physics-enabled object
  32371. */
  32372. position: Vector3;
  32373. /**
  32374. * The rotation of the physics-enabled object
  32375. */
  32376. rotationQuaternion: Nullable<Quaternion>;
  32377. /**
  32378. * The scale of the physics-enabled object
  32379. */
  32380. scaling: Vector3;
  32381. /**
  32382. * The rotation of the physics-enabled object
  32383. */
  32384. rotation?: Vector3;
  32385. /**
  32386. * The parent of the physics-enabled object
  32387. */
  32388. parent?: any;
  32389. /**
  32390. * The bounding info of the physics-enabled object
  32391. * @returns The bounding info of the physics-enabled object
  32392. */
  32393. getBoundingInfo(): BoundingInfo;
  32394. /**
  32395. * Computes the world matrix
  32396. * @param force Specifies if the world matrix should be computed by force
  32397. * @returns A world matrix
  32398. */
  32399. computeWorldMatrix(force: boolean): Matrix;
  32400. /**
  32401. * Gets the world matrix
  32402. * @returns A world matrix
  32403. */
  32404. getWorldMatrix?(): Matrix;
  32405. /**
  32406. * Gets the child meshes
  32407. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32408. * @returns An array of abstract meshes
  32409. */
  32410. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32411. /**
  32412. * Gets the vertex data
  32413. * @param kind The type of vertex data
  32414. * @returns A nullable array of numbers, or a float32 array
  32415. */
  32416. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32417. /**
  32418. * Gets the indices from the mesh
  32419. * @returns A nullable array of index arrays
  32420. */
  32421. getIndices?(): Nullable<IndicesArray>;
  32422. /**
  32423. * Gets the scene from the mesh
  32424. * @returns the indices array or null
  32425. */
  32426. getScene?(): Scene;
  32427. /**
  32428. * Gets the absolute position from the mesh
  32429. * @returns the absolute position
  32430. */
  32431. getAbsolutePosition(): Vector3;
  32432. /**
  32433. * Gets the absolute pivot point from the mesh
  32434. * @returns the absolute pivot point
  32435. */
  32436. getAbsolutePivotPoint(): Vector3;
  32437. /**
  32438. * Rotates the mesh
  32439. * @param axis The axis of rotation
  32440. * @param amount The amount of rotation
  32441. * @param space The space of the rotation
  32442. * @returns The rotation transform node
  32443. */
  32444. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32445. /**
  32446. * Translates the mesh
  32447. * @param axis The axis of translation
  32448. * @param distance The distance of translation
  32449. * @param space The space of the translation
  32450. * @returns The transform node
  32451. */
  32452. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32453. /**
  32454. * Sets the absolute position of the mesh
  32455. * @param absolutePosition The absolute position of the mesh
  32456. * @returns The transform node
  32457. */
  32458. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32459. /**
  32460. * Gets the class name of the mesh
  32461. * @returns The class name
  32462. */
  32463. getClassName(): string;
  32464. }
  32465. /**
  32466. * Represents a physics imposter
  32467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32468. */
  32469. export class PhysicsImpostor {
  32470. /**
  32471. * The physics-enabled object used as the physics imposter
  32472. */
  32473. object: IPhysicsEnabledObject;
  32474. /**
  32475. * The type of the physics imposter
  32476. */
  32477. type: number;
  32478. private _options;
  32479. private _scene?;
  32480. /**
  32481. * The default object size of the imposter
  32482. */
  32483. static DEFAULT_OBJECT_SIZE: Vector3;
  32484. /**
  32485. * The identity quaternion of the imposter
  32486. */
  32487. static IDENTITY_QUATERNION: Quaternion;
  32488. /** @hidden */
  32489. _pluginData: any;
  32490. private _physicsEngine;
  32491. private _physicsBody;
  32492. private _bodyUpdateRequired;
  32493. private _onBeforePhysicsStepCallbacks;
  32494. private _onAfterPhysicsStepCallbacks;
  32495. /** @hidden */
  32496. _onPhysicsCollideCallbacks: Array<{
  32497. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32498. otherImpostors: Array<PhysicsImpostor>;
  32499. }>;
  32500. private _deltaPosition;
  32501. private _deltaRotation;
  32502. private _deltaRotationConjugated;
  32503. /** @hidden */
  32504. _isFromLine: boolean;
  32505. private _parent;
  32506. private _isDisposed;
  32507. private static _tmpVecs;
  32508. private static _tmpQuat;
  32509. /**
  32510. * Specifies if the physics imposter is disposed
  32511. */
  32512. get isDisposed(): boolean;
  32513. /**
  32514. * Gets the mass of the physics imposter
  32515. */
  32516. get mass(): number;
  32517. set mass(value: number);
  32518. /**
  32519. * Gets the coefficient of friction
  32520. */
  32521. get friction(): number;
  32522. /**
  32523. * Sets the coefficient of friction
  32524. */
  32525. set friction(value: number);
  32526. /**
  32527. * Gets the coefficient of restitution
  32528. */
  32529. get restitution(): number;
  32530. /**
  32531. * Sets the coefficient of restitution
  32532. */
  32533. set restitution(value: number);
  32534. /**
  32535. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32536. */
  32537. get pressure(): number;
  32538. /**
  32539. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32540. */
  32541. set pressure(value: number);
  32542. /**
  32543. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32544. */
  32545. get stiffness(): number;
  32546. /**
  32547. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32548. */
  32549. set stiffness(value: number);
  32550. /**
  32551. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32552. */
  32553. get velocityIterations(): number;
  32554. /**
  32555. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32556. */
  32557. set velocityIterations(value: number);
  32558. /**
  32559. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32560. */
  32561. get positionIterations(): number;
  32562. /**
  32563. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32564. */
  32565. set positionIterations(value: number);
  32566. /**
  32567. * The unique id of the physics imposter
  32568. * set by the physics engine when adding this impostor to the array
  32569. */
  32570. uniqueId: number;
  32571. /**
  32572. * @hidden
  32573. */
  32574. soft: boolean;
  32575. /**
  32576. * @hidden
  32577. */
  32578. segments: number;
  32579. private _joints;
  32580. /**
  32581. * Initializes the physics imposter
  32582. * @param object The physics-enabled object used as the physics imposter
  32583. * @param type The type of the physics imposter
  32584. * @param _options The options for the physics imposter
  32585. * @param _scene The Babylon scene
  32586. */
  32587. constructor(
  32588. /**
  32589. * The physics-enabled object used as the physics imposter
  32590. */
  32591. object: IPhysicsEnabledObject,
  32592. /**
  32593. * The type of the physics imposter
  32594. */
  32595. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32596. /**
  32597. * This function will completly initialize this impostor.
  32598. * It will create a new body - but only if this mesh has no parent.
  32599. * If it has, this impostor will not be used other than to define the impostor
  32600. * of the child mesh.
  32601. * @hidden
  32602. */
  32603. _init(): void;
  32604. private _getPhysicsParent;
  32605. /**
  32606. * Should a new body be generated.
  32607. * @returns boolean specifying if body initialization is required
  32608. */
  32609. isBodyInitRequired(): boolean;
  32610. /**
  32611. * Sets the updated scaling
  32612. * @param updated Specifies if the scaling is updated
  32613. */
  32614. setScalingUpdated(): void;
  32615. /**
  32616. * Force a regeneration of this or the parent's impostor's body.
  32617. * Use under cautious - This will remove all joints already implemented.
  32618. */
  32619. forceUpdate(): void;
  32620. /**
  32621. * Gets the body that holds this impostor. Either its own, or its parent.
  32622. */
  32623. get physicsBody(): any;
  32624. /**
  32625. * Get the parent of the physics imposter
  32626. * @returns Physics imposter or null
  32627. */
  32628. get parent(): Nullable<PhysicsImpostor>;
  32629. /**
  32630. * Sets the parent of the physics imposter
  32631. */
  32632. set parent(value: Nullable<PhysicsImpostor>);
  32633. /**
  32634. * Set the physics body. Used mainly by the physics engine/plugin
  32635. */
  32636. set physicsBody(physicsBody: any);
  32637. /**
  32638. * Resets the update flags
  32639. */
  32640. resetUpdateFlags(): void;
  32641. /**
  32642. * Gets the object extend size
  32643. * @returns the object extend size
  32644. */
  32645. getObjectExtendSize(): Vector3;
  32646. /**
  32647. * Gets the object center
  32648. * @returns The object center
  32649. */
  32650. getObjectCenter(): Vector3;
  32651. /**
  32652. * Get a specific parameter from the options parameters
  32653. * @param paramName The object parameter name
  32654. * @returns The object parameter
  32655. */
  32656. getParam(paramName: string): any;
  32657. /**
  32658. * Sets a specific parameter in the options given to the physics plugin
  32659. * @param paramName The parameter name
  32660. * @param value The value of the parameter
  32661. */
  32662. setParam(paramName: string, value: number): void;
  32663. /**
  32664. * Specifically change the body's mass option. Won't recreate the physics body object
  32665. * @param mass The mass of the physics imposter
  32666. */
  32667. setMass(mass: number): void;
  32668. /**
  32669. * Gets the linear velocity
  32670. * @returns linear velocity or null
  32671. */
  32672. getLinearVelocity(): Nullable<Vector3>;
  32673. /**
  32674. * Sets the linear velocity
  32675. * @param velocity linear velocity or null
  32676. */
  32677. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32678. /**
  32679. * Gets the angular velocity
  32680. * @returns angular velocity or null
  32681. */
  32682. getAngularVelocity(): Nullable<Vector3>;
  32683. /**
  32684. * Sets the angular velocity
  32685. * @param velocity The velocity or null
  32686. */
  32687. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32688. /**
  32689. * Execute a function with the physics plugin native code
  32690. * Provide a function the will have two variables - the world object and the physics body object
  32691. * @param func The function to execute with the physics plugin native code
  32692. */
  32693. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32694. /**
  32695. * Register a function that will be executed before the physics world is stepping forward
  32696. * @param func The function to execute before the physics world is stepped forward
  32697. */
  32698. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32699. /**
  32700. * Unregister a function that will be executed before the physics world is stepping forward
  32701. * @param func The function to execute before the physics world is stepped forward
  32702. */
  32703. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32704. /**
  32705. * Register a function that will be executed after the physics step
  32706. * @param func The function to execute after physics step
  32707. */
  32708. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32709. /**
  32710. * Unregisters a function that will be executed after the physics step
  32711. * @param func The function to execute after physics step
  32712. */
  32713. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32714. /**
  32715. * register a function that will be executed when this impostor collides against a different body
  32716. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32717. * @param func Callback that is executed on collision
  32718. */
  32719. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32720. /**
  32721. * Unregisters the physics imposter on contact
  32722. * @param collideAgainst The physics object to collide against
  32723. * @param func Callback to execute on collision
  32724. */
  32725. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32726. private _tmpQuat;
  32727. private _tmpQuat2;
  32728. /**
  32729. * Get the parent rotation
  32730. * @returns The parent rotation
  32731. */
  32732. getParentsRotation(): Quaternion;
  32733. /**
  32734. * this function is executed by the physics engine.
  32735. */
  32736. beforeStep: () => void;
  32737. /**
  32738. * this function is executed by the physics engine
  32739. */
  32740. afterStep: () => void;
  32741. /**
  32742. * Legacy collision detection event support
  32743. */
  32744. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32745. /**
  32746. * event and body object due to cannon's event-based architecture.
  32747. */
  32748. onCollide: (e: {
  32749. body: any;
  32750. point: Nullable<Vector3>;
  32751. }) => void;
  32752. /**
  32753. * Apply a force
  32754. * @param force The force to apply
  32755. * @param contactPoint The contact point for the force
  32756. * @returns The physics imposter
  32757. */
  32758. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32759. /**
  32760. * Apply an impulse
  32761. * @param force The impulse force
  32762. * @param contactPoint The contact point for the impulse force
  32763. * @returns The physics imposter
  32764. */
  32765. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32766. /**
  32767. * A help function to create a joint
  32768. * @param otherImpostor A physics imposter used to create a joint
  32769. * @param jointType The type of joint
  32770. * @param jointData The data for the joint
  32771. * @returns The physics imposter
  32772. */
  32773. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32774. /**
  32775. * Add a joint to this impostor with a different impostor
  32776. * @param otherImpostor A physics imposter used to add a joint
  32777. * @param joint The joint to add
  32778. * @returns The physics imposter
  32779. */
  32780. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32781. /**
  32782. * Add an anchor to a cloth impostor
  32783. * @param otherImpostor rigid impostor to anchor to
  32784. * @param width ratio across width from 0 to 1
  32785. * @param height ratio up height from 0 to 1
  32786. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32787. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32788. * @returns impostor the soft imposter
  32789. */
  32790. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32791. /**
  32792. * Add a hook to a rope impostor
  32793. * @param otherImpostor rigid impostor to anchor to
  32794. * @param length ratio across rope from 0 to 1
  32795. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32796. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32797. * @returns impostor the rope imposter
  32798. */
  32799. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32800. /**
  32801. * Will keep this body still, in a sleep mode.
  32802. * @returns the physics imposter
  32803. */
  32804. sleep(): PhysicsImpostor;
  32805. /**
  32806. * Wake the body up.
  32807. * @returns The physics imposter
  32808. */
  32809. wakeUp(): PhysicsImpostor;
  32810. /**
  32811. * Clones the physics imposter
  32812. * @param newObject The physics imposter clones to this physics-enabled object
  32813. * @returns A nullable physics imposter
  32814. */
  32815. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32816. /**
  32817. * Disposes the physics imposter
  32818. */
  32819. dispose(): void;
  32820. /**
  32821. * Sets the delta position
  32822. * @param position The delta position amount
  32823. */
  32824. setDeltaPosition(position: Vector3): void;
  32825. /**
  32826. * Sets the delta rotation
  32827. * @param rotation The delta rotation amount
  32828. */
  32829. setDeltaRotation(rotation: Quaternion): void;
  32830. /**
  32831. * Gets the box size of the physics imposter and stores the result in the input parameter
  32832. * @param result Stores the box size
  32833. * @returns The physics imposter
  32834. */
  32835. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32836. /**
  32837. * Gets the radius of the physics imposter
  32838. * @returns Radius of the physics imposter
  32839. */
  32840. getRadius(): number;
  32841. /**
  32842. * Sync a bone with this impostor
  32843. * @param bone The bone to sync to the impostor.
  32844. * @param boneMesh The mesh that the bone is influencing.
  32845. * @param jointPivot The pivot of the joint / bone in local space.
  32846. * @param distToJoint Optional distance from the impostor to the joint.
  32847. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32848. */
  32849. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32850. /**
  32851. * Sync impostor to a bone
  32852. * @param bone The bone that the impostor will be synced to.
  32853. * @param boneMesh The mesh that the bone is influencing.
  32854. * @param jointPivot The pivot of the joint / bone in local space.
  32855. * @param distToJoint Optional distance from the impostor to the joint.
  32856. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32857. * @param boneAxis Optional vector3 axis the bone is aligned with
  32858. */
  32859. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32860. /**
  32861. * No-Imposter type
  32862. */
  32863. static NoImpostor: number;
  32864. /**
  32865. * Sphere-Imposter type
  32866. */
  32867. static SphereImpostor: number;
  32868. /**
  32869. * Box-Imposter type
  32870. */
  32871. static BoxImpostor: number;
  32872. /**
  32873. * Plane-Imposter type
  32874. */
  32875. static PlaneImpostor: number;
  32876. /**
  32877. * Mesh-imposter type
  32878. */
  32879. static MeshImpostor: number;
  32880. /**
  32881. * Capsule-Impostor type (Ammo.js plugin only)
  32882. */
  32883. static CapsuleImpostor: number;
  32884. /**
  32885. * Cylinder-Imposter type
  32886. */
  32887. static CylinderImpostor: number;
  32888. /**
  32889. * Particle-Imposter type
  32890. */
  32891. static ParticleImpostor: number;
  32892. /**
  32893. * Heightmap-Imposter type
  32894. */
  32895. static HeightmapImpostor: number;
  32896. /**
  32897. * ConvexHull-Impostor type (Ammo.js plugin only)
  32898. */
  32899. static ConvexHullImpostor: number;
  32900. /**
  32901. * Custom-Imposter type (Ammo.js plugin only)
  32902. */
  32903. static CustomImpostor: number;
  32904. /**
  32905. * Rope-Imposter type
  32906. */
  32907. static RopeImpostor: number;
  32908. /**
  32909. * Cloth-Imposter type
  32910. */
  32911. static ClothImpostor: number;
  32912. /**
  32913. * Softbody-Imposter type
  32914. */
  32915. static SoftbodyImpostor: number;
  32916. }
  32917. }
  32918. declare module BABYLON {
  32919. /**
  32920. * @hidden
  32921. **/
  32922. export class _CreationDataStorage {
  32923. closePath?: boolean;
  32924. closeArray?: boolean;
  32925. idx: number[];
  32926. dashSize: number;
  32927. gapSize: number;
  32928. path3D: Path3D;
  32929. pathArray: Vector3[][];
  32930. arc: number;
  32931. radius: number;
  32932. cap: number;
  32933. tessellation: number;
  32934. }
  32935. /**
  32936. * @hidden
  32937. **/
  32938. class _InstanceDataStorage {
  32939. visibleInstances: any;
  32940. batchCache: _InstancesBatch;
  32941. instancesBufferSize: number;
  32942. instancesBuffer: Nullable<Buffer>;
  32943. instancesData: Float32Array;
  32944. overridenInstanceCount: number;
  32945. isFrozen: boolean;
  32946. previousBatch: Nullable<_InstancesBatch>;
  32947. hardwareInstancedRendering: boolean;
  32948. sideOrientation: number;
  32949. manualUpdate: boolean;
  32950. previousRenderId: number;
  32951. }
  32952. /**
  32953. * @hidden
  32954. **/
  32955. export class _InstancesBatch {
  32956. mustReturn: boolean;
  32957. visibleInstances: Nullable<InstancedMesh[]>[];
  32958. renderSelf: boolean[];
  32959. hardwareInstancedRendering: boolean[];
  32960. }
  32961. /**
  32962. * @hidden
  32963. **/
  32964. class _ThinInstanceDataStorage {
  32965. instancesCount: number;
  32966. matrixBuffer: Nullable<Buffer>;
  32967. matrixBufferSize: number;
  32968. matrixData: Nullable<Float32Array>;
  32969. boundingVectors: Array<Vector3>;
  32970. worldMatrices: Nullable<Matrix[]>;
  32971. }
  32972. /**
  32973. * Class used to represent renderable models
  32974. */
  32975. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32976. /**
  32977. * Mesh side orientation : usually the external or front surface
  32978. */
  32979. static readonly FRONTSIDE: number;
  32980. /**
  32981. * Mesh side orientation : usually the internal or back surface
  32982. */
  32983. static readonly BACKSIDE: number;
  32984. /**
  32985. * Mesh side orientation : both internal and external or front and back surfaces
  32986. */
  32987. static readonly DOUBLESIDE: number;
  32988. /**
  32989. * Mesh side orientation : by default, `FRONTSIDE`
  32990. */
  32991. static readonly DEFAULTSIDE: number;
  32992. /**
  32993. * Mesh cap setting : no cap
  32994. */
  32995. static readonly NO_CAP: number;
  32996. /**
  32997. * Mesh cap setting : one cap at the beginning of the mesh
  32998. */
  32999. static readonly CAP_START: number;
  33000. /**
  33001. * Mesh cap setting : one cap at the end of the mesh
  33002. */
  33003. static readonly CAP_END: number;
  33004. /**
  33005. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33006. */
  33007. static readonly CAP_ALL: number;
  33008. /**
  33009. * Mesh pattern setting : no flip or rotate
  33010. */
  33011. static readonly NO_FLIP: number;
  33012. /**
  33013. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33014. */
  33015. static readonly FLIP_TILE: number;
  33016. /**
  33017. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33018. */
  33019. static readonly ROTATE_TILE: number;
  33020. /**
  33021. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33022. */
  33023. static readonly FLIP_ROW: number;
  33024. /**
  33025. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33026. */
  33027. static readonly ROTATE_ROW: number;
  33028. /**
  33029. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33030. */
  33031. static readonly FLIP_N_ROTATE_TILE: number;
  33032. /**
  33033. * Mesh pattern setting : rotate pattern and rotate
  33034. */
  33035. static readonly FLIP_N_ROTATE_ROW: number;
  33036. /**
  33037. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33038. */
  33039. static readonly CENTER: number;
  33040. /**
  33041. * Mesh tile positioning : part tiles on left
  33042. */
  33043. static readonly LEFT: number;
  33044. /**
  33045. * Mesh tile positioning : part tiles on right
  33046. */
  33047. static readonly RIGHT: number;
  33048. /**
  33049. * Mesh tile positioning : part tiles on top
  33050. */
  33051. static readonly TOP: number;
  33052. /**
  33053. * Mesh tile positioning : part tiles on bottom
  33054. */
  33055. static readonly BOTTOM: number;
  33056. /**
  33057. * Gets the default side orientation.
  33058. * @param orientation the orientation to value to attempt to get
  33059. * @returns the default orientation
  33060. * @hidden
  33061. */
  33062. static _GetDefaultSideOrientation(orientation?: number): number;
  33063. private _internalMeshDataInfo;
  33064. get computeBonesUsingShaders(): boolean;
  33065. set computeBonesUsingShaders(value: boolean);
  33066. /**
  33067. * An event triggered before rendering the mesh
  33068. */
  33069. get onBeforeRenderObservable(): Observable<Mesh>;
  33070. /**
  33071. * An event triggered before binding the mesh
  33072. */
  33073. get onBeforeBindObservable(): Observable<Mesh>;
  33074. /**
  33075. * An event triggered after rendering the mesh
  33076. */
  33077. get onAfterRenderObservable(): Observable<Mesh>;
  33078. /**
  33079. * An event triggered before drawing the mesh
  33080. */
  33081. get onBeforeDrawObservable(): Observable<Mesh>;
  33082. private _onBeforeDrawObserver;
  33083. /**
  33084. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33085. */
  33086. set onBeforeDraw(callback: () => void);
  33087. get hasInstances(): boolean;
  33088. get hasThinInstances(): boolean;
  33089. /**
  33090. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33091. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33092. */
  33093. delayLoadState: number;
  33094. /**
  33095. * Gets the list of instances created from this mesh
  33096. * it is not supposed to be modified manually.
  33097. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33098. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33099. */
  33100. instances: InstancedMesh[];
  33101. /**
  33102. * Gets the file containing delay loading data for this mesh
  33103. */
  33104. delayLoadingFile: string;
  33105. /** @hidden */
  33106. _binaryInfo: any;
  33107. /**
  33108. * User defined function used to change how LOD level selection is done
  33109. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33110. */
  33111. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33112. /**
  33113. * Gets or sets the morph target manager
  33114. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33115. */
  33116. get morphTargetManager(): Nullable<MorphTargetManager>;
  33117. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33118. /** @hidden */
  33119. _creationDataStorage: Nullable<_CreationDataStorage>;
  33120. /** @hidden */
  33121. _geometry: Nullable<Geometry>;
  33122. /** @hidden */
  33123. _delayInfo: Array<string>;
  33124. /** @hidden */
  33125. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33126. /** @hidden */
  33127. _instanceDataStorage: _InstanceDataStorage;
  33128. /** @hidden */
  33129. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33130. private _effectiveMaterial;
  33131. /** @hidden */
  33132. _shouldGenerateFlatShading: boolean;
  33133. /** @hidden */
  33134. _originalBuilderSideOrientation: number;
  33135. /**
  33136. * Use this property to change the original side orientation defined at construction time
  33137. */
  33138. overrideMaterialSideOrientation: Nullable<number>;
  33139. /**
  33140. * Gets the source mesh (the one used to clone this one from)
  33141. */
  33142. get source(): Nullable<Mesh>;
  33143. /**
  33144. * Gets the list of clones of this mesh
  33145. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33146. * Note that useClonedMeshMap=true is the default setting
  33147. */
  33148. get cloneMeshMap(): Nullable<{
  33149. [id: string]: Mesh | undefined;
  33150. }>;
  33151. /**
  33152. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33153. */
  33154. get isUnIndexed(): boolean;
  33155. set isUnIndexed(value: boolean);
  33156. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33157. get worldMatrixInstancedBuffer(): Float32Array;
  33158. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33159. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33160. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33161. /**
  33162. * @constructor
  33163. * @param name The value used by scene.getMeshByName() to do a lookup.
  33164. * @param scene The scene to add this mesh to.
  33165. * @param parent The parent of this mesh, if it has one
  33166. * @param source An optional Mesh from which geometry is shared, cloned.
  33167. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33168. * When false, achieved by calling a clone(), also passing False.
  33169. * This will make creation of children, recursive.
  33170. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33171. */
  33172. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33173. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33174. doNotInstantiate: boolean;
  33175. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33176. /**
  33177. * Gets the class name
  33178. * @returns the string "Mesh".
  33179. */
  33180. getClassName(): string;
  33181. /** @hidden */
  33182. get _isMesh(): boolean;
  33183. /**
  33184. * Returns a description of this mesh
  33185. * @param fullDetails define if full details about this mesh must be used
  33186. * @returns a descriptive string representing this mesh
  33187. */
  33188. toString(fullDetails?: boolean): string;
  33189. /** @hidden */
  33190. _unBindEffect(): void;
  33191. /**
  33192. * Gets a boolean indicating if this mesh has LOD
  33193. */
  33194. get hasLODLevels(): boolean;
  33195. /**
  33196. * Gets the list of MeshLODLevel associated with the current mesh
  33197. * @returns an array of MeshLODLevel
  33198. */
  33199. getLODLevels(): MeshLODLevel[];
  33200. private _sortLODLevels;
  33201. /**
  33202. * Add a mesh as LOD level triggered at the given distance.
  33203. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33204. * @param distance The distance from the center of the object to show this level
  33205. * @param mesh The mesh to be added as LOD level (can be null)
  33206. * @return This mesh (for chaining)
  33207. */
  33208. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33209. /**
  33210. * Returns the LOD level mesh at the passed distance or null if not found.
  33211. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33212. * @param distance The distance from the center of the object to show this level
  33213. * @returns a Mesh or `null`
  33214. */
  33215. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33216. /**
  33217. * Remove a mesh from the LOD array
  33218. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33219. * @param mesh defines the mesh to be removed
  33220. * @return This mesh (for chaining)
  33221. */
  33222. removeLODLevel(mesh: Mesh): Mesh;
  33223. /**
  33224. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33225. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33226. * @param camera defines the camera to use to compute distance
  33227. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33228. * @return This mesh (for chaining)
  33229. */
  33230. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33231. /**
  33232. * Gets the mesh internal Geometry object
  33233. */
  33234. get geometry(): Nullable<Geometry>;
  33235. /**
  33236. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33237. * @returns the total number of vertices
  33238. */
  33239. getTotalVertices(): number;
  33240. /**
  33241. * Returns the content of an associated vertex buffer
  33242. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33243. * - VertexBuffer.PositionKind
  33244. * - VertexBuffer.UVKind
  33245. * - VertexBuffer.UV2Kind
  33246. * - VertexBuffer.UV3Kind
  33247. * - VertexBuffer.UV4Kind
  33248. * - VertexBuffer.UV5Kind
  33249. * - VertexBuffer.UV6Kind
  33250. * - VertexBuffer.ColorKind
  33251. * - VertexBuffer.MatricesIndicesKind
  33252. * - VertexBuffer.MatricesIndicesExtraKind
  33253. * - VertexBuffer.MatricesWeightsKind
  33254. * - VertexBuffer.MatricesWeightsExtraKind
  33255. * @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
  33256. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33257. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33258. */
  33259. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33260. /**
  33261. * Returns the mesh VertexBuffer object from the requested `kind`
  33262. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33263. * - VertexBuffer.PositionKind
  33264. * - VertexBuffer.NormalKind
  33265. * - VertexBuffer.UVKind
  33266. * - VertexBuffer.UV2Kind
  33267. * - VertexBuffer.UV3Kind
  33268. * - VertexBuffer.UV4Kind
  33269. * - VertexBuffer.UV5Kind
  33270. * - VertexBuffer.UV6Kind
  33271. * - VertexBuffer.ColorKind
  33272. * - VertexBuffer.MatricesIndicesKind
  33273. * - VertexBuffer.MatricesIndicesExtraKind
  33274. * - VertexBuffer.MatricesWeightsKind
  33275. * - VertexBuffer.MatricesWeightsExtraKind
  33276. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33277. */
  33278. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33279. /**
  33280. * Tests if a specific vertex buffer is associated with this mesh
  33281. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33282. * - VertexBuffer.PositionKind
  33283. * - VertexBuffer.NormalKind
  33284. * - VertexBuffer.UVKind
  33285. * - VertexBuffer.UV2Kind
  33286. * - VertexBuffer.UV3Kind
  33287. * - VertexBuffer.UV4Kind
  33288. * - VertexBuffer.UV5Kind
  33289. * - VertexBuffer.UV6Kind
  33290. * - VertexBuffer.ColorKind
  33291. * - VertexBuffer.MatricesIndicesKind
  33292. * - VertexBuffer.MatricesIndicesExtraKind
  33293. * - VertexBuffer.MatricesWeightsKind
  33294. * - VertexBuffer.MatricesWeightsExtraKind
  33295. * @returns a boolean
  33296. */
  33297. isVerticesDataPresent(kind: string): boolean;
  33298. /**
  33299. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33300. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33301. * - VertexBuffer.PositionKind
  33302. * - VertexBuffer.UVKind
  33303. * - VertexBuffer.UV2Kind
  33304. * - VertexBuffer.UV3Kind
  33305. * - VertexBuffer.UV4Kind
  33306. * - VertexBuffer.UV5Kind
  33307. * - VertexBuffer.UV6Kind
  33308. * - VertexBuffer.ColorKind
  33309. * - VertexBuffer.MatricesIndicesKind
  33310. * - VertexBuffer.MatricesIndicesExtraKind
  33311. * - VertexBuffer.MatricesWeightsKind
  33312. * - VertexBuffer.MatricesWeightsExtraKind
  33313. * @returns a boolean
  33314. */
  33315. isVertexBufferUpdatable(kind: string): boolean;
  33316. /**
  33317. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33318. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33319. * - VertexBuffer.PositionKind
  33320. * - VertexBuffer.NormalKind
  33321. * - VertexBuffer.UVKind
  33322. * - VertexBuffer.UV2Kind
  33323. * - VertexBuffer.UV3Kind
  33324. * - VertexBuffer.UV4Kind
  33325. * - VertexBuffer.UV5Kind
  33326. * - VertexBuffer.UV6Kind
  33327. * - VertexBuffer.ColorKind
  33328. * - VertexBuffer.MatricesIndicesKind
  33329. * - VertexBuffer.MatricesIndicesExtraKind
  33330. * - VertexBuffer.MatricesWeightsKind
  33331. * - VertexBuffer.MatricesWeightsExtraKind
  33332. * @returns an array of strings
  33333. */
  33334. getVerticesDataKinds(): string[];
  33335. /**
  33336. * Returns a positive integer : the total number of indices in this mesh geometry.
  33337. * @returns the numner of indices or zero if the mesh has no geometry.
  33338. */
  33339. getTotalIndices(): number;
  33340. /**
  33341. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33342. * @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.
  33343. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33344. * @returns the indices array or an empty array if the mesh has no geometry
  33345. */
  33346. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33347. get isBlocked(): boolean;
  33348. /**
  33349. * Determine if the current mesh is ready to be rendered
  33350. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33351. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33352. * @returns true if all associated assets are ready (material, textures, shaders)
  33353. */
  33354. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33355. /**
  33356. * 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.
  33357. */
  33358. get areNormalsFrozen(): boolean;
  33359. /**
  33360. * 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.
  33361. * @returns the current mesh
  33362. */
  33363. freezeNormals(): Mesh;
  33364. /**
  33365. * 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
  33366. * @returns the current mesh
  33367. */
  33368. unfreezeNormals(): Mesh;
  33369. /**
  33370. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33371. */
  33372. set overridenInstanceCount(count: number);
  33373. /** @hidden */
  33374. _preActivate(): Mesh;
  33375. /** @hidden */
  33376. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33377. /** @hidden */
  33378. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33379. protected _afterComputeWorldMatrix(): void;
  33380. /** @hidden */
  33381. _postActivate(): void;
  33382. /**
  33383. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33384. * This means the mesh underlying bounding box and sphere are recomputed.
  33385. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33386. * @returns the current mesh
  33387. */
  33388. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33389. /** @hidden */
  33390. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33391. /**
  33392. * This function will subdivide the mesh into multiple submeshes
  33393. * @param count defines the expected number of submeshes
  33394. */
  33395. subdivide(count: number): void;
  33396. /**
  33397. * Copy a FloatArray into a specific associated vertex buffer
  33398. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33399. * - VertexBuffer.PositionKind
  33400. * - VertexBuffer.UVKind
  33401. * - VertexBuffer.UV2Kind
  33402. * - VertexBuffer.UV3Kind
  33403. * - VertexBuffer.UV4Kind
  33404. * - VertexBuffer.UV5Kind
  33405. * - VertexBuffer.UV6Kind
  33406. * - VertexBuffer.ColorKind
  33407. * - VertexBuffer.MatricesIndicesKind
  33408. * - VertexBuffer.MatricesIndicesExtraKind
  33409. * - VertexBuffer.MatricesWeightsKind
  33410. * - VertexBuffer.MatricesWeightsExtraKind
  33411. * @param data defines the data source
  33412. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33413. * @param stride defines the data stride size (can be null)
  33414. * @returns the current mesh
  33415. */
  33416. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33417. /**
  33418. * Delete a vertex buffer associated with this mesh
  33419. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33420. * - VertexBuffer.PositionKind
  33421. * - VertexBuffer.UVKind
  33422. * - VertexBuffer.UV2Kind
  33423. * - VertexBuffer.UV3Kind
  33424. * - VertexBuffer.UV4Kind
  33425. * - VertexBuffer.UV5Kind
  33426. * - VertexBuffer.UV6Kind
  33427. * - VertexBuffer.ColorKind
  33428. * - VertexBuffer.MatricesIndicesKind
  33429. * - VertexBuffer.MatricesIndicesExtraKind
  33430. * - VertexBuffer.MatricesWeightsKind
  33431. * - VertexBuffer.MatricesWeightsExtraKind
  33432. */
  33433. removeVerticesData(kind: string): void;
  33434. /**
  33435. * Flags an associated vertex buffer as updatable
  33436. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33437. * - VertexBuffer.PositionKind
  33438. * - VertexBuffer.UVKind
  33439. * - VertexBuffer.UV2Kind
  33440. * - VertexBuffer.UV3Kind
  33441. * - VertexBuffer.UV4Kind
  33442. * - VertexBuffer.UV5Kind
  33443. * - VertexBuffer.UV6Kind
  33444. * - VertexBuffer.ColorKind
  33445. * - VertexBuffer.MatricesIndicesKind
  33446. * - VertexBuffer.MatricesIndicesExtraKind
  33447. * - VertexBuffer.MatricesWeightsKind
  33448. * - VertexBuffer.MatricesWeightsExtraKind
  33449. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33450. */
  33451. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33452. /**
  33453. * Sets the mesh global Vertex Buffer
  33454. * @param buffer defines the buffer to use
  33455. * @returns the current mesh
  33456. */
  33457. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33458. /**
  33459. * Update a specific associated vertex buffer
  33460. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33461. * - VertexBuffer.PositionKind
  33462. * - VertexBuffer.UVKind
  33463. * - VertexBuffer.UV2Kind
  33464. * - VertexBuffer.UV3Kind
  33465. * - VertexBuffer.UV4Kind
  33466. * - VertexBuffer.UV5Kind
  33467. * - VertexBuffer.UV6Kind
  33468. * - VertexBuffer.ColorKind
  33469. * - VertexBuffer.MatricesIndicesKind
  33470. * - VertexBuffer.MatricesIndicesExtraKind
  33471. * - VertexBuffer.MatricesWeightsKind
  33472. * - VertexBuffer.MatricesWeightsExtraKind
  33473. * @param data defines the data source
  33474. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33475. * @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)
  33476. * @returns the current mesh
  33477. */
  33478. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33479. /**
  33480. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33481. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33482. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33483. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33484. * @returns the current mesh
  33485. */
  33486. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33487. /**
  33488. * Creates a un-shared specific occurence of the geometry for the mesh.
  33489. * @returns the current mesh
  33490. */
  33491. makeGeometryUnique(): Mesh;
  33492. /**
  33493. * Set the index buffer of this mesh
  33494. * @param indices defines the source data
  33495. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33496. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33497. * @returns the current mesh
  33498. */
  33499. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33500. /**
  33501. * Update the current index buffer
  33502. * @param indices defines the source data
  33503. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33504. * @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)
  33505. * @returns the current mesh
  33506. */
  33507. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33508. /**
  33509. * Invert the geometry to move from a right handed system to a left handed one.
  33510. * @returns the current mesh
  33511. */
  33512. toLeftHanded(): Mesh;
  33513. /** @hidden */
  33514. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33515. /** @hidden */
  33516. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33517. /**
  33518. * Registers for this mesh a javascript function called just before the rendering process
  33519. * @param func defines the function to call before rendering this mesh
  33520. * @returns the current mesh
  33521. */
  33522. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33523. /**
  33524. * Disposes a previously registered javascript function called before the rendering
  33525. * @param func defines the function to remove
  33526. * @returns the current mesh
  33527. */
  33528. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33529. /**
  33530. * Registers for this mesh a javascript function called just after the rendering is complete
  33531. * @param func defines the function to call after rendering this mesh
  33532. * @returns the current mesh
  33533. */
  33534. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33535. /**
  33536. * Disposes a previously registered javascript function called after the rendering.
  33537. * @param func defines the function to remove
  33538. * @returns the current mesh
  33539. */
  33540. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33541. /** @hidden */
  33542. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33543. /** @hidden */
  33544. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33545. /** @hidden */
  33546. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33547. /** @hidden */
  33548. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33549. /** @hidden */
  33550. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33551. /** @hidden */
  33552. _rebuild(): void;
  33553. /** @hidden */
  33554. _freeze(): void;
  33555. /** @hidden */
  33556. _unFreeze(): void;
  33557. /**
  33558. * 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
  33559. * @param subMesh defines the subMesh to render
  33560. * @param enableAlphaMode defines if alpha mode can be changed
  33561. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33562. * @returns the current mesh
  33563. */
  33564. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33565. private _onBeforeDraw;
  33566. /**
  33567. * Renormalize the mesh and patch it up if there are no weights
  33568. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33569. * However in the case of zero weights then we set just a single influence to 1.
  33570. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33571. */
  33572. cleanMatrixWeights(): void;
  33573. private normalizeSkinFourWeights;
  33574. private normalizeSkinWeightsAndExtra;
  33575. /**
  33576. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33577. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33578. * the user know there was an issue with importing the mesh
  33579. * @returns a validation object with skinned, valid and report string
  33580. */
  33581. validateSkinning(): {
  33582. skinned: boolean;
  33583. valid: boolean;
  33584. report: string;
  33585. };
  33586. /** @hidden */
  33587. _checkDelayState(): Mesh;
  33588. private _queueLoad;
  33589. /**
  33590. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33591. * A mesh is in the frustum if its bounding box intersects the frustum
  33592. * @param frustumPlanes defines the frustum to test
  33593. * @returns true if the mesh is in the frustum planes
  33594. */
  33595. isInFrustum(frustumPlanes: Plane[]): boolean;
  33596. /**
  33597. * Sets the mesh material by the material or multiMaterial `id` property
  33598. * @param id is a string identifying the material or the multiMaterial
  33599. * @returns the current mesh
  33600. */
  33601. setMaterialByID(id: string): Mesh;
  33602. /**
  33603. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33604. * @returns an array of IAnimatable
  33605. */
  33606. getAnimatables(): IAnimatable[];
  33607. /**
  33608. * Modifies the mesh geometry according to the passed transformation matrix.
  33609. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33610. * The mesh normals are modified using the same transformation.
  33611. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33612. * @param transform defines the transform matrix to use
  33613. * @see https://doc.babylonjs.com/resources/baking_transformations
  33614. * @returns the current mesh
  33615. */
  33616. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33617. /**
  33618. * Modifies the mesh geometry according to its own current World Matrix.
  33619. * The mesh World Matrix is then reset.
  33620. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33621. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33622. * @see https://doc.babylonjs.com/resources/baking_transformations
  33623. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33624. * @returns the current mesh
  33625. */
  33626. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33627. /** @hidden */
  33628. get _positions(): Nullable<Vector3[]>;
  33629. /** @hidden */
  33630. _resetPointsArrayCache(): Mesh;
  33631. /** @hidden */
  33632. _generatePointsArray(): boolean;
  33633. /**
  33634. * Returns a new Mesh object generated from the current mesh properties.
  33635. * This method must not get confused with createInstance()
  33636. * @param name is a string, the name given to the new mesh
  33637. * @param newParent can be any Node object (default `null`)
  33638. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33639. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33640. * @returns a new mesh
  33641. */
  33642. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33643. /**
  33644. * Releases resources associated with this mesh.
  33645. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33646. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33647. */
  33648. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33649. /** @hidden */
  33650. _disposeInstanceSpecificData(): void;
  33651. /** @hidden */
  33652. _disposeThinInstanceSpecificData(): void;
  33653. /**
  33654. * Modifies the mesh geometry according to a displacement map.
  33655. * 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.
  33656. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33657. * @param url is a string, the URL from the image file is to be downloaded.
  33658. * @param minHeight is the lower limit of the displacement.
  33659. * @param maxHeight is the upper limit of the displacement.
  33660. * @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.
  33661. * @param uvOffset is an optional vector2 used to offset UV.
  33662. * @param uvScale is an optional vector2 used to scale UV.
  33663. * @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.
  33664. * @returns the Mesh.
  33665. */
  33666. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33667. /**
  33668. * Modifies the mesh geometry according to a displacementMap buffer.
  33669. * 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.
  33670. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33671. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33672. * @param heightMapWidth is the width of the buffer image.
  33673. * @param heightMapHeight is the height of the buffer image.
  33674. * @param minHeight is the lower limit of the displacement.
  33675. * @param maxHeight is the upper limit of the displacement.
  33676. * @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.
  33677. * @param uvOffset is an optional vector2 used to offset UV.
  33678. * @param uvScale is an optional vector2 used to scale UV.
  33679. * @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.
  33680. * @returns the Mesh.
  33681. */
  33682. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33683. /**
  33684. * Modify the mesh to get a flat shading rendering.
  33685. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33686. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33687. * @returns current mesh
  33688. */
  33689. convertToFlatShadedMesh(): Mesh;
  33690. /**
  33691. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33692. * In other words, more vertices, no more indices and a single bigger VBO.
  33693. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33694. * @returns current mesh
  33695. */
  33696. convertToUnIndexedMesh(): Mesh;
  33697. /**
  33698. * Inverses facet orientations.
  33699. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33700. * @param flipNormals will also inverts the normals
  33701. * @returns current mesh
  33702. */
  33703. flipFaces(flipNormals?: boolean): Mesh;
  33704. /**
  33705. * Increase the number of facets and hence vertices in a mesh
  33706. * Vertex normals are interpolated from existing vertex normals
  33707. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33708. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33709. */
  33710. increaseVertices(numberPerEdge: number): void;
  33711. /**
  33712. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33713. * This will undo any application of covertToFlatShadedMesh
  33714. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33715. */
  33716. forceSharedVertices(): void;
  33717. /** @hidden */
  33718. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33719. /** @hidden */
  33720. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33721. /**
  33722. * Creates a new InstancedMesh object from the mesh model.
  33723. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33724. * @param name defines the name of the new instance
  33725. * @returns a new InstancedMesh
  33726. */
  33727. createInstance(name: string): InstancedMesh;
  33728. /**
  33729. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33730. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33731. * @returns the current mesh
  33732. */
  33733. synchronizeInstances(): Mesh;
  33734. /**
  33735. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33736. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33737. * This should be used together with the simplification to avoid disappearing triangles.
  33738. * @param successCallback an optional success callback to be called after the optimization finished.
  33739. * @returns the current mesh
  33740. */
  33741. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33742. /**
  33743. * Serialize current mesh
  33744. * @param serializationObject defines the object which will receive the serialization data
  33745. */
  33746. serialize(serializationObject: any): void;
  33747. /** @hidden */
  33748. _syncGeometryWithMorphTargetManager(): void;
  33749. /** @hidden */
  33750. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33751. /**
  33752. * Returns a new Mesh object parsed from the source provided.
  33753. * @param parsedMesh is the source
  33754. * @param scene defines the hosting scene
  33755. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33756. * @returns a new Mesh
  33757. */
  33758. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33759. /**
  33760. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33761. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33762. * @param name defines the name of the mesh to create
  33763. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33764. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33765. * @param closePath creates a seam between the first and the last points of each path of the path array
  33766. * @param offset is taken in account only if the `pathArray` is containing a single path
  33767. * @param scene defines the hosting scene
  33768. * @param updatable defines if the mesh must be flagged as updatable
  33769. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33770. * @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)
  33771. * @returns a new Mesh
  33772. */
  33773. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33774. /**
  33775. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33776. * @param name defines the name of the mesh to create
  33777. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33778. * @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
  33779. * @param scene defines the hosting scene
  33780. * @param updatable defines if the mesh must be flagged as updatable
  33781. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33782. * @returns a new Mesh
  33783. */
  33784. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33785. /**
  33786. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33787. * @param name defines the name of the mesh to create
  33788. * @param size sets the size (float) of each box side (default 1)
  33789. * @param scene defines the hosting scene
  33790. * @param updatable defines if the mesh must be flagged as updatable
  33791. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33792. * @returns a new Mesh
  33793. */
  33794. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33795. /**
  33796. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33797. * @param name defines the name of the mesh to create
  33798. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33799. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33800. * @param scene defines the hosting scene
  33801. * @param updatable defines if the mesh must be flagged as updatable
  33802. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33803. * @returns a new Mesh
  33804. */
  33805. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33806. /**
  33807. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33808. * @param name defines the name of the mesh to create
  33809. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33810. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33811. * @param scene defines the hosting scene
  33812. * @returns a new Mesh
  33813. */
  33814. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33815. /**
  33816. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33817. * @param name defines the name of the mesh to create
  33818. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33819. * @param diameterTop set the top cap diameter (floats, default 1)
  33820. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33821. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33822. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33823. * @param scene defines the hosting scene
  33824. * @param updatable defines if the mesh must be flagged as updatable
  33825. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33826. * @returns a new Mesh
  33827. */
  33828. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33829. /**
  33830. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33831. * @param name defines the name of the mesh to create
  33832. * @param diameter sets the diameter size (float) of the torus (default 1)
  33833. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33834. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33835. * @param scene defines the hosting scene
  33836. * @param updatable defines if the mesh must be flagged as updatable
  33837. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33838. * @returns a new Mesh
  33839. */
  33840. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33841. /**
  33842. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33843. * @param name defines the name of the mesh to create
  33844. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33845. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33846. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33847. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33848. * @param p the number of windings on X axis (positive integers, default 2)
  33849. * @param q the number of windings on Y axis (positive integers, default 3)
  33850. * @param scene defines the hosting scene
  33851. * @param updatable defines if the mesh must be flagged as updatable
  33852. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33853. * @returns a new Mesh
  33854. */
  33855. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33856. /**
  33857. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33858. * @param name defines the name of the mesh to create
  33859. * @param points is an array successive Vector3
  33860. * @param scene defines the hosting scene
  33861. * @param updatable defines if the mesh must be flagged as updatable
  33862. * @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).
  33863. * @returns a new Mesh
  33864. */
  33865. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33866. /**
  33867. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33868. * @param name defines the name of the mesh to create
  33869. * @param points is an array successive Vector3
  33870. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33871. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33872. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33873. * @param scene defines the hosting scene
  33874. * @param updatable defines if the mesh must be flagged as updatable
  33875. * @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)
  33876. * @returns a new Mesh
  33877. */
  33878. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33879. /**
  33880. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33881. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33882. * 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.
  33883. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33884. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33885. * Remember you can only change the shape positions, not their number when updating a polygon.
  33886. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33887. * @param name defines the name of the mesh to create
  33888. * @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
  33889. * @param scene defines the hosting scene
  33890. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33891. * @param updatable defines if the mesh must be flagged as updatable
  33892. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33893. * @param earcutInjection can be used to inject your own earcut reference
  33894. * @returns a new Mesh
  33895. */
  33896. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33897. /**
  33898. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33899. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33900. * @param name defines the name of the mesh to create
  33901. * @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
  33902. * @param depth defines the height of extrusion
  33903. * @param scene defines the hosting scene
  33904. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33905. * @param updatable defines if the mesh must be flagged as updatable
  33906. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33907. * @param earcutInjection can be used to inject your own earcut reference
  33908. * @returns a new Mesh
  33909. */
  33910. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33911. /**
  33912. * Creates an extruded shape mesh.
  33913. * 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
  33914. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33915. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33916. * @param name defines the name of the mesh to create
  33917. * @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
  33918. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33919. * @param scale is the value to scale the shape
  33920. * @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
  33921. * @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
  33922. * @param scene defines the hosting scene
  33923. * @param updatable defines if the mesh must be flagged as updatable
  33924. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33925. * @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)
  33926. * @returns a new Mesh
  33927. */
  33928. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33929. /**
  33930. * Creates an custom extruded shape mesh.
  33931. * The custom extrusion is a parametric shape.
  33932. * It has no predefined shape. Its final shape will depend on the input parameters.
  33933. * Please consider using the same method from the MeshBuilder class instead
  33934. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33935. * @param name defines the name of the mesh to create
  33936. * @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
  33937. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33938. * @param scaleFunction is a custom Javascript function called on each path point
  33939. * @param rotationFunction is a custom Javascript function called on each path point
  33940. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33941. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33942. * @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
  33943. * @param scene defines the hosting scene
  33944. * @param updatable defines if the mesh must be flagged as updatable
  33945. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33946. * @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)
  33947. * @returns a new Mesh
  33948. */
  33949. 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;
  33950. /**
  33951. * Creates lathe mesh.
  33952. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33953. * Please consider using the same method from the MeshBuilder class instead
  33954. * @param name defines the name of the mesh to create
  33955. * @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
  33956. * @param radius is the radius value of the lathe
  33957. * @param tessellation is the side number of the lathe.
  33958. * @param scene defines the hosting scene
  33959. * @param updatable defines if the mesh must be flagged as updatable
  33960. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33961. * @returns a new Mesh
  33962. */
  33963. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33964. /**
  33965. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33966. * @param name defines the name of the mesh to create
  33967. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33968. * @param scene defines the hosting scene
  33969. * @param updatable defines if the mesh must be flagged as updatable
  33970. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33971. * @returns a new Mesh
  33972. */
  33973. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33974. /**
  33975. * Creates a ground mesh.
  33976. * Please consider using the same method from the MeshBuilder class instead
  33977. * @param name defines the name of the mesh to create
  33978. * @param width set the width of the ground
  33979. * @param height set the height of the ground
  33980. * @param subdivisions sets the number of subdivisions per side
  33981. * @param scene defines the hosting scene
  33982. * @param updatable defines if the mesh must be flagged as updatable
  33983. * @returns a new Mesh
  33984. */
  33985. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33986. /**
  33987. * Creates a tiled ground mesh.
  33988. * Please consider using the same method from the MeshBuilder class instead
  33989. * @param name defines the name of the mesh to create
  33990. * @param xmin set the ground minimum X coordinate
  33991. * @param zmin set the ground minimum Y coordinate
  33992. * @param xmax set the ground maximum X coordinate
  33993. * @param zmax set the ground maximum Z coordinate
  33994. * @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
  33995. * @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
  33996. * @param scene defines the hosting scene
  33997. * @param updatable defines if the mesh must be flagged as updatable
  33998. * @returns a new Mesh
  33999. */
  34000. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34001. w: number;
  34002. h: number;
  34003. }, precision: {
  34004. w: number;
  34005. h: number;
  34006. }, scene: Scene, updatable?: boolean): Mesh;
  34007. /**
  34008. * Creates a ground mesh from a height map.
  34009. * Please consider using the same method from the MeshBuilder class instead
  34010. * @see https://doc.babylonjs.com/babylon101/height_map
  34011. * @param name defines the name of the mesh to create
  34012. * @param url sets the URL of the height map image resource
  34013. * @param width set the ground width size
  34014. * @param height set the ground height size
  34015. * @param subdivisions sets the number of subdivision per side
  34016. * @param minHeight is the minimum altitude on the ground
  34017. * @param maxHeight is the maximum altitude on the ground
  34018. * @param scene defines the hosting scene
  34019. * @param updatable defines if the mesh must be flagged as updatable
  34020. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34021. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34022. * @returns a new Mesh
  34023. */
  34024. 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;
  34025. /**
  34026. * Creates a tube mesh.
  34027. * The tube is a parametric shape.
  34028. * It has no predefined shape. Its final shape will depend on the input parameters.
  34029. * Please consider using the same method from the MeshBuilder class instead
  34030. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34031. * @param name defines the name of the mesh to create
  34032. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34033. * @param radius sets the tube radius size
  34034. * @param tessellation is the number of sides on the tubular surface
  34035. * @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
  34036. * @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
  34037. * @param scene defines the hosting scene
  34038. * @param updatable defines if the mesh must be flagged as updatable
  34039. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34040. * @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)
  34041. * @returns a new Mesh
  34042. */
  34043. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34044. (i: number, distance: number): number;
  34045. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34046. /**
  34047. * Creates a polyhedron mesh.
  34048. * Please consider using the same method from the MeshBuilder class instead.
  34049. * * 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
  34050. * * The parameter `size` (positive float, default 1) sets the polygon size
  34051. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34052. * * 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`
  34053. * * 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
  34054. * * 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)`)
  34055. * * 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
  34056. * * 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
  34057. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34058. * * 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
  34059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34060. * @param name defines the name of the mesh to create
  34061. * @param options defines the options used to create the mesh
  34062. * @param scene defines the hosting scene
  34063. * @returns a new Mesh
  34064. */
  34065. static CreatePolyhedron(name: string, options: {
  34066. type?: number;
  34067. size?: number;
  34068. sizeX?: number;
  34069. sizeY?: number;
  34070. sizeZ?: number;
  34071. custom?: any;
  34072. faceUV?: Vector4[];
  34073. faceColors?: Color4[];
  34074. updatable?: boolean;
  34075. sideOrientation?: number;
  34076. }, scene: Scene): Mesh;
  34077. /**
  34078. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34079. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34080. * * 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`)
  34081. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34082. * * 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
  34083. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34084. * * 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
  34085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34086. * @param name defines the name of the mesh
  34087. * @param options defines the options used to create the mesh
  34088. * @param scene defines the hosting scene
  34089. * @returns a new Mesh
  34090. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34091. */
  34092. static CreateIcoSphere(name: string, options: {
  34093. radius?: number;
  34094. flat?: boolean;
  34095. subdivisions?: number;
  34096. sideOrientation?: number;
  34097. updatable?: boolean;
  34098. }, scene: Scene): Mesh;
  34099. /**
  34100. * Creates a decal mesh.
  34101. * Please consider using the same method from the MeshBuilder class instead.
  34102. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34103. * @param name defines the name of the mesh
  34104. * @param sourceMesh defines the mesh receiving the decal
  34105. * @param position sets the position of the decal in world coordinates
  34106. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34107. * @param size sets the decal scaling
  34108. * @param angle sets the angle to rotate the decal
  34109. * @returns a new Mesh
  34110. */
  34111. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34112. /** Creates a Capsule Mesh
  34113. * @param name defines the name of the mesh.
  34114. * @param options the constructors options used to shape the mesh.
  34115. * @param scene defines the scene the mesh is scoped to.
  34116. * @returns the capsule mesh
  34117. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34118. */
  34119. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34120. /**
  34121. * Prepare internal position array for software CPU skinning
  34122. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34123. */
  34124. setPositionsForCPUSkinning(): Float32Array;
  34125. /**
  34126. * Prepare internal normal array for software CPU skinning
  34127. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34128. */
  34129. setNormalsForCPUSkinning(): Float32Array;
  34130. /**
  34131. * Updates the vertex buffer by applying transformation from the bones
  34132. * @param skeleton defines the skeleton to apply to current mesh
  34133. * @returns the current mesh
  34134. */
  34135. applySkeleton(skeleton: Skeleton): Mesh;
  34136. /**
  34137. * 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
  34138. * @param meshes defines the list of meshes to scan
  34139. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34140. */
  34141. static MinMax(meshes: AbstractMesh[]): {
  34142. min: Vector3;
  34143. max: Vector3;
  34144. };
  34145. /**
  34146. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34147. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34148. * @returns a vector3
  34149. */
  34150. static Center(meshesOrMinMaxVector: {
  34151. min: Vector3;
  34152. max: Vector3;
  34153. } | AbstractMesh[]): Vector3;
  34154. /**
  34155. * Merge the array of meshes into a single mesh for performance reasons.
  34156. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34157. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34158. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34159. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34160. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34161. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34162. * @returns a new mesh
  34163. */
  34164. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34165. /** @hidden */
  34166. addInstance(instance: InstancedMesh): void;
  34167. /** @hidden */
  34168. removeInstance(instance: InstancedMesh): void;
  34169. }
  34170. }
  34171. declare module BABYLON {
  34172. /**
  34173. * The options Interface for creating a Capsule Mesh
  34174. */
  34175. export interface ICreateCapsuleOptions {
  34176. /** The Orientation of the capsule. Default : Vector3.Up() */
  34177. orientation?: Vector3;
  34178. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34179. subdivisions: number;
  34180. /** Number of cylindrical segments on the capsule. */
  34181. tessellation: number;
  34182. /** Height or Length of the capsule. */
  34183. height: number;
  34184. /** Radius of the capsule. */
  34185. radius: number;
  34186. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34187. capSubdivisions: number;
  34188. /** Overwrite for the top radius. */
  34189. radiusTop?: number;
  34190. /** Overwrite for the bottom radius. */
  34191. radiusBottom?: number;
  34192. /** Overwrite for the top capSubdivisions. */
  34193. topCapSubdivisions?: number;
  34194. /** Overwrite for the bottom capSubdivisions. */
  34195. bottomCapSubdivisions?: number;
  34196. }
  34197. /**
  34198. * Class containing static functions to help procedurally build meshes
  34199. */
  34200. export class CapsuleBuilder {
  34201. /**
  34202. * Creates a capsule or a pill mesh
  34203. * @param name defines the name of the mesh
  34204. * @param options The constructors options.
  34205. * @param scene The scene the mesh is scoped to.
  34206. * @returns Capsule Mesh
  34207. */
  34208. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34209. }
  34210. }
  34211. declare module BABYLON {
  34212. /**
  34213. * Define an interface for all classes that will get and set the data on vertices
  34214. */
  34215. export interface IGetSetVerticesData {
  34216. /**
  34217. * Gets a boolean indicating if specific vertex data is present
  34218. * @param kind defines the vertex data kind to use
  34219. * @returns true is data kind is present
  34220. */
  34221. isVerticesDataPresent(kind: string): boolean;
  34222. /**
  34223. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34224. * @param kind defines the data kind (Position, normal, etc...)
  34225. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34226. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34227. * @returns a float array containing vertex data
  34228. */
  34229. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34230. /**
  34231. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34232. * @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.
  34233. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34234. * @returns the indices array or an empty array if the mesh has no geometry
  34235. */
  34236. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34237. /**
  34238. * Set specific vertex data
  34239. * @param kind defines the data kind (Position, normal, etc...)
  34240. * @param data defines the vertex data to use
  34241. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34242. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34243. */
  34244. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34245. /**
  34246. * Update a specific associated vertex buffer
  34247. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34248. * - VertexBuffer.PositionKind
  34249. * - VertexBuffer.UVKind
  34250. * - VertexBuffer.UV2Kind
  34251. * - VertexBuffer.UV3Kind
  34252. * - VertexBuffer.UV4Kind
  34253. * - VertexBuffer.UV5Kind
  34254. * - VertexBuffer.UV6Kind
  34255. * - VertexBuffer.ColorKind
  34256. * - VertexBuffer.MatricesIndicesKind
  34257. * - VertexBuffer.MatricesIndicesExtraKind
  34258. * - VertexBuffer.MatricesWeightsKind
  34259. * - VertexBuffer.MatricesWeightsExtraKind
  34260. * @param data defines the data source
  34261. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34262. * @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)
  34263. */
  34264. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34265. /**
  34266. * Creates a new index buffer
  34267. * @param indices defines the indices to store in the index buffer
  34268. * @param totalVertices defines the total number of vertices (could be null)
  34269. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34270. */
  34271. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34272. }
  34273. /**
  34274. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34275. */
  34276. export class VertexData {
  34277. /**
  34278. * Mesh side orientation : usually the external or front surface
  34279. */
  34280. static readonly FRONTSIDE: number;
  34281. /**
  34282. * Mesh side orientation : usually the internal or back surface
  34283. */
  34284. static readonly BACKSIDE: number;
  34285. /**
  34286. * Mesh side orientation : both internal and external or front and back surfaces
  34287. */
  34288. static readonly DOUBLESIDE: number;
  34289. /**
  34290. * Mesh side orientation : by default, `FRONTSIDE`
  34291. */
  34292. static readonly DEFAULTSIDE: number;
  34293. /**
  34294. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34295. */
  34296. positions: Nullable<FloatArray>;
  34297. /**
  34298. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34299. */
  34300. normals: Nullable<FloatArray>;
  34301. /**
  34302. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34303. */
  34304. tangents: Nullable<FloatArray>;
  34305. /**
  34306. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34307. */
  34308. uvs: Nullable<FloatArray>;
  34309. /**
  34310. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34311. */
  34312. uvs2: Nullable<FloatArray>;
  34313. /**
  34314. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34315. */
  34316. uvs3: Nullable<FloatArray>;
  34317. /**
  34318. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34319. */
  34320. uvs4: Nullable<FloatArray>;
  34321. /**
  34322. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34323. */
  34324. uvs5: Nullable<FloatArray>;
  34325. /**
  34326. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34327. */
  34328. uvs6: Nullable<FloatArray>;
  34329. /**
  34330. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34331. */
  34332. colors: Nullable<FloatArray>;
  34333. /**
  34334. * 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).
  34335. */
  34336. matricesIndices: Nullable<FloatArray>;
  34337. /**
  34338. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34339. */
  34340. matricesWeights: Nullable<FloatArray>;
  34341. /**
  34342. * An array extending the number of possible indices
  34343. */
  34344. matricesIndicesExtra: Nullable<FloatArray>;
  34345. /**
  34346. * An array extending the number of possible weights when the number of indices is extended
  34347. */
  34348. matricesWeightsExtra: Nullable<FloatArray>;
  34349. /**
  34350. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34351. */
  34352. indices: Nullable<IndicesArray>;
  34353. /**
  34354. * Uses the passed data array to set the set the values for the specified kind of data
  34355. * @param data a linear array of floating numbers
  34356. * @param kind the type of data that is being set, eg positions, colors etc
  34357. */
  34358. set(data: FloatArray, kind: string): void;
  34359. /**
  34360. * Associates the vertexData to the passed Mesh.
  34361. * Sets it as updatable or not (default `false`)
  34362. * @param mesh the mesh the vertexData is applied to
  34363. * @param updatable when used and having the value true allows new data to update the vertexData
  34364. * @returns the VertexData
  34365. */
  34366. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34367. /**
  34368. * Associates the vertexData to the passed Geometry.
  34369. * Sets it as updatable or not (default `false`)
  34370. * @param geometry the geometry the vertexData is applied to
  34371. * @param updatable when used and having the value true allows new data to update the vertexData
  34372. * @returns VertexData
  34373. */
  34374. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34375. /**
  34376. * Updates the associated mesh
  34377. * @param mesh the mesh to be updated
  34378. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34379. * @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
  34380. * @returns VertexData
  34381. */
  34382. updateMesh(mesh: Mesh): VertexData;
  34383. /**
  34384. * Updates the associated geometry
  34385. * @param geometry the geometry to be updated
  34386. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34387. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  34388. * @returns VertexData.
  34389. */
  34390. updateGeometry(geometry: Geometry): VertexData;
  34391. private _applyTo;
  34392. private _update;
  34393. /**
  34394. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34395. * @param matrix the transforming matrix
  34396. * @returns the VertexData
  34397. */
  34398. transform(matrix: Matrix): VertexData;
  34399. /**
  34400. * Merges the passed VertexData into the current one
  34401. * @param other the VertexData to be merged into the current one
  34402. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34403. * @returns the modified VertexData
  34404. */
  34405. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34406. private _mergeElement;
  34407. private _validate;
  34408. /**
  34409. * Serializes the VertexData
  34410. * @returns a serialized object
  34411. */
  34412. serialize(): any;
  34413. /**
  34414. * Extracts the vertexData from a mesh
  34415. * @param mesh the mesh from which to extract the VertexData
  34416. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34417. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34418. * @returns the object VertexData associated to the passed mesh
  34419. */
  34420. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34421. /**
  34422. * Extracts the vertexData from the geometry
  34423. * @param geometry the geometry from which to extract the VertexData
  34424. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34425. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34426. * @returns the object VertexData associated to the passed mesh
  34427. */
  34428. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34429. private static _ExtractFrom;
  34430. /**
  34431. * Creates the VertexData for a Ribbon
  34432. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34433. * * pathArray array of paths, each of which an array of successive Vector3
  34434. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34435. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34436. * * 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
  34437. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34438. * * 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)
  34439. * * 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)
  34440. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34441. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34442. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34443. * @returns the VertexData of the ribbon
  34444. */
  34445. static CreateRibbon(options: {
  34446. pathArray: Vector3[][];
  34447. closeArray?: boolean;
  34448. closePath?: boolean;
  34449. offset?: number;
  34450. sideOrientation?: number;
  34451. frontUVs?: Vector4;
  34452. backUVs?: Vector4;
  34453. invertUV?: boolean;
  34454. uvs?: Vector2[];
  34455. colors?: Color4[];
  34456. }): VertexData;
  34457. /**
  34458. * Creates the VertexData for a box
  34459. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34460. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34461. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34462. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34463. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34464. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34465. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34467. * * 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)
  34468. * * 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)
  34469. * @returns the VertexData of the box
  34470. */
  34471. static CreateBox(options: {
  34472. size?: number;
  34473. width?: number;
  34474. height?: number;
  34475. depth?: number;
  34476. faceUV?: Vector4[];
  34477. faceColors?: Color4[];
  34478. sideOrientation?: number;
  34479. frontUVs?: Vector4;
  34480. backUVs?: Vector4;
  34481. }): VertexData;
  34482. /**
  34483. * Creates the VertexData for a tiled box
  34484. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34485. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34486. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34487. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34488. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34489. * @returns the VertexData of the box
  34490. */
  34491. static CreateTiledBox(options: {
  34492. pattern?: number;
  34493. width?: number;
  34494. height?: number;
  34495. depth?: number;
  34496. tileSize?: number;
  34497. tileWidth?: number;
  34498. tileHeight?: number;
  34499. alignHorizontal?: number;
  34500. alignVertical?: number;
  34501. faceUV?: Vector4[];
  34502. faceColors?: Color4[];
  34503. sideOrientation?: number;
  34504. }): VertexData;
  34505. /**
  34506. * Creates the VertexData for a tiled plane
  34507. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34508. * * pattern a limited pattern arrangement depending on the number
  34509. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34510. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34511. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34512. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34513. * * 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)
  34514. * * 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)
  34515. * @returns the VertexData of the tiled plane
  34516. */
  34517. static CreateTiledPlane(options: {
  34518. pattern?: number;
  34519. tileSize?: number;
  34520. tileWidth?: number;
  34521. tileHeight?: number;
  34522. size?: number;
  34523. width?: number;
  34524. height?: number;
  34525. alignHorizontal?: number;
  34526. alignVertical?: number;
  34527. sideOrientation?: number;
  34528. frontUVs?: Vector4;
  34529. backUVs?: Vector4;
  34530. }): VertexData;
  34531. /**
  34532. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34533. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34534. * * segments sets the number of horizontal strips optional, default 32
  34535. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34536. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34537. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34538. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34539. * * 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
  34540. * * 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
  34541. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34542. * * 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)
  34543. * * 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)
  34544. * @returns the VertexData of the ellipsoid
  34545. */
  34546. static CreateSphere(options: {
  34547. segments?: number;
  34548. diameter?: number;
  34549. diameterX?: number;
  34550. diameterY?: number;
  34551. diameterZ?: number;
  34552. arc?: number;
  34553. slice?: number;
  34554. sideOrientation?: number;
  34555. frontUVs?: Vector4;
  34556. backUVs?: Vector4;
  34557. }): VertexData;
  34558. /**
  34559. * Creates the VertexData for a cylinder, cone or prism
  34560. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34561. * * height sets the height (y direction) of the cylinder, optional, default 2
  34562. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34563. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34564. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34565. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34566. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34567. * * 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
  34568. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34569. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34570. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34571. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34572. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34573. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34574. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34575. * @returns the VertexData of the cylinder, cone or prism
  34576. */
  34577. static CreateCylinder(options: {
  34578. height?: number;
  34579. diameterTop?: number;
  34580. diameterBottom?: number;
  34581. diameter?: number;
  34582. tessellation?: number;
  34583. subdivisions?: number;
  34584. arc?: number;
  34585. faceColors?: Color4[];
  34586. faceUV?: Vector4[];
  34587. hasRings?: boolean;
  34588. enclose?: boolean;
  34589. sideOrientation?: number;
  34590. frontUVs?: Vector4;
  34591. backUVs?: Vector4;
  34592. }): VertexData;
  34593. /**
  34594. * Creates the VertexData for a torus
  34595. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34596. * * diameter the diameter of the torus, optional default 1
  34597. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34598. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34599. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34600. * * 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)
  34601. * * 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)
  34602. * @returns the VertexData of the torus
  34603. */
  34604. static CreateTorus(options: {
  34605. diameter?: number;
  34606. thickness?: number;
  34607. tessellation?: number;
  34608. sideOrientation?: number;
  34609. frontUVs?: Vector4;
  34610. backUVs?: Vector4;
  34611. }): VertexData;
  34612. /**
  34613. * Creates the VertexData of the LineSystem
  34614. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  34615. * - lines an array of lines, each line being an array of successive Vector3
  34616. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  34617. * @returns the VertexData of the LineSystem
  34618. */
  34619. static CreateLineSystem(options: {
  34620. lines: Vector3[][];
  34621. colors?: Nullable<Color4[][]>;
  34622. }): VertexData;
  34623. /**
  34624. * Create the VertexData for a DashedLines
  34625. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  34626. * - points an array successive Vector3
  34627. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  34628. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  34629. * - dashNb the intended total number of dashes, optional, default 200
  34630. * @returns the VertexData for the DashedLines
  34631. */
  34632. static CreateDashedLines(options: {
  34633. points: Vector3[];
  34634. dashSize?: number;
  34635. gapSize?: number;
  34636. dashNb?: number;
  34637. }): VertexData;
  34638. /**
  34639. * Creates the VertexData for a Ground
  34640. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34641. * - width the width (x direction) of the ground, optional, default 1
  34642. * - height the height (z direction) of the ground, optional, default 1
  34643. * - subdivisions the number of subdivisions per side, optional, default 1
  34644. * @returns the VertexData of the Ground
  34645. */
  34646. static CreateGround(options: {
  34647. width?: number;
  34648. height?: number;
  34649. subdivisions?: number;
  34650. subdivisionsX?: number;
  34651. subdivisionsY?: number;
  34652. }): VertexData;
  34653. /**
  34654. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  34655. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34656. * * xmin the ground minimum X coordinate, optional, default -1
  34657. * * zmin the ground minimum Z coordinate, optional, default -1
  34658. * * xmax the ground maximum X coordinate, optional, default 1
  34659. * * zmax the ground maximum Z coordinate, optional, default 1
  34660. * * 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}
  34661. * * 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}
  34662. * @returns the VertexData of the TiledGround
  34663. */
  34664. static CreateTiledGround(options: {
  34665. xmin: number;
  34666. zmin: number;
  34667. xmax: number;
  34668. zmax: number;
  34669. subdivisions?: {
  34670. w: number;
  34671. h: number;
  34672. };
  34673. precision?: {
  34674. w: number;
  34675. h: number;
  34676. };
  34677. }): VertexData;
  34678. /**
  34679. * Creates the VertexData of the Ground designed from a heightmap
  34680. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  34681. * * width the width (x direction) of the ground
  34682. * * height the height (z direction) of the ground
  34683. * * subdivisions the number of subdivisions per side
  34684. * * minHeight the minimum altitude on the ground, optional, default 0
  34685. * * maxHeight the maximum altitude on the ground, optional default 1
  34686. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  34687. * * buffer the array holding the image color data
  34688. * * bufferWidth the width of image
  34689. * * bufferHeight the height of image
  34690. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  34691. * @returns the VertexData of the Ground designed from a heightmap
  34692. */
  34693. static CreateGroundFromHeightMap(options: {
  34694. width: number;
  34695. height: number;
  34696. subdivisions: number;
  34697. minHeight: number;
  34698. maxHeight: number;
  34699. colorFilter: Color3;
  34700. buffer: Uint8Array;
  34701. bufferWidth: number;
  34702. bufferHeight: number;
  34703. alphaFilter: number;
  34704. }): VertexData;
  34705. /**
  34706. * Creates the VertexData for a Plane
  34707. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  34708. * * size sets the width and height of the plane to the value of size, optional default 1
  34709. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  34710. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  34711. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34712. * * 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)
  34713. * * 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)
  34714. * @returns the VertexData of the box
  34715. */
  34716. static CreatePlane(options: {
  34717. size?: number;
  34718. width?: number;
  34719. height?: number;
  34720. sideOrientation?: number;
  34721. frontUVs?: Vector4;
  34722. backUVs?: Vector4;
  34723. }): VertexData;
  34724. /**
  34725. * Creates the VertexData of the Disc or regular Polygon
  34726. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  34727. * * radius the radius of the disc, optional default 0.5
  34728. * * tessellation the number of polygon sides, optional, default 64
  34729. * * 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
  34730. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34731. * * 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)
  34732. * * 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)
  34733. * @returns the VertexData of the box
  34734. */
  34735. static CreateDisc(options: {
  34736. radius?: number;
  34737. tessellation?: number;
  34738. arc?: number;
  34739. sideOrientation?: number;
  34740. frontUVs?: Vector4;
  34741. backUVs?: Vector4;
  34742. }): VertexData;
  34743. /**
  34744. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34745. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34746. * @param polygon a mesh built from polygonTriangulation.build()
  34747. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34748. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34749. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34750. * @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)
  34751. * @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)
  34752. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34753. * @returns the VertexData of the Polygon
  34754. */
  34755. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34756. /**
  34757. * Creates the VertexData of the IcoSphere
  34758. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34759. * * radius the radius of the IcoSphere, optional default 1
  34760. * * radiusX allows stretching in the x direction, optional, default radius
  34761. * * radiusY allows stretching in the y direction, optional, default radius
  34762. * * radiusZ allows stretching in the z direction, optional, default radius
  34763. * * flat when true creates a flat shaded mesh, optional, default true
  34764. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34765. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34766. * * 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)
  34767. * * 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)
  34768. * @returns the VertexData of the IcoSphere
  34769. */
  34770. static CreateIcoSphere(options: {
  34771. radius?: number;
  34772. radiusX?: number;
  34773. radiusY?: number;
  34774. radiusZ?: number;
  34775. flat?: boolean;
  34776. subdivisions?: number;
  34777. sideOrientation?: number;
  34778. frontUVs?: Vector4;
  34779. backUVs?: Vector4;
  34780. }): VertexData;
  34781. /**
  34782. * Creates the VertexData for a Polyhedron
  34783. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34784. * * type provided types are:
  34785. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34786. * * 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)
  34787. * * size the size of the IcoSphere, optional default 1
  34788. * * sizeX allows stretching in the x direction, optional, default size
  34789. * * sizeY allows stretching in the y direction, optional, default size
  34790. * * sizeZ allows stretching in the z direction, optional, default size
  34791. * * 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
  34792. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34793. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34794. * * flat when true creates a flat shaded mesh, optional, default true
  34795. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34796. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34797. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34798. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34799. * @returns the VertexData of the Polyhedron
  34800. */
  34801. static CreatePolyhedron(options: {
  34802. type?: number;
  34803. size?: number;
  34804. sizeX?: number;
  34805. sizeY?: number;
  34806. sizeZ?: number;
  34807. custom?: any;
  34808. faceUV?: Vector4[];
  34809. faceColors?: Color4[];
  34810. flat?: boolean;
  34811. sideOrientation?: number;
  34812. frontUVs?: Vector4;
  34813. backUVs?: Vector4;
  34814. }): VertexData;
  34815. /**
  34816. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34817. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34818. * @returns the VertexData of the Capsule
  34819. */
  34820. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34821. /**
  34822. * Creates the VertexData for a TorusKnot
  34823. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34824. * * radius the radius of the torus knot, optional, default 2
  34825. * * tube the thickness of the tube, optional, default 0.5
  34826. * * radialSegments the number of sides on each tube segments, optional, default 32
  34827. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34828. * * p the number of windings around the z axis, optional, default 2
  34829. * * q the number of windings around the x axis, optional, default 3
  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 Torus Knot
  34834. */
  34835. static CreateTorusKnot(options: {
  34836. radius?: number;
  34837. tube?: number;
  34838. radialSegments?: number;
  34839. tubularSegments?: number;
  34840. p?: number;
  34841. q?: number;
  34842. sideOrientation?: number;
  34843. frontUVs?: Vector4;
  34844. backUVs?: Vector4;
  34845. }): VertexData;
  34846. /**
  34847. * Compute normals for given positions and indices
  34848. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34849. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34850. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34851. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34852. * * facetNormals : optional array of facet normals (vector3)
  34853. * * facetPositions : optional array of facet positions (vector3)
  34854. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34855. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34856. * * bInfo : optional bounding info, required for facetPartitioning computation
  34857. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34858. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34859. * * useRightHandedSystem: optional boolean to for right handed system computation
  34860. * * depthSort : optional boolean to enable the facet depth sort computation
  34861. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34862. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34863. */
  34864. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34865. facetNormals?: any;
  34866. facetPositions?: any;
  34867. facetPartitioning?: any;
  34868. ratio?: number;
  34869. bInfo?: any;
  34870. bbSize?: Vector3;
  34871. subDiv?: any;
  34872. useRightHandedSystem?: boolean;
  34873. depthSort?: boolean;
  34874. distanceTo?: Vector3;
  34875. depthSortedFacets?: any;
  34876. }): void;
  34877. /** @hidden */
  34878. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34879. /**
  34880. * Applies VertexData created from the imported parameters to the geometry
  34881. * @param parsedVertexData the parsed data from an imported file
  34882. * @param geometry the geometry to apply the VertexData to
  34883. */
  34884. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34885. }
  34886. }
  34887. declare module BABYLON {
  34888. /**
  34889. * Class containing static functions to help procedurally build meshes
  34890. */
  34891. export class DiscBuilder {
  34892. /**
  34893. * Creates a plane polygonal mesh. By default, this is a disc
  34894. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34895. * * 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
  34896. * * 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
  34897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34898. * * 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
  34899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34900. * @param name defines the name of the mesh
  34901. * @param options defines the options used to create the mesh
  34902. * @param scene defines the hosting scene
  34903. * @returns the plane polygonal mesh
  34904. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34905. */
  34906. static CreateDisc(name: string, options: {
  34907. radius?: number;
  34908. tessellation?: number;
  34909. arc?: number;
  34910. updatable?: boolean;
  34911. sideOrientation?: number;
  34912. frontUVs?: Vector4;
  34913. backUVs?: Vector4;
  34914. }, scene?: Nullable<Scene>): Mesh;
  34915. }
  34916. }
  34917. declare module BABYLON {
  34918. /**
  34919. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34920. *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.
  34921. * The SPS is also a particle system. It provides some methods to manage the particles.
  34922. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34923. *
  34924. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34925. */
  34926. export class SolidParticleSystem implements IDisposable {
  34927. /**
  34928. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34929. * Example : var p = SPS.particles[i];
  34930. */
  34931. particles: SolidParticle[];
  34932. /**
  34933. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34934. */
  34935. nbParticles: number;
  34936. /**
  34937. * If the particles must ever face the camera (default false). Useful for planar particles.
  34938. */
  34939. billboard: boolean;
  34940. /**
  34941. * Recompute normals when adding a shape
  34942. */
  34943. recomputeNormals: boolean;
  34944. /**
  34945. * This a counter ofr your own usage. It's not set by any SPS functions.
  34946. */
  34947. counter: number;
  34948. /**
  34949. * The SPS name. This name is also given to the underlying mesh.
  34950. */
  34951. name: string;
  34952. /**
  34953. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34954. */
  34955. mesh: Mesh;
  34956. /**
  34957. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34958. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34959. */
  34960. vars: any;
  34961. /**
  34962. * This array is populated when the SPS is set as 'pickable'.
  34963. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34964. * Each element of this array is an object `{idx: int, faceId: int}`.
  34965. * `idx` is the picked particle index in the `SPS.particles` array
  34966. * `faceId` is the picked face index counted within this particle.
  34967. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34968. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34969. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34970. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34971. */
  34972. pickedParticles: {
  34973. idx: number;
  34974. faceId: number;
  34975. }[];
  34976. /**
  34977. * This array is populated when the SPS is set as 'pickable'
  34978. * Each key of this array is a submesh index.
  34979. * Each element of this array is a second array defined like this :
  34980. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34981. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34982. * `idx` is the picked particle index in the `SPS.particles` array
  34983. * `faceId` is the picked face index counted within this particle.
  34984. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34985. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34986. */
  34987. pickedBySubMesh: {
  34988. idx: number;
  34989. faceId: number;
  34990. }[][];
  34991. /**
  34992. * This array is populated when `enableDepthSort` is set to true.
  34993. * Each element of this array is an instance of the class DepthSortedParticle.
  34994. */
  34995. depthSortedParticles: DepthSortedParticle[];
  34996. /**
  34997. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34998. * @hidden
  34999. */
  35000. _bSphereOnly: boolean;
  35001. /**
  35002. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35003. * @hidden
  35004. */
  35005. _bSphereRadiusFactor: number;
  35006. private _scene;
  35007. private _positions;
  35008. private _indices;
  35009. private _normals;
  35010. private _colors;
  35011. private _uvs;
  35012. private _indices32;
  35013. private _positions32;
  35014. private _normals32;
  35015. private _fixedNormal32;
  35016. private _colors32;
  35017. private _uvs32;
  35018. private _index;
  35019. private _updatable;
  35020. private _pickable;
  35021. private _isVisibilityBoxLocked;
  35022. private _alwaysVisible;
  35023. private _depthSort;
  35024. private _expandable;
  35025. private _shapeCounter;
  35026. private _copy;
  35027. private _color;
  35028. private _computeParticleColor;
  35029. private _computeParticleTexture;
  35030. private _computeParticleRotation;
  35031. private _computeParticleVertex;
  35032. private _computeBoundingBox;
  35033. private _depthSortParticles;
  35034. private _camera;
  35035. private _mustUnrotateFixedNormals;
  35036. private _particlesIntersect;
  35037. private _needs32Bits;
  35038. private _isNotBuilt;
  35039. private _lastParticleId;
  35040. private _idxOfId;
  35041. private _multimaterialEnabled;
  35042. private _useModelMaterial;
  35043. private _indicesByMaterial;
  35044. private _materialIndexes;
  35045. private _depthSortFunction;
  35046. private _materialSortFunction;
  35047. private _materials;
  35048. private _multimaterial;
  35049. private _materialIndexesById;
  35050. private _defaultMaterial;
  35051. private _autoUpdateSubMeshes;
  35052. private _tmpVertex;
  35053. /**
  35054. * Creates a SPS (Solid Particle System) object.
  35055. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35056. * @param scene (Scene) is the scene in which the SPS is added.
  35057. * @param options defines the options of the sps e.g.
  35058. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35059. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35060. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35061. * * 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.
  35062. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35063. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35064. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35065. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35066. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35067. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35068. */
  35069. constructor(name: string, scene: Scene, options?: {
  35070. updatable?: boolean;
  35071. isPickable?: boolean;
  35072. enableDepthSort?: boolean;
  35073. particleIntersection?: boolean;
  35074. boundingSphereOnly?: boolean;
  35075. bSphereRadiusFactor?: number;
  35076. expandable?: boolean;
  35077. useModelMaterial?: boolean;
  35078. enableMultiMaterial?: boolean;
  35079. });
  35080. /**
  35081. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35082. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35083. * @returns the created mesh
  35084. */
  35085. buildMesh(): Mesh;
  35086. /**
  35087. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35088. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35089. * Thus the particles generated from `digest()` have their property `position` set yet.
  35090. * @param mesh ( Mesh ) is the mesh to be digested
  35091. * @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
  35092. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35093. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35094. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35095. * @returns the current SPS
  35096. */
  35097. digest(mesh: Mesh, options?: {
  35098. facetNb?: number;
  35099. number?: number;
  35100. delta?: number;
  35101. storage?: [];
  35102. }): SolidParticleSystem;
  35103. /**
  35104. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35105. * @hidden
  35106. */
  35107. private _unrotateFixedNormals;
  35108. /**
  35109. * Resets the temporary working copy particle
  35110. * @hidden
  35111. */
  35112. private _resetCopy;
  35113. /**
  35114. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35115. * @param p the current index in the positions array to be updated
  35116. * @param ind the current index in the indices array
  35117. * @param shape a Vector3 array, the shape geometry
  35118. * @param positions the positions array to be updated
  35119. * @param meshInd the shape indices array
  35120. * @param indices the indices array to be updated
  35121. * @param meshUV the shape uv array
  35122. * @param uvs the uv array to be updated
  35123. * @param meshCol the shape color array
  35124. * @param colors the color array to be updated
  35125. * @param meshNor the shape normals array
  35126. * @param normals the normals array to be updated
  35127. * @param idx the particle index
  35128. * @param idxInShape the particle index in its shape
  35129. * @param options the addShape() method passed options
  35130. * @model the particle model
  35131. * @hidden
  35132. */
  35133. private _meshBuilder;
  35134. /**
  35135. * Returns a shape Vector3 array from positions float array
  35136. * @param positions float array
  35137. * @returns a vector3 array
  35138. * @hidden
  35139. */
  35140. private _posToShape;
  35141. /**
  35142. * Returns a shapeUV array from a float uvs (array deep copy)
  35143. * @param uvs as a float array
  35144. * @returns a shapeUV array
  35145. * @hidden
  35146. */
  35147. private _uvsToShapeUV;
  35148. /**
  35149. * Adds a new particle object in the particles array
  35150. * @param idx particle index in particles array
  35151. * @param id particle id
  35152. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35153. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35154. * @param model particle ModelShape object
  35155. * @param shapeId model shape identifier
  35156. * @param idxInShape index of the particle in the current model
  35157. * @param bInfo model bounding info object
  35158. * @param storage target storage array, if any
  35159. * @hidden
  35160. */
  35161. private _addParticle;
  35162. /**
  35163. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35164. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35165. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35166. * @param nb (positive integer) the number of particles to be created from this model
  35167. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35168. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35169. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35170. * @returns the number of shapes in the system
  35171. */
  35172. addShape(mesh: Mesh, nb: number, options?: {
  35173. positionFunction?: any;
  35174. vertexFunction?: any;
  35175. storage?: [];
  35176. }): number;
  35177. /**
  35178. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35179. * @hidden
  35180. */
  35181. private _rebuildParticle;
  35182. /**
  35183. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35184. * @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.
  35185. * @returns the SPS.
  35186. */
  35187. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35188. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35189. * Returns an array with the removed particles.
  35190. * 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.
  35191. * The SPS can't be empty so at least one particle needs to remain in place.
  35192. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35193. * @param start index of the first particle to remove
  35194. * @param end index of the last particle to remove (included)
  35195. * @returns an array populated with the removed particles
  35196. */
  35197. removeParticles(start: number, end: number): SolidParticle[];
  35198. /**
  35199. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35200. * @param solidParticleArray an array populated with Solid Particles objects
  35201. * @returns the SPS
  35202. */
  35203. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35204. /**
  35205. * Creates a new particle and modifies the SPS mesh geometry :
  35206. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35207. * - calls _addParticle() to populate the particle array
  35208. * factorized code from addShape() and insertParticlesFromArray()
  35209. * @param idx particle index in the particles array
  35210. * @param i particle index in its shape
  35211. * @param modelShape particle ModelShape object
  35212. * @param shape shape vertex array
  35213. * @param meshInd shape indices array
  35214. * @param meshUV shape uv array
  35215. * @param meshCol shape color array
  35216. * @param meshNor shape normals array
  35217. * @param bbInfo shape bounding info
  35218. * @param storage target particle storage
  35219. * @options addShape() passed options
  35220. * @hidden
  35221. */
  35222. private _insertNewParticle;
  35223. /**
  35224. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35225. * This method calls `updateParticle()` for each particle of the SPS.
  35226. * For an animated SPS, it is usually called within the render loop.
  35227. * 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.
  35228. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35229. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35230. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35231. * @returns the SPS.
  35232. */
  35233. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35234. /**
  35235. * Disposes the SPS.
  35236. */
  35237. dispose(): void;
  35238. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35239. * idx is the particle index in the SPS
  35240. * faceId is the picked face index counted within this particle.
  35241. * Returns null if the pickInfo can't identify a picked particle.
  35242. * @param pickingInfo (PickingInfo object)
  35243. * @returns {idx: number, faceId: number} or null
  35244. */
  35245. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35246. idx: number;
  35247. faceId: number;
  35248. }>;
  35249. /**
  35250. * Returns a SolidParticle object from its identifier : particle.id
  35251. * @param id (integer) the particle Id
  35252. * @returns the searched particle or null if not found in the SPS.
  35253. */
  35254. getParticleById(id: number): Nullable<SolidParticle>;
  35255. /**
  35256. * Returns a new array populated with the particles having the passed shapeId.
  35257. * @param shapeId (integer) the shape identifier
  35258. * @returns a new solid particle array
  35259. */
  35260. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35261. /**
  35262. * Populates the passed array "ref" with the particles having the passed shapeId.
  35263. * @param shapeId the shape identifier
  35264. * @returns the SPS
  35265. * @param ref
  35266. */
  35267. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35268. /**
  35269. * Computes the required SubMeshes according the materials assigned to the particles.
  35270. * @returns the solid particle system.
  35271. * Does nothing if called before the SPS mesh is built.
  35272. */
  35273. computeSubMeshes(): SolidParticleSystem;
  35274. /**
  35275. * Sorts the solid particles by material when MultiMaterial is enabled.
  35276. * Updates the indices32 array.
  35277. * Updates the indicesByMaterial array.
  35278. * Updates the mesh indices array.
  35279. * @returns the SPS
  35280. * @hidden
  35281. */
  35282. private _sortParticlesByMaterial;
  35283. /**
  35284. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35285. * @hidden
  35286. */
  35287. private _setMaterialIndexesById;
  35288. /**
  35289. * Returns an array with unique values of Materials from the passed array
  35290. * @param array the material array to be checked and filtered
  35291. * @hidden
  35292. */
  35293. private _filterUniqueMaterialId;
  35294. /**
  35295. * Sets a new Standard Material as _defaultMaterial if not already set.
  35296. * @hidden
  35297. */
  35298. private _setDefaultMaterial;
  35299. /**
  35300. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35301. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35302. * @returns the SPS.
  35303. */
  35304. refreshVisibleSize(): SolidParticleSystem;
  35305. /**
  35306. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35307. * @param size the size (float) of the visibility box
  35308. * note : this doesn't lock the SPS mesh bounding box.
  35309. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35310. */
  35311. setVisibilityBox(size: number): void;
  35312. /**
  35313. * Gets whether the SPS as always visible or not
  35314. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35315. */
  35316. get isAlwaysVisible(): boolean;
  35317. /**
  35318. * Sets the SPS as always visible or not
  35319. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35320. */
  35321. set isAlwaysVisible(val: boolean);
  35322. /**
  35323. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35324. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35325. */
  35326. set isVisibilityBoxLocked(val: boolean);
  35327. /**
  35328. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35329. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35330. */
  35331. get isVisibilityBoxLocked(): boolean;
  35332. /**
  35333. * Tells to `setParticles()` to compute the particle rotations or not.
  35334. * Default value : true. The SPS is faster when it's set to false.
  35335. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35336. */
  35337. set computeParticleRotation(val: boolean);
  35338. /**
  35339. * Tells to `setParticles()` to compute the particle colors or not.
  35340. * Default value : true. The SPS is faster when it's set to false.
  35341. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35342. */
  35343. set computeParticleColor(val: boolean);
  35344. set computeParticleTexture(val: boolean);
  35345. /**
  35346. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35347. * Default value : false. The SPS is faster when it's set to false.
  35348. * Note : the particle custom vertex positions aren't stored values.
  35349. */
  35350. set computeParticleVertex(val: boolean);
  35351. /**
  35352. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35353. */
  35354. set computeBoundingBox(val: boolean);
  35355. /**
  35356. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35357. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35358. * Default : `true`
  35359. */
  35360. set depthSortParticles(val: boolean);
  35361. /**
  35362. * Gets if `setParticles()` computes the particle rotations or not.
  35363. * Default value : true. The SPS is faster when it's set to false.
  35364. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35365. */
  35366. get computeParticleRotation(): boolean;
  35367. /**
  35368. * Gets if `setParticles()` computes the particle colors or not.
  35369. * Default value : true. The SPS is faster when it's set to false.
  35370. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35371. */
  35372. get computeParticleColor(): boolean;
  35373. /**
  35374. * Gets if `setParticles()` computes the particle textures or not.
  35375. * Default value : true. The SPS is faster when it's set to false.
  35376. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35377. */
  35378. get computeParticleTexture(): boolean;
  35379. /**
  35380. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35381. * Default value : false. The SPS is faster when it's set to false.
  35382. * Note : the particle custom vertex positions aren't stored values.
  35383. */
  35384. get computeParticleVertex(): boolean;
  35385. /**
  35386. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35387. */
  35388. get computeBoundingBox(): boolean;
  35389. /**
  35390. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35391. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35392. * Default : `true`
  35393. */
  35394. get depthSortParticles(): boolean;
  35395. /**
  35396. * Gets if the SPS is created as expandable at construction time.
  35397. * Default : `false`
  35398. */
  35399. get expandable(): boolean;
  35400. /**
  35401. * Gets if the SPS supports the Multi Materials
  35402. */
  35403. get multimaterialEnabled(): boolean;
  35404. /**
  35405. * Gets if the SPS uses the model materials for its own multimaterial.
  35406. */
  35407. get useModelMaterial(): boolean;
  35408. /**
  35409. * The SPS used material array.
  35410. */
  35411. get materials(): Material[];
  35412. /**
  35413. * Sets the SPS MultiMaterial from the passed materials.
  35414. * Note : the passed array is internally copied and not used then by reference.
  35415. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35416. */
  35417. setMultiMaterial(materials: Material[]): void;
  35418. /**
  35419. * The SPS computed multimaterial object
  35420. */
  35421. get multimaterial(): MultiMaterial;
  35422. set multimaterial(mm: MultiMaterial);
  35423. /**
  35424. * If the subMeshes must be updated on the next call to setParticles()
  35425. */
  35426. get autoUpdateSubMeshes(): boolean;
  35427. set autoUpdateSubMeshes(val: boolean);
  35428. /**
  35429. * This function does nothing. It may be overwritten to set all the particle first values.
  35430. * The SPS doesn't call this function, you may have to call it by your own.
  35431. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35432. */
  35433. initParticles(): void;
  35434. /**
  35435. * This function does nothing. It may be overwritten to recycle a particle.
  35436. * The SPS doesn't call this function, you may have to call it by your own.
  35437. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35438. * @param particle The particle to recycle
  35439. * @returns the recycled particle
  35440. */
  35441. recycleParticle(particle: SolidParticle): SolidParticle;
  35442. /**
  35443. * Updates a particle : this function should be overwritten by the user.
  35444. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35445. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35446. * @example : just set a particle position or velocity and recycle conditions
  35447. * @param particle The particle to update
  35448. * @returns the updated particle
  35449. */
  35450. updateParticle(particle: SolidParticle): SolidParticle;
  35451. /**
  35452. * Updates a vertex of a particle : it can be overwritten by the user.
  35453. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35454. * @param particle the current particle
  35455. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35456. * @param pt the index of the current vertex in the particle shape
  35457. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35458. * @example : just set a vertex particle position or color
  35459. * @returns the sps
  35460. */
  35461. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35462. /**
  35463. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35464. * This does nothing and may be overwritten by the user.
  35465. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35466. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35467. * @param update the boolean update value actually passed to setParticles()
  35468. */
  35469. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35470. /**
  35471. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35472. * This will be passed three parameters.
  35473. * This does nothing and may be overwritten by the user.
  35474. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35475. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35476. * @param update the boolean update value actually passed to setParticles()
  35477. */
  35478. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35479. }
  35480. }
  35481. declare module BABYLON {
  35482. /**
  35483. * Represents one particle of a solid particle system.
  35484. */
  35485. export class SolidParticle {
  35486. /**
  35487. * particle global index
  35488. */
  35489. idx: number;
  35490. /**
  35491. * particle identifier
  35492. */
  35493. id: number;
  35494. /**
  35495. * The color of the particle
  35496. */
  35497. color: Nullable<Color4>;
  35498. /**
  35499. * The world space position of the particle.
  35500. */
  35501. position: Vector3;
  35502. /**
  35503. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35504. */
  35505. rotation: Vector3;
  35506. /**
  35507. * The world space rotation quaternion of the particle.
  35508. */
  35509. rotationQuaternion: Nullable<Quaternion>;
  35510. /**
  35511. * The scaling of the particle.
  35512. */
  35513. scaling: Vector3;
  35514. /**
  35515. * The uvs of the particle.
  35516. */
  35517. uvs: Vector4;
  35518. /**
  35519. * The current speed of the particle.
  35520. */
  35521. velocity: Vector3;
  35522. /**
  35523. * The pivot point in the particle local space.
  35524. */
  35525. pivot: Vector3;
  35526. /**
  35527. * Must the particle be translated from its pivot point in its local space ?
  35528. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35529. * Default : false
  35530. */
  35531. translateFromPivot: boolean;
  35532. /**
  35533. * Is the particle active or not ?
  35534. */
  35535. alive: boolean;
  35536. /**
  35537. * Is the particle visible or not ?
  35538. */
  35539. isVisible: boolean;
  35540. /**
  35541. * Index of this particle in the global "positions" array (Internal use)
  35542. * @hidden
  35543. */
  35544. _pos: number;
  35545. /**
  35546. * @hidden Index of this particle in the global "indices" array (Internal use)
  35547. */
  35548. _ind: number;
  35549. /**
  35550. * @hidden ModelShape of this particle (Internal use)
  35551. */
  35552. _model: ModelShape;
  35553. /**
  35554. * ModelShape id of this particle
  35555. */
  35556. shapeId: number;
  35557. /**
  35558. * Index of the particle in its shape id
  35559. */
  35560. idxInShape: number;
  35561. /**
  35562. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35563. */
  35564. _modelBoundingInfo: BoundingInfo;
  35565. /**
  35566. * @hidden Particle BoundingInfo object (Internal use)
  35567. */
  35568. _boundingInfo: BoundingInfo;
  35569. /**
  35570. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35571. */
  35572. _sps: SolidParticleSystem;
  35573. /**
  35574. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35575. */
  35576. _stillInvisible: boolean;
  35577. /**
  35578. * @hidden Last computed particle rotation matrix
  35579. */
  35580. _rotationMatrix: number[];
  35581. /**
  35582. * Parent particle Id, if any.
  35583. * Default null.
  35584. */
  35585. parentId: Nullable<number>;
  35586. /**
  35587. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35588. */
  35589. materialIndex: Nullable<number>;
  35590. /**
  35591. * Custom object or properties.
  35592. */
  35593. props: Nullable<any>;
  35594. /**
  35595. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35596. * The possible values are :
  35597. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35598. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35599. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35600. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35601. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35602. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35603. * */
  35604. cullingStrategy: number;
  35605. /**
  35606. * @hidden Internal global position in the SPS.
  35607. */
  35608. _globalPosition: Vector3;
  35609. /**
  35610. * Creates a Solid Particle object.
  35611. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35612. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35613. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35614. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35615. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35616. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35617. * @param shapeId (integer) is the model shape identifier in the SPS.
  35618. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35619. * @param sps defines the sps it is associated to
  35620. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35621. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35622. */
  35623. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35624. /**
  35625. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35626. * @param target the particle target
  35627. * @returns the current particle
  35628. */
  35629. copyToRef(target: SolidParticle): SolidParticle;
  35630. /**
  35631. * Legacy support, changed scale to scaling
  35632. */
  35633. get scale(): Vector3;
  35634. /**
  35635. * Legacy support, changed scale to scaling
  35636. */
  35637. set scale(scale: Vector3);
  35638. /**
  35639. * Legacy support, changed quaternion to rotationQuaternion
  35640. */
  35641. get quaternion(): Nullable<Quaternion>;
  35642. /**
  35643. * Legacy support, changed quaternion to rotationQuaternion
  35644. */
  35645. set quaternion(q: Nullable<Quaternion>);
  35646. /**
  35647. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35648. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35649. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35650. * @returns true if it intersects
  35651. */
  35652. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35653. /**
  35654. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35655. * A particle is in the frustum if its bounding box intersects the frustum
  35656. * @param frustumPlanes defines the frustum to test
  35657. * @returns true if the particle is in the frustum planes
  35658. */
  35659. isInFrustum(frustumPlanes: Plane[]): boolean;
  35660. /**
  35661. * get the rotation matrix of the particle
  35662. * @hidden
  35663. */
  35664. getRotationMatrix(m: Matrix): void;
  35665. }
  35666. /**
  35667. * Represents the shape of the model used by one particle of a solid particle system.
  35668. * SPS internal tool, don't use it manually.
  35669. */
  35670. export class ModelShape {
  35671. /**
  35672. * The shape id
  35673. * @hidden
  35674. */
  35675. shapeID: number;
  35676. /**
  35677. * flat array of model positions (internal use)
  35678. * @hidden
  35679. */
  35680. _shape: Vector3[];
  35681. /**
  35682. * flat array of model UVs (internal use)
  35683. * @hidden
  35684. */
  35685. _shapeUV: number[];
  35686. /**
  35687. * color array of the model
  35688. * @hidden
  35689. */
  35690. _shapeColors: number[];
  35691. /**
  35692. * indices array of the model
  35693. * @hidden
  35694. */
  35695. _indices: number[];
  35696. /**
  35697. * normals array of the model
  35698. * @hidden
  35699. */
  35700. _normals: number[];
  35701. /**
  35702. * length of the shape in the model indices array (internal use)
  35703. * @hidden
  35704. */
  35705. _indicesLength: number;
  35706. /**
  35707. * Custom position function (internal use)
  35708. * @hidden
  35709. */
  35710. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35711. /**
  35712. * Custom vertex function (internal use)
  35713. * @hidden
  35714. */
  35715. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35716. /**
  35717. * Model material (internal use)
  35718. * @hidden
  35719. */
  35720. _material: Nullable<Material>;
  35721. /**
  35722. * 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.
  35723. * SPS internal tool, don't use it manually.
  35724. * @hidden
  35725. */
  35726. 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>);
  35727. }
  35728. /**
  35729. * Represents a Depth Sorted Particle in the solid particle system.
  35730. * @hidden
  35731. */
  35732. export class DepthSortedParticle {
  35733. /**
  35734. * Particle index
  35735. */
  35736. idx: number;
  35737. /**
  35738. * Index of the particle in the "indices" array
  35739. */
  35740. ind: number;
  35741. /**
  35742. * Length of the particle shape in the "indices" array
  35743. */
  35744. indicesLength: number;
  35745. /**
  35746. * Squared distance from the particle to the camera
  35747. */
  35748. sqDistance: number;
  35749. /**
  35750. * Material index when used with MultiMaterials
  35751. */
  35752. materialIndex: number;
  35753. /**
  35754. * Creates a new sorted particle
  35755. * @param materialIndex
  35756. */
  35757. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35758. }
  35759. /**
  35760. * Represents a solid particle vertex
  35761. */
  35762. export class SolidParticleVertex {
  35763. /**
  35764. * Vertex position
  35765. */
  35766. position: Vector3;
  35767. /**
  35768. * Vertex color
  35769. */
  35770. color: Color4;
  35771. /**
  35772. * Vertex UV
  35773. */
  35774. uv: Vector2;
  35775. /**
  35776. * Creates a new solid particle vertex
  35777. */
  35778. constructor();
  35779. /** Vertex x coordinate */
  35780. get x(): number;
  35781. set x(val: number);
  35782. /** Vertex y coordinate */
  35783. get y(): number;
  35784. set y(val: number);
  35785. /** Vertex z coordinate */
  35786. get z(): number;
  35787. set z(val: number);
  35788. }
  35789. }
  35790. declare module BABYLON {
  35791. /**
  35792. * @hidden
  35793. */
  35794. export class _MeshCollisionData {
  35795. _checkCollisions: boolean;
  35796. _collisionMask: number;
  35797. _collisionGroup: number;
  35798. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35799. _collider: Nullable<Collider>;
  35800. _oldPositionForCollisions: Vector3;
  35801. _diffPositionForCollisions: Vector3;
  35802. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35803. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35804. _collisionResponse: boolean;
  35805. }
  35806. }
  35807. declare module BABYLON {
  35808. /** @hidden */
  35809. class _FacetDataStorage {
  35810. facetPositions: Vector3[];
  35811. facetNormals: Vector3[];
  35812. facetPartitioning: number[][];
  35813. facetNb: number;
  35814. partitioningSubdivisions: number;
  35815. partitioningBBoxRatio: number;
  35816. facetDataEnabled: boolean;
  35817. facetParameters: any;
  35818. bbSize: Vector3;
  35819. subDiv: {
  35820. max: number;
  35821. X: number;
  35822. Y: number;
  35823. Z: number;
  35824. };
  35825. facetDepthSort: boolean;
  35826. facetDepthSortEnabled: boolean;
  35827. depthSortedIndices: IndicesArray;
  35828. depthSortedFacets: {
  35829. ind: number;
  35830. sqDistance: number;
  35831. }[];
  35832. facetDepthSortFunction: (f1: {
  35833. ind: number;
  35834. sqDistance: number;
  35835. }, f2: {
  35836. ind: number;
  35837. sqDistance: number;
  35838. }) => number;
  35839. facetDepthSortFrom: Vector3;
  35840. facetDepthSortOrigin: Vector3;
  35841. invertedMatrix: Matrix;
  35842. }
  35843. /**
  35844. * @hidden
  35845. **/
  35846. class _InternalAbstractMeshDataInfo {
  35847. _hasVertexAlpha: boolean;
  35848. _useVertexColors: boolean;
  35849. _numBoneInfluencers: number;
  35850. _applyFog: boolean;
  35851. _receiveShadows: boolean;
  35852. _facetData: _FacetDataStorage;
  35853. _visibility: number;
  35854. _skeleton: Nullable<Skeleton>;
  35855. _layerMask: number;
  35856. _computeBonesUsingShaders: boolean;
  35857. _isActive: boolean;
  35858. _onlyForInstances: boolean;
  35859. _isActiveIntermediate: boolean;
  35860. _onlyForInstancesIntermediate: boolean;
  35861. _actAsRegularMesh: boolean;
  35862. _currentLOD: Nullable<AbstractMesh>;
  35863. _currentLODIsUpToDate: boolean;
  35864. }
  35865. /**
  35866. * Class used to store all common mesh properties
  35867. */
  35868. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35869. /** No occlusion */
  35870. static OCCLUSION_TYPE_NONE: number;
  35871. /** Occlusion set to optimisitic */
  35872. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35873. /** Occlusion set to strict */
  35874. static OCCLUSION_TYPE_STRICT: number;
  35875. /** Use an accurante occlusion algorithm */
  35876. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35877. /** Use a conservative occlusion algorithm */
  35878. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35879. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35880. * Test order :
  35881. * Is the bounding sphere outside the frustum ?
  35882. * If not, are the bounding box vertices outside the frustum ?
  35883. * It not, then the cullable object is in the frustum.
  35884. */
  35885. static readonly CULLINGSTRATEGY_STANDARD: number;
  35886. /** Culling strategy : Bounding Sphere Only.
  35887. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35888. * It's also less accurate than the standard because some not visible objects can still be selected.
  35889. * Test : is the bounding sphere outside the frustum ?
  35890. * If not, then the cullable object is in the frustum.
  35891. */
  35892. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35893. /** Culling strategy : Optimistic Inclusion.
  35894. * This in an inclusion test first, then the standard exclusion test.
  35895. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35896. * 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.
  35897. * Anyway, it's as accurate as the standard strategy.
  35898. * Test :
  35899. * Is the cullable object bounding sphere center in the frustum ?
  35900. * If not, apply the default culling strategy.
  35901. */
  35902. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35903. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35904. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35905. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35906. * 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.
  35907. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35908. * Test :
  35909. * Is the cullable object bounding sphere center in the frustum ?
  35910. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35911. */
  35912. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35913. /**
  35914. * No billboard
  35915. */
  35916. static get BILLBOARDMODE_NONE(): number;
  35917. /** Billboard on X axis */
  35918. static get BILLBOARDMODE_X(): number;
  35919. /** Billboard on Y axis */
  35920. static get BILLBOARDMODE_Y(): number;
  35921. /** Billboard on Z axis */
  35922. static get BILLBOARDMODE_Z(): number;
  35923. /** Billboard on all axes */
  35924. static get BILLBOARDMODE_ALL(): number;
  35925. /** Billboard on using position instead of orientation */
  35926. static get BILLBOARDMODE_USE_POSITION(): number;
  35927. /** @hidden */
  35928. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35929. /**
  35930. * The culling strategy to use to check whether the mesh must be rendered or not.
  35931. * This value can be changed at any time and will be used on the next render mesh selection.
  35932. * The possible values are :
  35933. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35934. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35935. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35936. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35937. * Please read each static variable documentation to get details about the culling process.
  35938. * */
  35939. cullingStrategy: number;
  35940. /**
  35941. * Gets the number of facets in the mesh
  35942. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35943. */
  35944. get facetNb(): number;
  35945. /**
  35946. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35947. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35948. */
  35949. get partitioningSubdivisions(): number;
  35950. set partitioningSubdivisions(nb: number);
  35951. /**
  35952. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35953. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35954. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35955. */
  35956. get partitioningBBoxRatio(): number;
  35957. set partitioningBBoxRatio(ratio: number);
  35958. /**
  35959. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35960. * Works only for updatable meshes.
  35961. * Doesn't work with multi-materials
  35962. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35963. */
  35964. get mustDepthSortFacets(): boolean;
  35965. set mustDepthSortFacets(sort: boolean);
  35966. /**
  35967. * The location (Vector3) where the facet depth sort must be computed from.
  35968. * By default, the active camera position.
  35969. * Used only when facet depth sort is enabled
  35970. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35971. */
  35972. get facetDepthSortFrom(): Vector3;
  35973. set facetDepthSortFrom(location: Vector3);
  35974. /**
  35975. * gets a boolean indicating if facetData is enabled
  35976. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35977. */
  35978. get isFacetDataEnabled(): boolean;
  35979. /** @hidden */
  35980. _updateNonUniformScalingState(value: boolean): boolean;
  35981. /**
  35982. * An event triggered when this mesh collides with another one
  35983. */
  35984. onCollideObservable: Observable<AbstractMesh>;
  35985. /** Set a function to call when this mesh collides with another one */
  35986. set onCollide(callback: () => void);
  35987. /**
  35988. * An event triggered when the collision's position changes
  35989. */
  35990. onCollisionPositionChangeObservable: Observable<Vector3>;
  35991. /** Set a function to call when the collision's position changes */
  35992. set onCollisionPositionChange(callback: () => void);
  35993. /**
  35994. * An event triggered when material is changed
  35995. */
  35996. onMaterialChangedObservable: Observable<AbstractMesh>;
  35997. /**
  35998. * Gets or sets the orientation for POV movement & rotation
  35999. */
  36000. definedFacingForward: boolean;
  36001. /** @hidden */
  36002. _occlusionQuery: Nullable<WebGLQuery>;
  36003. /** @hidden */
  36004. _renderingGroup: Nullable<RenderingGroup>;
  36005. /**
  36006. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36007. */
  36008. get visibility(): number;
  36009. /**
  36010. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36011. */
  36012. set visibility(value: number);
  36013. /** Gets or sets the alpha index used to sort transparent meshes
  36014. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36015. */
  36016. alphaIndex: number;
  36017. /**
  36018. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36019. */
  36020. isVisible: boolean;
  36021. /**
  36022. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36023. */
  36024. isPickable: boolean;
  36025. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36026. showSubMeshesBoundingBox: boolean;
  36027. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36028. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36029. */
  36030. isBlocker: boolean;
  36031. /**
  36032. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36033. */
  36034. enablePointerMoveEvents: boolean;
  36035. private _renderingGroupId;
  36036. /**
  36037. * Specifies the rendering group id for this mesh (0 by default)
  36038. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36039. */
  36040. get renderingGroupId(): number;
  36041. set renderingGroupId(value: number);
  36042. private _material;
  36043. /** Gets or sets current material */
  36044. get material(): Nullable<Material>;
  36045. set material(value: Nullable<Material>);
  36046. /**
  36047. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36048. * @see https://doc.babylonjs.com/babylon101/shadows
  36049. */
  36050. get receiveShadows(): boolean;
  36051. set receiveShadows(value: boolean);
  36052. /** Defines color to use when rendering outline */
  36053. outlineColor: Color3;
  36054. /** Define width to use when rendering outline */
  36055. outlineWidth: number;
  36056. /** Defines color to use when rendering overlay */
  36057. overlayColor: Color3;
  36058. /** Defines alpha to use when rendering overlay */
  36059. overlayAlpha: number;
  36060. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36061. get hasVertexAlpha(): boolean;
  36062. set hasVertexAlpha(value: boolean);
  36063. /** 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) */
  36064. get useVertexColors(): boolean;
  36065. set useVertexColors(value: boolean);
  36066. /**
  36067. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36068. */
  36069. get computeBonesUsingShaders(): boolean;
  36070. set computeBonesUsingShaders(value: boolean);
  36071. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36072. get numBoneInfluencers(): number;
  36073. set numBoneInfluencers(value: number);
  36074. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36075. get applyFog(): boolean;
  36076. set applyFog(value: boolean);
  36077. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36078. useOctreeForRenderingSelection: boolean;
  36079. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36080. useOctreeForPicking: boolean;
  36081. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36082. useOctreeForCollisions: boolean;
  36083. /**
  36084. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36085. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36086. */
  36087. get layerMask(): number;
  36088. set layerMask(value: number);
  36089. /**
  36090. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36091. */
  36092. alwaysSelectAsActiveMesh: boolean;
  36093. /**
  36094. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36095. */
  36096. doNotSyncBoundingInfo: boolean;
  36097. /**
  36098. * Gets or sets the current action manager
  36099. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36100. */
  36101. actionManager: Nullable<AbstractActionManager>;
  36102. private _meshCollisionData;
  36103. /**
  36104. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36105. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36106. */
  36107. ellipsoid: Vector3;
  36108. /**
  36109. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36110. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36111. */
  36112. ellipsoidOffset: Vector3;
  36113. /**
  36114. * Gets or sets a collision mask used to mask collisions (default is -1).
  36115. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36116. */
  36117. get collisionMask(): number;
  36118. set collisionMask(mask: number);
  36119. /**
  36120. * Gets or sets a collision response flag (default is true).
  36121. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36122. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36123. * to respond to the collision.
  36124. */
  36125. get collisionResponse(): boolean;
  36126. set collisionResponse(response: boolean);
  36127. /**
  36128. * Gets or sets the current collision group mask (-1 by default).
  36129. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36130. */
  36131. get collisionGroup(): number;
  36132. set collisionGroup(mask: number);
  36133. /**
  36134. * Gets or sets current surrounding meshes (null by default).
  36135. *
  36136. * By default collision detection is tested against every mesh in the scene.
  36137. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36138. * meshes will be tested for the collision.
  36139. *
  36140. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36141. */
  36142. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36143. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36144. /**
  36145. * Defines edge width used when edgesRenderer is enabled
  36146. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36147. */
  36148. edgesWidth: number;
  36149. /**
  36150. * Defines edge color used when edgesRenderer is enabled
  36151. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36152. */
  36153. edgesColor: Color4;
  36154. /** @hidden */
  36155. _edgesRenderer: Nullable<IEdgesRenderer>;
  36156. /** @hidden */
  36157. _masterMesh: Nullable<AbstractMesh>;
  36158. /** @hidden */
  36159. _boundingInfo: Nullable<BoundingInfo>;
  36160. /** @hidden */
  36161. _renderId: number;
  36162. /**
  36163. * Gets or sets the list of subMeshes
  36164. * @see https://doc.babylonjs.com/how_to/multi_materials
  36165. */
  36166. subMeshes: SubMesh[];
  36167. /** @hidden */
  36168. _intersectionsInProgress: AbstractMesh[];
  36169. /** @hidden */
  36170. _unIndexed: boolean;
  36171. /** @hidden */
  36172. _lightSources: Light[];
  36173. /** Gets the list of lights affecting that mesh */
  36174. get lightSources(): Light[];
  36175. /** @hidden */
  36176. get _positions(): Nullable<Vector3[]>;
  36177. /** @hidden */
  36178. _waitingData: {
  36179. lods: Nullable<any>;
  36180. actions: Nullable<any>;
  36181. freezeWorldMatrix: Nullable<boolean>;
  36182. };
  36183. /** @hidden */
  36184. _bonesTransformMatrices: Nullable<Float32Array>;
  36185. /** @hidden */
  36186. _transformMatrixTexture: Nullable<RawTexture>;
  36187. /**
  36188. * Gets or sets a skeleton to apply skining transformations
  36189. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36190. */
  36191. set skeleton(value: Nullable<Skeleton>);
  36192. get skeleton(): Nullable<Skeleton>;
  36193. /**
  36194. * An event triggered when the mesh is rebuilt.
  36195. */
  36196. onRebuildObservable: Observable<AbstractMesh>;
  36197. /**
  36198. * The current mesh unifom buffer.
  36199. * @hidden Internal use only.
  36200. */
  36201. _uniformBuffer: UniformBuffer;
  36202. /**
  36203. * Creates a new AbstractMesh
  36204. * @param name defines the name of the mesh
  36205. * @param scene defines the hosting scene
  36206. */
  36207. constructor(name: string, scene?: Nullable<Scene>);
  36208. protected _buildUniformLayout(): void;
  36209. /**
  36210. * Transfer the mesh values to its UBO.
  36211. * @param world The world matrix associated with the mesh
  36212. */
  36213. transferToEffect(world: Matrix): void;
  36214. /**
  36215. * Gets the mesh uniform buffer.
  36216. * @return the uniform buffer of the mesh.
  36217. */
  36218. getMeshUniformBuffer(): UniformBuffer;
  36219. /**
  36220. * Returns the string "AbstractMesh"
  36221. * @returns "AbstractMesh"
  36222. */
  36223. getClassName(): string;
  36224. /**
  36225. * Gets a string representation of the current mesh
  36226. * @param fullDetails defines a boolean indicating if full details must be included
  36227. * @returns a string representation of the current mesh
  36228. */
  36229. toString(fullDetails?: boolean): string;
  36230. /**
  36231. * @hidden
  36232. */
  36233. protected _getEffectiveParent(): Nullable<Node>;
  36234. /** @hidden */
  36235. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36236. /** @hidden */
  36237. _rebuild(): void;
  36238. /** @hidden */
  36239. _resyncLightSources(): void;
  36240. /** @hidden */
  36241. _resyncLightSource(light: Light): void;
  36242. /** @hidden */
  36243. _unBindEffect(): void;
  36244. /** @hidden */
  36245. _removeLightSource(light: Light, dispose: boolean): void;
  36246. private _markSubMeshesAsDirty;
  36247. /** @hidden */
  36248. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36249. /** @hidden */
  36250. _markSubMeshesAsAttributesDirty(): void;
  36251. /** @hidden */
  36252. _markSubMeshesAsMiscDirty(): void;
  36253. /**
  36254. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36255. */
  36256. get scaling(): Vector3;
  36257. set scaling(newScaling: Vector3);
  36258. /**
  36259. * Returns true if the mesh is blocked. Implemented by child classes
  36260. */
  36261. get isBlocked(): boolean;
  36262. /**
  36263. * Returns the mesh itself by default. Implemented by child classes
  36264. * @param camera defines the camera to use to pick the right LOD level
  36265. * @returns the currentAbstractMesh
  36266. */
  36267. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36268. /**
  36269. * Returns 0 by default. Implemented by child classes
  36270. * @returns an integer
  36271. */
  36272. getTotalVertices(): number;
  36273. /**
  36274. * Returns a positive integer : the total number of indices in this mesh geometry.
  36275. * @returns the numner of indices or zero if the mesh has no geometry.
  36276. */
  36277. getTotalIndices(): number;
  36278. /**
  36279. * Returns null by default. Implemented by child classes
  36280. * @returns null
  36281. */
  36282. getIndices(): Nullable<IndicesArray>;
  36283. /**
  36284. * Returns the array of the requested vertex data kind. Implemented by child classes
  36285. * @param kind defines the vertex data kind to use
  36286. * @returns null
  36287. */
  36288. getVerticesData(kind: string): Nullable<FloatArray>;
  36289. /**
  36290. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36291. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36292. * Note that a new underlying VertexBuffer object is created each call.
  36293. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36294. * @param kind defines vertex data kind:
  36295. * * VertexBuffer.PositionKind
  36296. * * VertexBuffer.UVKind
  36297. * * VertexBuffer.UV2Kind
  36298. * * VertexBuffer.UV3Kind
  36299. * * VertexBuffer.UV4Kind
  36300. * * VertexBuffer.UV5Kind
  36301. * * VertexBuffer.UV6Kind
  36302. * * VertexBuffer.ColorKind
  36303. * * VertexBuffer.MatricesIndicesKind
  36304. * * VertexBuffer.MatricesIndicesExtraKind
  36305. * * VertexBuffer.MatricesWeightsKind
  36306. * * VertexBuffer.MatricesWeightsExtraKind
  36307. * @param data defines the data source
  36308. * @param updatable defines if the data must be flagged as updatable (or static)
  36309. * @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
  36310. * @returns the current mesh
  36311. */
  36312. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36313. /**
  36314. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36315. * If the mesh has no geometry, it is simply returned as it is.
  36316. * @param kind defines vertex data kind:
  36317. * * VertexBuffer.PositionKind
  36318. * * VertexBuffer.UVKind
  36319. * * VertexBuffer.UV2Kind
  36320. * * VertexBuffer.UV3Kind
  36321. * * VertexBuffer.UV4Kind
  36322. * * VertexBuffer.UV5Kind
  36323. * * VertexBuffer.UV6Kind
  36324. * * VertexBuffer.ColorKind
  36325. * * VertexBuffer.MatricesIndicesKind
  36326. * * VertexBuffer.MatricesIndicesExtraKind
  36327. * * VertexBuffer.MatricesWeightsKind
  36328. * * VertexBuffer.MatricesWeightsExtraKind
  36329. * @param data defines the data source
  36330. * @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
  36331. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36332. * @returns the current mesh
  36333. */
  36334. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36335. /**
  36336. * Sets the mesh indices,
  36337. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36338. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36339. * @param totalVertices Defines the total number of vertices
  36340. * @returns the current mesh
  36341. */
  36342. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36343. /**
  36344. * Gets a boolean indicating if specific vertex data is present
  36345. * @param kind defines the vertex data kind to use
  36346. * @returns true is data kind is present
  36347. */
  36348. isVerticesDataPresent(kind: string): boolean;
  36349. /**
  36350. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36351. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36352. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36353. * @returns a BoundingInfo
  36354. */
  36355. getBoundingInfo(): BoundingInfo;
  36356. /**
  36357. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36358. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36359. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36360. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36361. * @returns the current mesh
  36362. */
  36363. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36364. /**
  36365. * Overwrite the current bounding info
  36366. * @param boundingInfo defines the new bounding info
  36367. * @returns the current mesh
  36368. */
  36369. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36370. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36371. get useBones(): boolean;
  36372. /** @hidden */
  36373. _preActivate(): void;
  36374. /** @hidden */
  36375. _preActivateForIntermediateRendering(renderId: number): void;
  36376. /** @hidden */
  36377. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36378. /** @hidden */
  36379. _postActivate(): void;
  36380. /** @hidden */
  36381. _freeze(): void;
  36382. /** @hidden */
  36383. _unFreeze(): void;
  36384. /**
  36385. * Gets the current world matrix
  36386. * @returns a Matrix
  36387. */
  36388. getWorldMatrix(): Matrix;
  36389. /** @hidden */
  36390. _getWorldMatrixDeterminant(): number;
  36391. /**
  36392. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36393. */
  36394. get isAnInstance(): boolean;
  36395. /**
  36396. * Gets a boolean indicating if this mesh has instances
  36397. */
  36398. get hasInstances(): boolean;
  36399. /**
  36400. * Gets a boolean indicating if this mesh has thin instances
  36401. */
  36402. get hasThinInstances(): boolean;
  36403. /**
  36404. * Perform relative position change from the point of view of behind the front of the mesh.
  36405. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36406. * Supports definition of mesh facing forward or backward
  36407. * @param amountRight defines the distance on the right axis
  36408. * @param amountUp defines the distance on the up axis
  36409. * @param amountForward defines the distance on the forward axis
  36410. * @returns the current mesh
  36411. */
  36412. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36413. /**
  36414. * Calculate relative position change from the point of view of behind the front of the mesh.
  36415. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36416. * Supports definition of mesh facing forward or backward
  36417. * @param amountRight defines the distance on the right axis
  36418. * @param amountUp defines the distance on the up axis
  36419. * @param amountForward defines the distance on the forward axis
  36420. * @returns the new displacement vector
  36421. */
  36422. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36423. /**
  36424. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36425. * Supports definition of mesh facing forward or backward
  36426. * @param flipBack defines the flip
  36427. * @param twirlClockwise defines the twirl
  36428. * @param tiltRight defines the tilt
  36429. * @returns the current mesh
  36430. */
  36431. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36432. /**
  36433. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36434. * Supports definition of mesh facing forward or backward.
  36435. * @param flipBack defines the flip
  36436. * @param twirlClockwise defines the twirl
  36437. * @param tiltRight defines the tilt
  36438. * @returns the new rotation vector
  36439. */
  36440. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36441. /**
  36442. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36443. * This means the mesh underlying bounding box and sphere are recomputed.
  36444. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36445. * @returns the current mesh
  36446. */
  36447. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36448. /** @hidden */
  36449. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36450. /** @hidden */
  36451. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36452. /** @hidden */
  36453. _updateBoundingInfo(): AbstractMesh;
  36454. /** @hidden */
  36455. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36456. /** @hidden */
  36457. protected _afterComputeWorldMatrix(): void;
  36458. /** @hidden */
  36459. get _effectiveMesh(): AbstractMesh;
  36460. /**
  36461. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36462. * A mesh is in the frustum if its bounding box intersects the frustum
  36463. * @param frustumPlanes defines the frustum to test
  36464. * @returns true if the mesh is in the frustum planes
  36465. */
  36466. isInFrustum(frustumPlanes: Plane[]): boolean;
  36467. /**
  36468. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36469. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36470. * @param frustumPlanes defines the frustum to test
  36471. * @returns true if the mesh is completely in the frustum planes
  36472. */
  36473. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36474. /**
  36475. * True if the mesh intersects another mesh or a SolidParticle object
  36476. * @param mesh defines a target mesh or SolidParticle to test
  36477. * @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)
  36478. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36479. * @returns true if there is an intersection
  36480. */
  36481. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36482. /**
  36483. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36484. * @param point defines the point to test
  36485. * @returns true if there is an intersection
  36486. */
  36487. intersectsPoint(point: Vector3): boolean;
  36488. /**
  36489. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36490. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36491. */
  36492. get checkCollisions(): boolean;
  36493. set checkCollisions(collisionEnabled: boolean);
  36494. /**
  36495. * Gets Collider object used to compute collisions (not physics)
  36496. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36497. */
  36498. get collider(): Nullable<Collider>;
  36499. /**
  36500. * Move the mesh using collision engine
  36501. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36502. * @param displacement defines the requested displacement vector
  36503. * @returns the current mesh
  36504. */
  36505. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36506. private _onCollisionPositionChange;
  36507. /** @hidden */
  36508. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36509. /** @hidden */
  36510. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36511. /** @hidden */
  36512. _checkCollision(collider: Collider): AbstractMesh;
  36513. /** @hidden */
  36514. _generatePointsArray(): boolean;
  36515. /**
  36516. * Checks if the passed Ray intersects with the mesh
  36517. * @param ray defines the ray to use
  36518. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36519. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36520. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36521. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36522. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36523. * @returns the picking info
  36524. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36525. */
  36526. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36527. /**
  36528. * Clones the current mesh
  36529. * @param name defines the mesh name
  36530. * @param newParent defines the new mesh parent
  36531. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36532. * @returns the new mesh
  36533. */
  36534. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36535. /**
  36536. * Disposes all the submeshes of the current meshnp
  36537. * @returns the current mesh
  36538. */
  36539. releaseSubMeshes(): AbstractMesh;
  36540. /**
  36541. * Releases resources associated with this abstract mesh.
  36542. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36543. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36544. */
  36545. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36546. /**
  36547. * Adds the passed mesh as a child to the current mesh
  36548. * @param mesh defines the child mesh
  36549. * @returns the current mesh
  36550. */
  36551. addChild(mesh: AbstractMesh): AbstractMesh;
  36552. /**
  36553. * Removes the passed mesh from the current mesh children list
  36554. * @param mesh defines the child mesh
  36555. * @returns the current mesh
  36556. */
  36557. removeChild(mesh: AbstractMesh): AbstractMesh;
  36558. /** @hidden */
  36559. private _initFacetData;
  36560. /**
  36561. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36562. * This method can be called within the render loop.
  36563. * 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
  36564. * @returns the current mesh
  36565. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36566. */
  36567. updateFacetData(): AbstractMesh;
  36568. /**
  36569. * Returns the facetLocalNormals array.
  36570. * The normals are expressed in the mesh local spac
  36571. * @returns an array of Vector3
  36572. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36573. */
  36574. getFacetLocalNormals(): Vector3[];
  36575. /**
  36576. * Returns the facetLocalPositions array.
  36577. * The facet positions are expressed in the mesh local space
  36578. * @returns an array of Vector3
  36579. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36580. */
  36581. getFacetLocalPositions(): Vector3[];
  36582. /**
  36583. * Returns the facetLocalPartioning array
  36584. * @returns an array of array of numbers
  36585. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36586. */
  36587. getFacetLocalPartitioning(): number[][];
  36588. /**
  36589. * Returns the i-th facet position in the world system.
  36590. * This method allocates a new Vector3 per call
  36591. * @param i defines the facet index
  36592. * @returns a new Vector3
  36593. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36594. */
  36595. getFacetPosition(i: number): Vector3;
  36596. /**
  36597. * Sets the reference Vector3 with the i-th facet position in the world system
  36598. * @param i defines the facet index
  36599. * @param ref defines the target vector
  36600. * @returns the current mesh
  36601. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36602. */
  36603. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36604. /**
  36605. * Returns the i-th facet normal in the world system.
  36606. * This method allocates a new Vector3 per call
  36607. * @param i defines the facet index
  36608. * @returns a new Vector3
  36609. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36610. */
  36611. getFacetNormal(i: number): Vector3;
  36612. /**
  36613. * Sets the reference Vector3 with the i-th facet normal in the world system
  36614. * @param i defines the facet index
  36615. * @param ref defines the target vector
  36616. * @returns the current mesh
  36617. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36618. */
  36619. getFacetNormalToRef(i: number, ref: Vector3): this;
  36620. /**
  36621. * 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)
  36622. * @param x defines x coordinate
  36623. * @param y defines y coordinate
  36624. * @param z defines z coordinate
  36625. * @returns the array of facet indexes
  36626. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36627. */
  36628. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36629. /**
  36630. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36631. * @param projected sets as the (x,y,z) world projection on the facet
  36632. * @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
  36633. * @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
  36634. * @param x defines x coordinate
  36635. * @param y defines y coordinate
  36636. * @param z defines z coordinate
  36637. * @returns the face index if found (or null instead)
  36638. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36639. */
  36640. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36641. /**
  36642. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36643. * @param projected sets as the (x,y,z) local projection on the facet
  36644. * @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
  36645. * @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
  36646. * @param x defines x coordinate
  36647. * @param y defines y coordinate
  36648. * @param z defines z coordinate
  36649. * @returns the face index if found (or null instead)
  36650. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36651. */
  36652. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36653. /**
  36654. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36655. * @returns the parameters
  36656. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36657. */
  36658. getFacetDataParameters(): any;
  36659. /**
  36660. * Disables the feature FacetData and frees the related memory
  36661. * @returns the current mesh
  36662. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36663. */
  36664. disableFacetData(): AbstractMesh;
  36665. /**
  36666. * Updates the AbstractMesh indices array
  36667. * @param indices defines the data source
  36668. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36669. * @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)
  36670. * @returns the current mesh
  36671. */
  36672. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36673. /**
  36674. * Creates new normals data for the mesh
  36675. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36676. * @returns the current mesh
  36677. */
  36678. createNormals(updatable: boolean): AbstractMesh;
  36679. /**
  36680. * Align the mesh with a normal
  36681. * @param normal defines the normal to use
  36682. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36683. * @returns the current mesh
  36684. */
  36685. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36686. /** @hidden */
  36687. _checkOcclusionQuery(): boolean;
  36688. /**
  36689. * Disables the mesh edge rendering mode
  36690. * @returns the currentAbstractMesh
  36691. */
  36692. disableEdgesRendering(): AbstractMesh;
  36693. /**
  36694. * Enables the edge rendering mode on the mesh.
  36695. * This mode makes the mesh edges visible
  36696. * @param epsilon defines the maximal distance between two angles to detect a face
  36697. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36698. * @param options options to the edge renderer
  36699. * @returns the currentAbstractMesh
  36700. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36701. */
  36702. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  36703. /**
  36704. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36705. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36706. */
  36707. getConnectedParticleSystems(): IParticleSystem[];
  36708. }
  36709. }
  36710. declare module BABYLON {
  36711. /**
  36712. * Interface used to define ActionEvent
  36713. */
  36714. export interface IActionEvent {
  36715. /** The mesh or sprite that triggered the action */
  36716. source: any;
  36717. /** The X mouse cursor position at the time of the event */
  36718. pointerX: number;
  36719. /** The Y mouse cursor position at the time of the event */
  36720. pointerY: number;
  36721. /** The mesh that is currently pointed at (can be null) */
  36722. meshUnderPointer: Nullable<AbstractMesh>;
  36723. /** the original (browser) event that triggered the ActionEvent */
  36724. sourceEvent?: any;
  36725. /** additional data for the event */
  36726. additionalData?: any;
  36727. }
  36728. /**
  36729. * ActionEvent is the event being sent when an action is triggered.
  36730. */
  36731. export class ActionEvent implements IActionEvent {
  36732. /** The mesh or sprite that triggered the action */
  36733. source: any;
  36734. /** The X mouse cursor position at the time of the event */
  36735. pointerX: number;
  36736. /** The Y mouse cursor position at the time of the event */
  36737. pointerY: number;
  36738. /** The mesh that is currently pointed at (can be null) */
  36739. meshUnderPointer: Nullable<AbstractMesh>;
  36740. /** the original (browser) event that triggered the ActionEvent */
  36741. sourceEvent?: any;
  36742. /** additional data for the event */
  36743. additionalData?: any;
  36744. /**
  36745. * Creates a new ActionEvent
  36746. * @param source The mesh or sprite that triggered the action
  36747. * @param pointerX The X mouse cursor position at the time of the event
  36748. * @param pointerY The Y mouse cursor position at the time of the event
  36749. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36750. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36751. * @param additionalData additional data for the event
  36752. */
  36753. constructor(
  36754. /** The mesh or sprite that triggered the action */
  36755. source: any,
  36756. /** The X mouse cursor position at the time of the event */
  36757. pointerX: number,
  36758. /** The Y mouse cursor position at the time of the event */
  36759. pointerY: number,
  36760. /** The mesh that is currently pointed at (can be null) */
  36761. meshUnderPointer: Nullable<AbstractMesh>,
  36762. /** the original (browser) event that triggered the ActionEvent */
  36763. sourceEvent?: any,
  36764. /** additional data for the event */
  36765. additionalData?: any);
  36766. /**
  36767. * Helper function to auto-create an ActionEvent from a source mesh.
  36768. * @param source The source mesh that triggered the event
  36769. * @param evt The original (browser) event
  36770. * @param additionalData additional data for the event
  36771. * @returns the new ActionEvent
  36772. */
  36773. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36774. /**
  36775. * Helper function to auto-create an ActionEvent from a source sprite
  36776. * @param source The source sprite that triggered the event
  36777. * @param scene Scene associated with the sprite
  36778. * @param evt The original (browser) event
  36779. * @param additionalData additional data for the event
  36780. * @returns the new ActionEvent
  36781. */
  36782. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36783. /**
  36784. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36785. * @param scene the scene where the event occurred
  36786. * @param evt The original (browser) event
  36787. * @returns the new ActionEvent
  36788. */
  36789. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36790. /**
  36791. * Helper function to auto-create an ActionEvent from a primitive
  36792. * @param prim defines the target primitive
  36793. * @param pointerPos defines the pointer position
  36794. * @param evt The original (browser) event
  36795. * @param additionalData additional data for the event
  36796. * @returns the new ActionEvent
  36797. */
  36798. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36799. }
  36800. }
  36801. declare module BABYLON {
  36802. /**
  36803. * Abstract class used to decouple action Manager from scene and meshes.
  36804. * Do not instantiate.
  36805. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36806. */
  36807. export abstract class AbstractActionManager implements IDisposable {
  36808. /** Gets the list of active triggers */
  36809. static Triggers: {
  36810. [key: string]: number;
  36811. };
  36812. /** Gets the cursor to use when hovering items */
  36813. hoverCursor: string;
  36814. /** Gets the list of actions */
  36815. actions: IAction[];
  36816. /**
  36817. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36818. */
  36819. isRecursive: boolean;
  36820. /**
  36821. * Releases all associated resources
  36822. */
  36823. abstract dispose(): void;
  36824. /**
  36825. * Does this action manager has pointer triggers
  36826. */
  36827. abstract get hasPointerTriggers(): boolean;
  36828. /**
  36829. * Does this action manager has pick triggers
  36830. */
  36831. abstract get hasPickTriggers(): boolean;
  36832. /**
  36833. * Process a specific trigger
  36834. * @param trigger defines the trigger to process
  36835. * @param evt defines the event details to be processed
  36836. */
  36837. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36838. /**
  36839. * Does this action manager handles actions of any of the given triggers
  36840. * @param triggers defines the triggers to be tested
  36841. * @return a boolean indicating whether one (or more) of the triggers is handled
  36842. */
  36843. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36844. /**
  36845. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36846. * speed.
  36847. * @param triggerA defines the trigger to be tested
  36848. * @param triggerB defines the trigger to be tested
  36849. * @return a boolean indicating whether one (or more) of the triggers is handled
  36850. */
  36851. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36852. /**
  36853. * Does this action manager handles actions of a given trigger
  36854. * @param trigger defines the trigger to be tested
  36855. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36856. * @return whether the trigger is handled
  36857. */
  36858. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36859. /**
  36860. * Serialize this manager to a JSON object
  36861. * @param name defines the property name to store this manager
  36862. * @returns a JSON representation of this manager
  36863. */
  36864. abstract serialize(name: string): any;
  36865. /**
  36866. * Registers an action to this action manager
  36867. * @param action defines the action to be registered
  36868. * @return the action amended (prepared) after registration
  36869. */
  36870. abstract registerAction(action: IAction): Nullable<IAction>;
  36871. /**
  36872. * Unregisters an action to this action manager
  36873. * @param action defines the action to be unregistered
  36874. * @return a boolean indicating whether the action has been unregistered
  36875. */
  36876. abstract unregisterAction(action: IAction): Boolean;
  36877. /**
  36878. * Does exist one action manager with at least one trigger
  36879. **/
  36880. static get HasTriggers(): boolean;
  36881. /**
  36882. * Does exist one action manager with at least one pick trigger
  36883. **/
  36884. static get HasPickTriggers(): boolean;
  36885. /**
  36886. * Does exist one action manager that handles actions of a given trigger
  36887. * @param trigger defines the trigger to be tested
  36888. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36889. **/
  36890. static HasSpecificTrigger(trigger: number): boolean;
  36891. }
  36892. }
  36893. declare module BABYLON {
  36894. /**
  36895. * Defines how a node can be built from a string name.
  36896. */
  36897. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36898. /**
  36899. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36900. */
  36901. export class Node implements IBehaviorAware<Node> {
  36902. /** @hidden */
  36903. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36904. private static _NodeConstructors;
  36905. /**
  36906. * Add a new node constructor
  36907. * @param type defines the type name of the node to construct
  36908. * @param constructorFunc defines the constructor function
  36909. */
  36910. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36911. /**
  36912. * Returns a node constructor based on type name
  36913. * @param type defines the type name
  36914. * @param name defines the new node name
  36915. * @param scene defines the hosting scene
  36916. * @param options defines optional options to transmit to constructors
  36917. * @returns the new constructor or null
  36918. */
  36919. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36920. /**
  36921. * Gets or sets the name of the node
  36922. */
  36923. name: string;
  36924. /**
  36925. * Gets or sets the id of the node
  36926. */
  36927. id: string;
  36928. /**
  36929. * Gets or sets the unique id of the node
  36930. */
  36931. uniqueId: number;
  36932. /**
  36933. * Gets or sets a string used to store user defined state for the node
  36934. */
  36935. state: string;
  36936. /**
  36937. * Gets or sets an object used to store user defined information for the node
  36938. */
  36939. metadata: any;
  36940. /**
  36941. * For internal use only. Please do not use.
  36942. */
  36943. reservedDataStore: any;
  36944. /**
  36945. * List of inspectable custom properties (used by the Inspector)
  36946. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36947. */
  36948. inspectableCustomProperties: IInspectable[];
  36949. private _doNotSerialize;
  36950. /**
  36951. * Gets or sets a boolean used to define if the node must be serialized
  36952. */
  36953. get doNotSerialize(): boolean;
  36954. set doNotSerialize(value: boolean);
  36955. /** @hidden */
  36956. _isDisposed: boolean;
  36957. /**
  36958. * Gets a list of Animations associated with the node
  36959. */
  36960. animations: Animation[];
  36961. protected _ranges: {
  36962. [name: string]: Nullable<AnimationRange>;
  36963. };
  36964. /**
  36965. * Callback raised when the node is ready to be used
  36966. */
  36967. onReady: Nullable<(node: Node) => void>;
  36968. private _isEnabled;
  36969. private _isParentEnabled;
  36970. private _isReady;
  36971. /** @hidden */
  36972. _currentRenderId: number;
  36973. private _parentUpdateId;
  36974. /** @hidden */
  36975. _childUpdateId: number;
  36976. /** @hidden */
  36977. _waitingParentId: Nullable<string>;
  36978. /** @hidden */
  36979. _scene: Scene;
  36980. /** @hidden */
  36981. _cache: any;
  36982. private _parentNode;
  36983. private _children;
  36984. /** @hidden */
  36985. _worldMatrix: Matrix;
  36986. /** @hidden */
  36987. _worldMatrixDeterminant: number;
  36988. /** @hidden */
  36989. _worldMatrixDeterminantIsDirty: boolean;
  36990. /** @hidden */
  36991. private _sceneRootNodesIndex;
  36992. /**
  36993. * Gets a boolean indicating if the node has been disposed
  36994. * @returns true if the node was disposed
  36995. */
  36996. isDisposed(): boolean;
  36997. /**
  36998. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36999. * @see https://doc.babylonjs.com/how_to/parenting
  37000. */
  37001. set parent(parent: Nullable<Node>);
  37002. get parent(): Nullable<Node>;
  37003. /** @hidden */
  37004. _addToSceneRootNodes(): void;
  37005. /** @hidden */
  37006. _removeFromSceneRootNodes(): void;
  37007. private _animationPropertiesOverride;
  37008. /**
  37009. * Gets or sets the animation properties override
  37010. */
  37011. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37012. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37013. /**
  37014. * Gets a string identifying the name of the class
  37015. * @returns "Node" string
  37016. */
  37017. getClassName(): string;
  37018. /** @hidden */
  37019. readonly _isNode: boolean;
  37020. /**
  37021. * An event triggered when the mesh is disposed
  37022. */
  37023. onDisposeObservable: Observable<Node>;
  37024. private _onDisposeObserver;
  37025. /**
  37026. * Sets a callback that will be raised when the node will be disposed
  37027. */
  37028. set onDispose(callback: () => void);
  37029. /**
  37030. * Creates a new Node
  37031. * @param name the name and id to be given to this node
  37032. * @param scene the scene this node will be added to
  37033. */
  37034. constructor(name: string, scene?: Nullable<Scene>);
  37035. /**
  37036. * Gets the scene of the node
  37037. * @returns a scene
  37038. */
  37039. getScene(): Scene;
  37040. /**
  37041. * Gets the engine of the node
  37042. * @returns a Engine
  37043. */
  37044. getEngine(): Engine;
  37045. private _behaviors;
  37046. /**
  37047. * Attach a behavior to the node
  37048. * @see https://doc.babylonjs.com/features/behaviour
  37049. * @param behavior defines the behavior to attach
  37050. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37051. * @returns the current Node
  37052. */
  37053. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37054. /**
  37055. * Remove an attached behavior
  37056. * @see https://doc.babylonjs.com/features/behaviour
  37057. * @param behavior defines the behavior to attach
  37058. * @returns the current Node
  37059. */
  37060. removeBehavior(behavior: Behavior<Node>): Node;
  37061. /**
  37062. * Gets the list of attached behaviors
  37063. * @see https://doc.babylonjs.com/features/behaviour
  37064. */
  37065. get behaviors(): Behavior<Node>[];
  37066. /**
  37067. * Gets an attached behavior by name
  37068. * @param name defines the name of the behavior to look for
  37069. * @see https://doc.babylonjs.com/features/behaviour
  37070. * @returns null if behavior was not found else the requested behavior
  37071. */
  37072. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37073. /**
  37074. * Returns the latest update of the World matrix
  37075. * @returns a Matrix
  37076. */
  37077. getWorldMatrix(): Matrix;
  37078. /** @hidden */
  37079. _getWorldMatrixDeterminant(): number;
  37080. /**
  37081. * Returns directly the latest state of the mesh World matrix.
  37082. * A Matrix is returned.
  37083. */
  37084. get worldMatrixFromCache(): Matrix;
  37085. /** @hidden */
  37086. _initCache(): void;
  37087. /** @hidden */
  37088. updateCache(force?: boolean): void;
  37089. /** @hidden */
  37090. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37091. /** @hidden */
  37092. _updateCache(ignoreParentClass?: boolean): void;
  37093. /** @hidden */
  37094. _isSynchronized(): boolean;
  37095. /** @hidden */
  37096. _markSyncedWithParent(): void;
  37097. /** @hidden */
  37098. isSynchronizedWithParent(): boolean;
  37099. /** @hidden */
  37100. isSynchronized(): boolean;
  37101. /**
  37102. * Is this node ready to be used/rendered
  37103. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37104. * @return true if the node is ready
  37105. */
  37106. isReady(completeCheck?: boolean): boolean;
  37107. /**
  37108. * Is this node enabled?
  37109. * 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
  37110. * @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
  37111. * @return whether this node (and its parent) is enabled
  37112. */
  37113. isEnabled(checkAncestors?: boolean): boolean;
  37114. /** @hidden */
  37115. protected _syncParentEnabledState(): void;
  37116. /**
  37117. * Set the enabled state of this node
  37118. * @param value defines the new enabled state
  37119. */
  37120. setEnabled(value: boolean): void;
  37121. /**
  37122. * Is this node a descendant of the given node?
  37123. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37124. * @param ancestor defines the parent node to inspect
  37125. * @returns a boolean indicating if this node is a descendant of the given node
  37126. */
  37127. isDescendantOf(ancestor: Node): boolean;
  37128. /** @hidden */
  37129. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37130. /**
  37131. * Will return all nodes that have this node as ascendant
  37132. * @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
  37133. * @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
  37134. * @return all children nodes of all types
  37135. */
  37136. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37137. /**
  37138. * Get all child-meshes of this node
  37139. * @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)
  37140. * @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
  37141. * @returns an array of AbstractMesh
  37142. */
  37143. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37144. /**
  37145. * Get all direct children of this node
  37146. * @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
  37147. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  37148. * @returns an array of Node
  37149. */
  37150. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37151. /** @hidden */
  37152. _setReady(state: boolean): void;
  37153. /**
  37154. * Get an animation by name
  37155. * @param name defines the name of the animation to look for
  37156. * @returns null if not found else the requested animation
  37157. */
  37158. getAnimationByName(name: string): Nullable<Animation>;
  37159. /**
  37160. * Creates an animation range for this node
  37161. * @param name defines the name of the range
  37162. * @param from defines the starting key
  37163. * @param to defines the end key
  37164. */
  37165. createAnimationRange(name: string, from: number, to: number): void;
  37166. /**
  37167. * Delete a specific animation range
  37168. * @param name defines the name of the range to delete
  37169. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37170. */
  37171. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37172. /**
  37173. * Get an animation range by name
  37174. * @param name defines the name of the animation range to look for
  37175. * @returns null if not found else the requested animation range
  37176. */
  37177. getAnimationRange(name: string): Nullable<AnimationRange>;
  37178. /**
  37179. * Gets the list of all animation ranges defined on this node
  37180. * @returns an array
  37181. */
  37182. getAnimationRanges(): Nullable<AnimationRange>[];
  37183. /**
  37184. * Will start the animation sequence
  37185. * @param name defines the range frames for animation sequence
  37186. * @param loop defines if the animation should loop (false by default)
  37187. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37188. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37189. * @returns the object created for this animation. If range does not exist, it will return null
  37190. */
  37191. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37192. /**
  37193. * Serialize animation ranges into a JSON compatible object
  37194. * @returns serialization object
  37195. */
  37196. serializeAnimationRanges(): any;
  37197. /**
  37198. * Computes the world matrix of the node
  37199. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37200. * @returns the world matrix
  37201. */
  37202. computeWorldMatrix(force?: boolean): Matrix;
  37203. /**
  37204. * Releases resources associated with this node.
  37205. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37206. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37207. */
  37208. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37209. /**
  37210. * Parse animation range data from a serialization object and store them into a given node
  37211. * @param node defines where to store the animation ranges
  37212. * @param parsedNode defines the serialization object to read data from
  37213. * @param scene defines the hosting scene
  37214. */
  37215. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37216. /**
  37217. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37218. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37219. * @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
  37220. * @returns the new bounding vectors
  37221. */
  37222. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37223. min: Vector3;
  37224. max: Vector3;
  37225. };
  37226. }
  37227. }
  37228. declare module BABYLON {
  37229. /**
  37230. * @hidden
  37231. */
  37232. export class _IAnimationState {
  37233. key: number;
  37234. repeatCount: number;
  37235. workValue?: any;
  37236. loopMode?: number;
  37237. offsetValue?: any;
  37238. highLimitValue?: any;
  37239. }
  37240. /**
  37241. * Class used to store any kind of animation
  37242. */
  37243. export class Animation {
  37244. /**Name of the animation */
  37245. name: string;
  37246. /**Property to animate */
  37247. targetProperty: string;
  37248. /**The frames per second of the animation */
  37249. framePerSecond: number;
  37250. /**The data type of the animation */
  37251. dataType: number;
  37252. /**The loop mode of the animation */
  37253. loopMode?: number | undefined;
  37254. /**Specifies if blending should be enabled */
  37255. enableBlending?: boolean | undefined;
  37256. /**
  37257. * Use matrix interpolation instead of using direct key value when animating matrices
  37258. */
  37259. static AllowMatricesInterpolation: boolean;
  37260. /**
  37261. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37262. */
  37263. static AllowMatrixDecomposeForInterpolation: boolean;
  37264. /** Define the Url to load snippets */
  37265. static SnippetUrl: string;
  37266. /** Snippet ID if the animation was created from the snippet server */
  37267. snippetId: string;
  37268. /**
  37269. * Stores the key frames of the animation
  37270. */
  37271. private _keys;
  37272. /**
  37273. * Stores the easing function of the animation
  37274. */
  37275. private _easingFunction;
  37276. /**
  37277. * @hidden Internal use only
  37278. */
  37279. _runtimeAnimations: RuntimeAnimation[];
  37280. /**
  37281. * The set of event that will be linked to this animation
  37282. */
  37283. private _events;
  37284. /**
  37285. * Stores an array of target property paths
  37286. */
  37287. targetPropertyPath: string[];
  37288. /**
  37289. * Stores the blending speed of the animation
  37290. */
  37291. blendingSpeed: number;
  37292. /**
  37293. * Stores the animation ranges for the animation
  37294. */
  37295. private _ranges;
  37296. /**
  37297. * @hidden Internal use
  37298. */
  37299. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37300. /**
  37301. * Sets up an animation
  37302. * @param property The property to animate
  37303. * @param animationType The animation type to apply
  37304. * @param framePerSecond The frames per second of the animation
  37305. * @param easingFunction The easing function used in the animation
  37306. * @returns The created animation
  37307. */
  37308. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37309. /**
  37310. * Create and start an animation on a node
  37311. * @param name defines the name of the global animation that will be run on all nodes
  37312. * @param node defines the root node where the animation will take place
  37313. * @param targetProperty defines property to animate
  37314. * @param framePerSecond defines the number of frame per second yo use
  37315. * @param totalFrame defines the number of frames in total
  37316. * @param from defines the initial value
  37317. * @param to defines the final value
  37318. * @param loopMode defines which loop mode you want to use (off by default)
  37319. * @param easingFunction defines the easing function to use (linear by default)
  37320. * @param onAnimationEnd defines the callback to call when animation end
  37321. * @returns the animatable created for this animation
  37322. */
  37323. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37324. /**
  37325. * Create and start an animation on a node and its descendants
  37326. * @param name defines the name of the global animation that will be run on all nodes
  37327. * @param node defines the root node where the animation will take place
  37328. * @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
  37329. * @param targetProperty defines property to animate
  37330. * @param framePerSecond defines the number of frame per second to use
  37331. * @param totalFrame defines the number of frames in total
  37332. * @param from defines the initial value
  37333. * @param to defines the final value
  37334. * @param loopMode defines which loop mode you want to use (off by default)
  37335. * @param easingFunction defines the easing function to use (linear by default)
  37336. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37337. * @returns the list of animatables created for all nodes
  37338. * @example https://www.babylonjs-playground.com/#MH0VLI
  37339. */
  37340. 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[]>;
  37341. /**
  37342. * Creates a new animation, merges it with the existing animations and starts it
  37343. * @param name Name of the animation
  37344. * @param node Node which contains the scene that begins the animations
  37345. * @param targetProperty Specifies which property to animate
  37346. * @param framePerSecond The frames per second of the animation
  37347. * @param totalFrame The total number of frames
  37348. * @param from The frame at the beginning of the animation
  37349. * @param to The frame at the end of the animation
  37350. * @param loopMode Specifies the loop mode of the animation
  37351. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37352. * @param onAnimationEnd Callback to run once the animation is complete
  37353. * @returns Nullable animation
  37354. */
  37355. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37356. /**
  37357. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37358. * @param sourceAnimation defines the Animation containing keyframes to convert
  37359. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37360. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37361. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37362. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37363. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37364. */
  37365. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37366. /**
  37367. * Transition property of an host to the target Value
  37368. * @param property The property to transition
  37369. * @param targetValue The target Value of the property
  37370. * @param host The object where the property to animate belongs
  37371. * @param scene Scene used to run the animation
  37372. * @param frameRate Framerate (in frame/s) to use
  37373. * @param transition The transition type we want to use
  37374. * @param duration The duration of the animation, in milliseconds
  37375. * @param onAnimationEnd Callback trigger at the end of the animation
  37376. * @returns Nullable animation
  37377. */
  37378. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37379. /**
  37380. * Return the array of runtime animations currently using this animation
  37381. */
  37382. get runtimeAnimations(): RuntimeAnimation[];
  37383. /**
  37384. * Specifies if any of the runtime animations are currently running
  37385. */
  37386. get hasRunningRuntimeAnimations(): boolean;
  37387. /**
  37388. * Initializes the animation
  37389. * @param name Name of the animation
  37390. * @param targetProperty Property to animate
  37391. * @param framePerSecond The frames per second of the animation
  37392. * @param dataType The data type of the animation
  37393. * @param loopMode The loop mode of the animation
  37394. * @param enableBlending Specifies if blending should be enabled
  37395. */
  37396. constructor(
  37397. /**Name of the animation */
  37398. name: string,
  37399. /**Property to animate */
  37400. targetProperty: string,
  37401. /**The frames per second of the animation */
  37402. framePerSecond: number,
  37403. /**The data type of the animation */
  37404. dataType: number,
  37405. /**The loop mode of the animation */
  37406. loopMode?: number | undefined,
  37407. /**Specifies if blending should be enabled */
  37408. enableBlending?: boolean | undefined);
  37409. /**
  37410. * Converts the animation to a string
  37411. * @param fullDetails support for multiple levels of logging within scene loading
  37412. * @returns String form of the animation
  37413. */
  37414. toString(fullDetails?: boolean): string;
  37415. /**
  37416. * Add an event to this animation
  37417. * @param event Event to add
  37418. */
  37419. addEvent(event: AnimationEvent): void;
  37420. /**
  37421. * Remove all events found at the given frame
  37422. * @param frame The frame to remove events from
  37423. */
  37424. removeEvents(frame: number): void;
  37425. /**
  37426. * Retrieves all the events from the animation
  37427. * @returns Events from the animation
  37428. */
  37429. getEvents(): AnimationEvent[];
  37430. /**
  37431. * Creates an animation range
  37432. * @param name Name of the animation range
  37433. * @param from Starting frame of the animation range
  37434. * @param to Ending frame of the animation
  37435. */
  37436. createRange(name: string, from: number, to: number): void;
  37437. /**
  37438. * Deletes an animation range by name
  37439. * @param name Name of the animation range to delete
  37440. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37441. */
  37442. deleteRange(name: string, deleteFrames?: boolean): void;
  37443. /**
  37444. * Gets the animation range by name, or null if not defined
  37445. * @param name Name of the animation range
  37446. * @returns Nullable animation range
  37447. */
  37448. getRange(name: string): Nullable<AnimationRange>;
  37449. /**
  37450. * Gets the key frames from the animation
  37451. * @returns The key frames of the animation
  37452. */
  37453. getKeys(): Array<IAnimationKey>;
  37454. /**
  37455. * Gets the highest frame rate of the animation
  37456. * @returns Highest frame rate of the animation
  37457. */
  37458. getHighestFrame(): number;
  37459. /**
  37460. * Gets the easing function of the animation
  37461. * @returns Easing function of the animation
  37462. */
  37463. getEasingFunction(): IEasingFunction;
  37464. /**
  37465. * Sets the easing function of the animation
  37466. * @param easingFunction A custom mathematical formula for animation
  37467. */
  37468. setEasingFunction(easingFunction: EasingFunction): void;
  37469. /**
  37470. * Interpolates a scalar linearly
  37471. * @param startValue Start value of the animation curve
  37472. * @param endValue End value of the animation curve
  37473. * @param gradient Scalar amount to interpolate
  37474. * @returns Interpolated scalar value
  37475. */
  37476. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37477. /**
  37478. * Interpolates a scalar cubically
  37479. * @param startValue Start value of the animation curve
  37480. * @param outTangent End tangent of the animation
  37481. * @param endValue End value of the animation curve
  37482. * @param inTangent Start tangent of the animation curve
  37483. * @param gradient Scalar amount to interpolate
  37484. * @returns Interpolated scalar value
  37485. */
  37486. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37487. /**
  37488. * Interpolates a quaternion using a spherical linear interpolation
  37489. * @param startValue Start value of the animation curve
  37490. * @param endValue End value of the animation curve
  37491. * @param gradient Scalar amount to interpolate
  37492. * @returns Interpolated quaternion value
  37493. */
  37494. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37495. /**
  37496. * Interpolates a quaternion cubically
  37497. * @param startValue Start value of the animation curve
  37498. * @param outTangent End tangent of the animation curve
  37499. * @param endValue End value of the animation curve
  37500. * @param inTangent Start tangent of the animation curve
  37501. * @param gradient Scalar amount to interpolate
  37502. * @returns Interpolated quaternion value
  37503. */
  37504. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37505. /**
  37506. * Interpolates a Vector3 linearl
  37507. * @param startValue Start value of the animation curve
  37508. * @param endValue End value of the animation curve
  37509. * @param gradient Scalar amount to interpolate
  37510. * @returns Interpolated scalar value
  37511. */
  37512. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37513. /**
  37514. * Interpolates a Vector3 cubically
  37515. * @param startValue Start value of the animation curve
  37516. * @param outTangent End tangent of the animation
  37517. * @param endValue End value of the animation curve
  37518. * @param inTangent Start tangent of the animation curve
  37519. * @param gradient Scalar amount to interpolate
  37520. * @returns InterpolatedVector3 value
  37521. */
  37522. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37523. /**
  37524. * Interpolates a Vector2 linearly
  37525. * @param startValue Start value of the animation curve
  37526. * @param endValue End value of the animation curve
  37527. * @param gradient Scalar amount to interpolate
  37528. * @returns Interpolated Vector2 value
  37529. */
  37530. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37531. /**
  37532. * Interpolates a Vector2 cubically
  37533. * @param startValue Start value of the animation curve
  37534. * @param outTangent End tangent of the animation
  37535. * @param endValue End value of the animation curve
  37536. * @param inTangent Start tangent of the animation curve
  37537. * @param gradient Scalar amount to interpolate
  37538. * @returns Interpolated Vector2 value
  37539. */
  37540. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37541. /**
  37542. * Interpolates a size linearly
  37543. * @param startValue Start value of the animation curve
  37544. * @param endValue End value of the animation curve
  37545. * @param gradient Scalar amount to interpolate
  37546. * @returns Interpolated Size value
  37547. */
  37548. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37549. /**
  37550. * Interpolates a Color3 linearly
  37551. * @param startValue Start value of the animation curve
  37552. * @param endValue End value of the animation curve
  37553. * @param gradient Scalar amount to interpolate
  37554. * @returns Interpolated Color3 value
  37555. */
  37556. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37557. /**
  37558. * Interpolates a Color4 linearly
  37559. * @param startValue Start value of the animation curve
  37560. * @param endValue End value of the animation curve
  37561. * @param gradient Scalar amount to interpolate
  37562. * @returns Interpolated Color3 value
  37563. */
  37564. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37565. /**
  37566. * @hidden Internal use only
  37567. */
  37568. _getKeyValue(value: any): any;
  37569. /**
  37570. * @hidden Internal use only
  37571. */
  37572. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37573. /**
  37574. * Defines the function to use to interpolate matrices
  37575. * @param startValue defines the start matrix
  37576. * @param endValue defines the end matrix
  37577. * @param gradient defines the gradient between both matrices
  37578. * @param result defines an optional target matrix where to store the interpolation
  37579. * @returns the interpolated matrix
  37580. */
  37581. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37582. /**
  37583. * Makes a copy of the animation
  37584. * @returns Cloned animation
  37585. */
  37586. clone(): Animation;
  37587. /**
  37588. * Sets the key frames of the animation
  37589. * @param values The animation key frames to set
  37590. */
  37591. setKeys(values: Array<IAnimationKey>): void;
  37592. /**
  37593. * Serializes the animation to an object
  37594. * @returns Serialized object
  37595. */
  37596. serialize(): any;
  37597. /**
  37598. * Float animation type
  37599. */
  37600. static readonly ANIMATIONTYPE_FLOAT: number;
  37601. /**
  37602. * Vector3 animation type
  37603. */
  37604. static readonly ANIMATIONTYPE_VECTOR3: number;
  37605. /**
  37606. * Quaternion animation type
  37607. */
  37608. static readonly ANIMATIONTYPE_QUATERNION: number;
  37609. /**
  37610. * Matrix animation type
  37611. */
  37612. static readonly ANIMATIONTYPE_MATRIX: number;
  37613. /**
  37614. * Color3 animation type
  37615. */
  37616. static readonly ANIMATIONTYPE_COLOR3: number;
  37617. /**
  37618. * Color3 animation type
  37619. */
  37620. static readonly ANIMATIONTYPE_COLOR4: number;
  37621. /**
  37622. * Vector2 animation type
  37623. */
  37624. static readonly ANIMATIONTYPE_VECTOR2: number;
  37625. /**
  37626. * Size animation type
  37627. */
  37628. static readonly ANIMATIONTYPE_SIZE: number;
  37629. /**
  37630. * Relative Loop Mode
  37631. */
  37632. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37633. /**
  37634. * Cycle Loop Mode
  37635. */
  37636. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37637. /**
  37638. * Constant Loop Mode
  37639. */
  37640. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37641. /** @hidden */
  37642. static _UniversalLerp(left: any, right: any, amount: number): any;
  37643. /**
  37644. * Parses an animation object and creates an animation
  37645. * @param parsedAnimation Parsed animation object
  37646. * @returns Animation object
  37647. */
  37648. static Parse(parsedAnimation: any): Animation;
  37649. /**
  37650. * Appends the serialized animations from the source animations
  37651. * @param source Source containing the animations
  37652. * @param destination Target to store the animations
  37653. */
  37654. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37655. /**
  37656. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37657. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37658. * @param url defines the url to load from
  37659. * @returns a promise that will resolve to the new animation or an array of animations
  37660. */
  37661. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37662. /**
  37663. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37664. * @param snippetId defines the snippet to load
  37665. * @returns a promise that will resolve to the new animation or a new array of animations
  37666. */
  37667. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37668. }
  37669. }
  37670. declare module BABYLON {
  37671. /**
  37672. * Interface containing an array of animations
  37673. */
  37674. export interface IAnimatable {
  37675. /**
  37676. * Array of animations
  37677. */
  37678. animations: Nullable<Array<Animation>>;
  37679. }
  37680. }
  37681. declare module BABYLON {
  37682. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37683. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37684. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37685. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37686. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37687. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37688. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37689. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37690. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37691. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37692. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37693. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37694. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37695. /**
  37696. * Decorator used to define property that can be serialized as reference to a camera
  37697. * @param sourceName defines the name of the property to decorate
  37698. */
  37699. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37700. /**
  37701. * Class used to help serialization objects
  37702. */
  37703. export class SerializationHelper {
  37704. /** @hidden */
  37705. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37706. /** @hidden */
  37707. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37708. /** @hidden */
  37709. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37710. /** @hidden */
  37711. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37712. /**
  37713. * Appends the serialized animations from the source animations
  37714. * @param source Source containing the animations
  37715. * @param destination Target to store the animations
  37716. */
  37717. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37718. /**
  37719. * Static function used to serialized a specific entity
  37720. * @param entity defines the entity to serialize
  37721. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37722. * @returns a JSON compatible object representing the serialization of the entity
  37723. */
  37724. static Serialize<T>(entity: T, serializationObject?: any): any;
  37725. /**
  37726. * Creates a new entity from a serialization data object
  37727. * @param creationFunction defines a function used to instanciated the new entity
  37728. * @param source defines the source serialization data
  37729. * @param scene defines the hosting scene
  37730. * @param rootUrl defines the root url for resources
  37731. * @returns a new entity
  37732. */
  37733. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37734. /**
  37735. * Clones an object
  37736. * @param creationFunction defines the function used to instanciate the new object
  37737. * @param source defines the source object
  37738. * @returns the cloned object
  37739. */
  37740. static Clone<T>(creationFunction: () => T, source: T): T;
  37741. /**
  37742. * Instanciates a new object based on a source one (some data will be shared between both object)
  37743. * @param creationFunction defines the function used to instanciate the new object
  37744. * @param source defines the source object
  37745. * @returns the new object
  37746. */
  37747. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37748. }
  37749. }
  37750. declare module BABYLON {
  37751. /**
  37752. * This is the base class of all the camera used in the application.
  37753. * @see https://doc.babylonjs.com/features/cameras
  37754. */
  37755. export class Camera extends Node {
  37756. /** @hidden */
  37757. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  37758. /**
  37759. * This is the default projection mode used by the cameras.
  37760. * It helps recreating a feeling of perspective and better appreciate depth.
  37761. * This is the best way to simulate real life cameras.
  37762. */
  37763. static readonly PERSPECTIVE_CAMERA: number;
  37764. /**
  37765. * This helps creating camera with an orthographic mode.
  37766. * 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.
  37767. */
  37768. static readonly ORTHOGRAPHIC_CAMERA: number;
  37769. /**
  37770. * This is the default FOV mode for perspective cameras.
  37771. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37772. */
  37773. static readonly FOVMODE_VERTICAL_FIXED: number;
  37774. /**
  37775. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37776. */
  37777. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37778. /**
  37779. * This specifies ther is no need for a camera rig.
  37780. * Basically only one eye is rendered corresponding to the camera.
  37781. */
  37782. static readonly RIG_MODE_NONE: number;
  37783. /**
  37784. * Simulates a camera Rig with one blue eye and one red eye.
  37785. * This can be use with 3d blue and red glasses.
  37786. */
  37787. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37788. /**
  37789. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37790. */
  37791. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37792. /**
  37793. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37794. */
  37795. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37796. /**
  37797. * Defines that both eyes of the camera will be rendered over under each other.
  37798. */
  37799. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37800. /**
  37801. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37802. */
  37803. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37804. /**
  37805. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37806. */
  37807. static readonly RIG_MODE_VR: number;
  37808. /**
  37809. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37810. */
  37811. static readonly RIG_MODE_WEBVR: number;
  37812. /**
  37813. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37814. */
  37815. static readonly RIG_MODE_CUSTOM: number;
  37816. /**
  37817. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37818. */
  37819. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37820. /**
  37821. * Define the input manager associated with the camera.
  37822. */
  37823. inputs: CameraInputsManager<Camera>;
  37824. /** @hidden */
  37825. _position: Vector3;
  37826. /**
  37827. * Define the current local position of the camera in the scene
  37828. */
  37829. get position(): Vector3;
  37830. set position(newPosition: Vector3);
  37831. protected _upVector: Vector3;
  37832. /**
  37833. * The vector the camera should consider as up.
  37834. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37835. */
  37836. set upVector(vec: Vector3);
  37837. get upVector(): Vector3;
  37838. /**
  37839. * Define the current limit on the left side for an orthographic camera
  37840. * In scene unit
  37841. */
  37842. orthoLeft: Nullable<number>;
  37843. /**
  37844. * Define the current limit on the right side for an orthographic camera
  37845. * In scene unit
  37846. */
  37847. orthoRight: Nullable<number>;
  37848. /**
  37849. * Define the current limit on the bottom side for an orthographic camera
  37850. * In scene unit
  37851. */
  37852. orthoBottom: Nullable<number>;
  37853. /**
  37854. * Define the current limit on the top side for an orthographic camera
  37855. * In scene unit
  37856. */
  37857. orthoTop: Nullable<number>;
  37858. /**
  37859. * Field Of View is set in Radians. (default is 0.8)
  37860. */
  37861. fov: number;
  37862. /**
  37863. * Define the minimum distance the camera can see from.
  37864. * This is important to note that the depth buffer are not infinite and the closer it starts
  37865. * the more your scene might encounter depth fighting issue.
  37866. */
  37867. minZ: number;
  37868. /**
  37869. * Define the maximum distance the camera can see to.
  37870. * This is important to note that the depth buffer are not infinite and the further it end
  37871. * the more your scene might encounter depth fighting issue.
  37872. */
  37873. maxZ: number;
  37874. /**
  37875. * Define the default inertia of the camera.
  37876. * This helps giving a smooth feeling to the camera movement.
  37877. */
  37878. inertia: number;
  37879. /**
  37880. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37881. */
  37882. mode: number;
  37883. /**
  37884. * Define whether the camera is intermediate.
  37885. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37886. */
  37887. isIntermediate: boolean;
  37888. /**
  37889. * Define the viewport of the camera.
  37890. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37891. */
  37892. viewport: Viewport;
  37893. /**
  37894. * Restricts the camera to viewing objects with the same layerMask.
  37895. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37896. */
  37897. layerMask: number;
  37898. /**
  37899. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37900. */
  37901. fovMode: number;
  37902. /**
  37903. * Rig mode of the camera.
  37904. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37905. * This is normally controlled byt the camera themselves as internal use.
  37906. */
  37907. cameraRigMode: number;
  37908. /**
  37909. * Defines the distance between both "eyes" in case of a RIG
  37910. */
  37911. interaxialDistance: number;
  37912. /**
  37913. * Defines if stereoscopic rendering is done side by side or over under.
  37914. */
  37915. isStereoscopicSideBySide: boolean;
  37916. /**
  37917. * 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
  37918. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37919. * else in the scene. (Eg. security camera)
  37920. *
  37921. * 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)
  37922. */
  37923. customRenderTargets: RenderTargetTexture[];
  37924. /**
  37925. * When set, the camera will render to this render target instead of the default canvas
  37926. *
  37927. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37928. */
  37929. outputRenderTarget: Nullable<RenderTargetTexture>;
  37930. /**
  37931. * Observable triggered when the camera view matrix has changed.
  37932. */
  37933. onViewMatrixChangedObservable: Observable<Camera>;
  37934. /**
  37935. * Observable triggered when the camera Projection matrix has changed.
  37936. */
  37937. onProjectionMatrixChangedObservable: Observable<Camera>;
  37938. /**
  37939. * Observable triggered when the inputs have been processed.
  37940. */
  37941. onAfterCheckInputsObservable: Observable<Camera>;
  37942. /**
  37943. * Observable triggered when reset has been called and applied to the camera.
  37944. */
  37945. onRestoreStateObservable: Observable<Camera>;
  37946. /**
  37947. * Is this camera a part of a rig system?
  37948. */
  37949. isRigCamera: boolean;
  37950. /**
  37951. * If isRigCamera set to true this will be set with the parent camera.
  37952. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37953. */
  37954. rigParent?: Camera;
  37955. /** @hidden */
  37956. _cameraRigParams: any;
  37957. /** @hidden */
  37958. _rigCameras: Camera[];
  37959. /** @hidden */
  37960. _rigPostProcess: Nullable<PostProcess>;
  37961. protected _webvrViewMatrix: Matrix;
  37962. /** @hidden */
  37963. _skipRendering: boolean;
  37964. /** @hidden */
  37965. _projectionMatrix: Matrix;
  37966. /** @hidden */
  37967. _postProcesses: Nullable<PostProcess>[];
  37968. /** @hidden */
  37969. _activeMeshes: SmartArray<AbstractMesh>;
  37970. protected _globalPosition: Vector3;
  37971. /** @hidden */
  37972. _computedViewMatrix: Matrix;
  37973. private _doNotComputeProjectionMatrix;
  37974. private _transformMatrix;
  37975. private _frustumPlanes;
  37976. private _refreshFrustumPlanes;
  37977. private _storedFov;
  37978. private _stateStored;
  37979. /**
  37980. * Instantiates a new camera object.
  37981. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37982. * @see https://doc.babylonjs.com/features/cameras
  37983. * @param name Defines the name of the camera in the scene
  37984. * @param position Defines the position of the camera
  37985. * @param scene Defines the scene the camera belongs too
  37986. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  37987. */
  37988. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37989. /**
  37990. * Store current camera state (fov, position, etc..)
  37991. * @returns the camera
  37992. */
  37993. storeState(): Camera;
  37994. /**
  37995. * Restores the camera state values if it has been stored. You must call storeState() first
  37996. */
  37997. protected _restoreStateValues(): boolean;
  37998. /**
  37999. * Restored camera state. You must call storeState() first.
  38000. * @returns true if restored and false otherwise
  38001. */
  38002. restoreState(): boolean;
  38003. /**
  38004. * Gets the class name of the camera.
  38005. * @returns the class name
  38006. */
  38007. getClassName(): string;
  38008. /** @hidden */
  38009. readonly _isCamera: boolean;
  38010. /**
  38011. * Gets a string representation of the camera useful for debug purpose.
  38012. * @param fullDetails Defines that a more verboe level of logging is required
  38013. * @returns the string representation
  38014. */
  38015. toString(fullDetails?: boolean): string;
  38016. /**
  38017. * Gets the current world space position of the camera.
  38018. */
  38019. get globalPosition(): Vector3;
  38020. /**
  38021. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38022. * @returns the active meshe list
  38023. */
  38024. getActiveMeshes(): SmartArray<AbstractMesh>;
  38025. /**
  38026. * Check whether a mesh is part of the current active mesh list of the camera
  38027. * @param mesh Defines the mesh to check
  38028. * @returns true if active, false otherwise
  38029. */
  38030. isActiveMesh(mesh: Mesh): boolean;
  38031. /**
  38032. * Is this camera ready to be used/rendered
  38033. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38034. * @return true if the camera is ready
  38035. */
  38036. isReady(completeCheck?: boolean): boolean;
  38037. /** @hidden */
  38038. _initCache(): void;
  38039. /** @hidden */
  38040. _updateCache(ignoreParentClass?: boolean): void;
  38041. /** @hidden */
  38042. _isSynchronized(): boolean;
  38043. /** @hidden */
  38044. _isSynchronizedViewMatrix(): boolean;
  38045. /** @hidden */
  38046. _isSynchronizedProjectionMatrix(): boolean;
  38047. /**
  38048. * Attach the input controls to a specific dom element to get the input from.
  38049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38050. */
  38051. attachControl(noPreventDefault?: boolean): void;
  38052. /**
  38053. * Attach the input controls to a specific dom element to get the input from.
  38054. * @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
  38055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38056. * BACK COMPAT SIGNATURE ONLY.
  38057. */
  38058. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38059. /**
  38060. * Detach the current controls from the specified dom element.
  38061. */
  38062. detachControl(): void;
  38063. /**
  38064. * Detach the current controls from the specified dom element.
  38065. * @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
  38066. */
  38067. detachControl(ignored: any): void;
  38068. /**
  38069. * Update the camera state according to the different inputs gathered during the frame.
  38070. */
  38071. update(): void;
  38072. /** @hidden */
  38073. _checkInputs(): void;
  38074. /** @hidden */
  38075. get rigCameras(): Camera[];
  38076. /**
  38077. * Gets the post process used by the rig cameras
  38078. */
  38079. get rigPostProcess(): Nullable<PostProcess>;
  38080. /**
  38081. * Internal, gets the first post proces.
  38082. * @returns the first post process to be run on this camera.
  38083. */
  38084. _getFirstPostProcess(): Nullable<PostProcess>;
  38085. private _cascadePostProcessesToRigCams;
  38086. /**
  38087. * Attach a post process to the camera.
  38088. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38089. * @param postProcess The post process to attach to the camera
  38090. * @param insertAt The position of the post process in case several of them are in use in the scene
  38091. * @returns the position the post process has been inserted at
  38092. */
  38093. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38094. /**
  38095. * Detach a post process to the camera.
  38096. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38097. * @param postProcess The post process to detach from the camera
  38098. */
  38099. detachPostProcess(postProcess: PostProcess): void;
  38100. /**
  38101. * Gets the current world matrix of the camera
  38102. */
  38103. getWorldMatrix(): Matrix;
  38104. /** @hidden */
  38105. _getViewMatrix(): Matrix;
  38106. /**
  38107. * Gets the current view matrix of the camera.
  38108. * @param force forces the camera to recompute the matrix without looking at the cached state
  38109. * @returns the view matrix
  38110. */
  38111. getViewMatrix(force?: boolean): Matrix;
  38112. /**
  38113. * Freeze the projection matrix.
  38114. * It will prevent the cache check of the camera projection compute and can speed up perf
  38115. * if no parameter of the camera are meant to change
  38116. * @param projection Defines manually a projection if necessary
  38117. */
  38118. freezeProjectionMatrix(projection?: Matrix): void;
  38119. /**
  38120. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38121. */
  38122. unfreezeProjectionMatrix(): void;
  38123. /**
  38124. * Gets the current projection matrix of the camera.
  38125. * @param force forces the camera to recompute the matrix without looking at the cached state
  38126. * @returns the projection matrix
  38127. */
  38128. getProjectionMatrix(force?: boolean): Matrix;
  38129. /**
  38130. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38131. * @returns a Matrix
  38132. */
  38133. getTransformationMatrix(): Matrix;
  38134. private _updateFrustumPlanes;
  38135. /**
  38136. * Checks if a cullable object (mesh...) is in the camera frustum
  38137. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38138. * @param target The object to check
  38139. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38140. * @returns true if the object is in frustum otherwise false
  38141. */
  38142. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38143. /**
  38144. * Checks if a cullable object (mesh...) is in the camera frustum
  38145. * Unlike isInFrustum this cheks the full bounding box
  38146. * @param target The object to check
  38147. * @returns true if the object is in frustum otherwise false
  38148. */
  38149. isCompletelyInFrustum(target: ICullable): boolean;
  38150. /**
  38151. * Gets a ray in the forward direction from the camera.
  38152. * @param length Defines the length of the ray to create
  38153. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38154. * @param origin Defines the start point of the ray which defaults to the camera position
  38155. * @returns the forward ray
  38156. */
  38157. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38158. /**
  38159. * Gets a ray in the forward direction from the camera.
  38160. * @param refRay the ray to (re)use when setting the values
  38161. * @param length Defines the length of the ray to create
  38162. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38163. * @param origin Defines the start point of the ray which defaults to the camera position
  38164. * @returns the forward ray
  38165. */
  38166. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38167. /**
  38168. * Releases resources associated with this node.
  38169. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38170. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38171. */
  38172. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38173. /** @hidden */
  38174. _isLeftCamera: boolean;
  38175. /**
  38176. * Gets the left camera of a rig setup in case of Rigged Camera
  38177. */
  38178. get isLeftCamera(): boolean;
  38179. /** @hidden */
  38180. _isRightCamera: boolean;
  38181. /**
  38182. * Gets the right camera of a rig setup in case of Rigged Camera
  38183. */
  38184. get isRightCamera(): boolean;
  38185. /**
  38186. * Gets the left camera of a rig setup in case of Rigged Camera
  38187. */
  38188. get leftCamera(): Nullable<FreeCamera>;
  38189. /**
  38190. * Gets the right camera of a rig setup in case of Rigged Camera
  38191. */
  38192. get rightCamera(): Nullable<FreeCamera>;
  38193. /**
  38194. * Gets the left camera target of a rig setup in case of Rigged Camera
  38195. * @returns the target position
  38196. */
  38197. getLeftTarget(): Nullable<Vector3>;
  38198. /**
  38199. * Gets the right camera target of a rig setup in case of Rigged Camera
  38200. * @returns the target position
  38201. */
  38202. getRightTarget(): Nullable<Vector3>;
  38203. /**
  38204. * @hidden
  38205. */
  38206. setCameraRigMode(mode: number, rigParams: any): void;
  38207. /** @hidden */
  38208. static _setStereoscopicRigMode(camera: Camera): void;
  38209. /** @hidden */
  38210. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38211. /** @hidden */
  38212. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38213. /** @hidden */
  38214. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38215. /** @hidden */
  38216. _getVRProjectionMatrix(): Matrix;
  38217. protected _updateCameraRotationMatrix(): void;
  38218. protected _updateWebVRCameraRotationMatrix(): void;
  38219. /**
  38220. * This function MUST be overwritten by the different WebVR cameras available.
  38221. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38222. * @hidden
  38223. */
  38224. _getWebVRProjectionMatrix(): Matrix;
  38225. /**
  38226. * This function MUST be overwritten by the different WebVR cameras available.
  38227. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38228. * @hidden
  38229. */
  38230. _getWebVRViewMatrix(): Matrix;
  38231. /** @hidden */
  38232. setCameraRigParameter(name: string, value: any): void;
  38233. /**
  38234. * needs to be overridden by children so sub has required properties to be copied
  38235. * @hidden
  38236. */
  38237. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38238. /**
  38239. * May need to be overridden by children
  38240. * @hidden
  38241. */
  38242. _updateRigCameras(): void;
  38243. /** @hidden */
  38244. _setupInputs(): void;
  38245. /**
  38246. * Serialiaze the camera setup to a json represention
  38247. * @returns the JSON representation
  38248. */
  38249. serialize(): any;
  38250. /**
  38251. * Clones the current camera.
  38252. * @param name The cloned camera name
  38253. * @returns the cloned camera
  38254. */
  38255. clone(name: string): Camera;
  38256. /**
  38257. * Gets the direction of the camera relative to a given local axis.
  38258. * @param localAxis Defines the reference axis to provide a relative direction.
  38259. * @return the direction
  38260. */
  38261. getDirection(localAxis: Vector3): Vector3;
  38262. /**
  38263. * Returns the current camera absolute rotation
  38264. */
  38265. get absoluteRotation(): Quaternion;
  38266. /**
  38267. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38268. * @param localAxis Defines the reference axis to provide a relative direction.
  38269. * @param result Defines the vector to store the result in
  38270. */
  38271. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38272. /**
  38273. * Gets a camera constructor for a given camera type
  38274. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38275. * @param name The name of the camera the result will be able to instantiate
  38276. * @param scene The scene the result will construct the camera in
  38277. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38278. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38279. * @returns a factory method to construc the camera
  38280. */
  38281. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38282. /**
  38283. * Compute the world matrix of the camera.
  38284. * @returns the camera world matrix
  38285. */
  38286. computeWorldMatrix(): Matrix;
  38287. /**
  38288. * Parse a JSON and creates the camera from the parsed information
  38289. * @param parsedCamera The JSON to parse
  38290. * @param scene The scene to instantiate the camera in
  38291. * @returns the newly constructed camera
  38292. */
  38293. static Parse(parsedCamera: any, scene: Scene): Camera;
  38294. }
  38295. }
  38296. declare module BABYLON {
  38297. /**
  38298. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38299. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38300. */
  38301. export class PostProcessManager {
  38302. private _scene;
  38303. private _indexBuffer;
  38304. private _vertexBuffers;
  38305. /**
  38306. * Creates a new instance PostProcess
  38307. * @param scene The scene that the post process is associated with.
  38308. */
  38309. constructor(scene: Scene);
  38310. private _prepareBuffers;
  38311. private _buildIndexBuffer;
  38312. /**
  38313. * Rebuilds the vertex buffers of the manager.
  38314. * @hidden
  38315. */
  38316. _rebuild(): void;
  38317. /**
  38318. * Prepares a frame to be run through a post process.
  38319. * @param sourceTexture The input texture to the post procesess. (default: null)
  38320. * @param postProcesses An array of post processes to be run. (default: null)
  38321. * @returns True if the post processes were able to be run.
  38322. * @hidden
  38323. */
  38324. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38325. /**
  38326. * Manually render a set of post processes to a texture.
  38327. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38328. * @param postProcesses An array of post processes to be run.
  38329. * @param targetTexture The target texture to render to.
  38330. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38331. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38332. * @param lodLevel defines which lod of the texture to render to
  38333. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38334. */
  38335. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38336. /**
  38337. * Finalize the result of the output of the postprocesses.
  38338. * @param doNotPresent If true the result will not be displayed to the screen.
  38339. * @param targetTexture The target texture to render to.
  38340. * @param faceIndex The index of the face to bind the target texture to.
  38341. * @param postProcesses The array of post processes to render.
  38342. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38343. * @hidden
  38344. */
  38345. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38346. /**
  38347. * Disposes of the post process manager.
  38348. */
  38349. dispose(): void;
  38350. }
  38351. }
  38352. declare module BABYLON {
  38353. /**
  38354. * This Helps creating a texture that will be created from a camera in your scene.
  38355. * It is basically a dynamic texture that could be used to create special effects for instance.
  38356. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38357. */
  38358. export class RenderTargetTexture extends Texture {
  38359. /**
  38360. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38361. */
  38362. static readonly REFRESHRATE_RENDER_ONCE: number;
  38363. /**
  38364. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  38365. */
  38366. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38367. /**
  38368. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38369. * the central point of your effect and can save a lot of performances.
  38370. */
  38371. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38372. /**
  38373. * Use this predicate to dynamically define the list of mesh you want to render.
  38374. * If set, the renderList property will be overwritten.
  38375. */
  38376. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38377. private _renderList;
  38378. /**
  38379. * Use this list to define the list of mesh you want to render.
  38380. */
  38381. get renderList(): Nullable<Array<AbstractMesh>>;
  38382. set renderList(value: Nullable<Array<AbstractMesh>>);
  38383. /**
  38384. * Use this function to overload the renderList array at rendering time.
  38385. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  38386. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38387. * the cube (if the RTT is a cube, else layerOrFace=0).
  38388. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38389. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38390. * hold dummy elements!
  38391. */
  38392. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38393. private _hookArray;
  38394. /**
  38395. * Define if particles should be rendered in your texture.
  38396. */
  38397. renderParticles: boolean;
  38398. /**
  38399. * Define if sprites should be rendered in your texture.
  38400. */
  38401. renderSprites: boolean;
  38402. /**
  38403. * Define the camera used to render the texture.
  38404. */
  38405. activeCamera: Nullable<Camera>;
  38406. /**
  38407. * Override the mesh isReady function with your own one.
  38408. */
  38409. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38410. /**
  38411. * Override the render function of the texture with your own one.
  38412. */
  38413. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38414. /**
  38415. * Define if camera post processes should be use while rendering the texture.
  38416. */
  38417. useCameraPostProcesses: boolean;
  38418. /**
  38419. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38420. */
  38421. ignoreCameraViewport: boolean;
  38422. private _postProcessManager;
  38423. private _postProcesses;
  38424. private _resizeObserver;
  38425. /**
  38426. * An event triggered when the texture is unbind.
  38427. */
  38428. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38429. /**
  38430. * An event triggered when the texture is unbind.
  38431. */
  38432. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38433. private _onAfterUnbindObserver;
  38434. /**
  38435. * Set a after unbind callback in the texture.
  38436. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38437. */
  38438. set onAfterUnbind(callback: () => void);
  38439. /**
  38440. * An event triggered before rendering the texture
  38441. */
  38442. onBeforeRenderObservable: Observable<number>;
  38443. private _onBeforeRenderObserver;
  38444. /**
  38445. * Set a before render callback in the texture.
  38446. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38447. */
  38448. set onBeforeRender(callback: (faceIndex: number) => void);
  38449. /**
  38450. * An event triggered after rendering the texture
  38451. */
  38452. onAfterRenderObservable: Observable<number>;
  38453. private _onAfterRenderObserver;
  38454. /**
  38455. * Set a after render callback in the texture.
  38456. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38457. */
  38458. set onAfterRender(callback: (faceIndex: number) => void);
  38459. /**
  38460. * An event triggered after the texture clear
  38461. */
  38462. onClearObservable: Observable<Engine>;
  38463. private _onClearObserver;
  38464. /**
  38465. * Set a clear callback in the texture.
  38466. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38467. */
  38468. set onClear(callback: (Engine: Engine) => void);
  38469. /**
  38470. * An event triggered when the texture is resized.
  38471. */
  38472. onResizeObservable: Observable<RenderTargetTexture>;
  38473. /**
  38474. * Define the clear color of the Render Target if it should be different from the scene.
  38475. */
  38476. clearColor: Color4;
  38477. protected _size: number | {
  38478. width: number;
  38479. height: number;
  38480. layers?: number;
  38481. };
  38482. protected _initialSizeParameter: number | {
  38483. width: number;
  38484. height: number;
  38485. } | {
  38486. ratio: number;
  38487. };
  38488. protected _sizeRatio: Nullable<number>;
  38489. /** @hidden */
  38490. _generateMipMaps: boolean;
  38491. protected _renderingManager: RenderingManager;
  38492. /** @hidden */
  38493. _waitingRenderList?: string[];
  38494. protected _doNotChangeAspectRatio: boolean;
  38495. protected _currentRefreshId: number;
  38496. protected _refreshRate: number;
  38497. protected _textureMatrix: Matrix;
  38498. protected _samples: number;
  38499. protected _renderTargetOptions: RenderTargetCreationOptions;
  38500. /**
  38501. * Gets render target creation options that were used.
  38502. */
  38503. get renderTargetOptions(): RenderTargetCreationOptions;
  38504. protected _onRatioRescale(): void;
  38505. /**
  38506. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38507. * It must define where the camera used to render the texture is set
  38508. */
  38509. boundingBoxPosition: Vector3;
  38510. private _boundingBoxSize;
  38511. /**
  38512. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38513. * When defined, the cubemap will switch to local mode
  38514. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38515. * @example https://www.babylonjs-playground.com/#RNASML
  38516. */
  38517. set boundingBoxSize(value: Vector3);
  38518. get boundingBoxSize(): Vector3;
  38519. /**
  38520. * In case the RTT has been created with a depth texture, get the associated
  38521. * depth texture.
  38522. * Otherwise, return null.
  38523. */
  38524. get depthStencilTexture(): Nullable<InternalTexture>;
  38525. /**
  38526. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  38527. * or used a shadow, depth texture...
  38528. * @param name The friendly name of the texture
  38529. * @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)
  38530. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38531. * @param generateMipMaps True if mip maps need to be generated after render.
  38532. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38533. * @param type The type of the buffer in the RTT (int, half float, float...)
  38534. * @param isCube True if a cube texture needs to be created
  38535. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38536. * @param generateDepthBuffer True to generate a depth buffer
  38537. * @param generateStencilBuffer True to generate a stencil buffer
  38538. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38539. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38540. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38541. * @param samples sample count to use when creating the RTT
  38542. */
  38543. constructor(name: string, size: number | {
  38544. width: number;
  38545. height: number;
  38546. layers?: number;
  38547. } | {
  38548. ratio: number;
  38549. }, 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);
  38550. /**
  38551. * Creates a depth stencil texture.
  38552. * This is only available in WebGL 2 or with the depth texture extension available.
  38553. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38554. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38555. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38556. * @param samples sample count of the depth/stencil texture
  38557. */
  38558. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38559. private _processSizeParameter;
  38560. /**
  38561. * Define the number of samples to use in case of MSAA.
  38562. * It defaults to one meaning no MSAA has been enabled.
  38563. */
  38564. get samples(): number;
  38565. set samples(value: number);
  38566. /**
  38567. * Resets the refresh counter of the texture and start bak from scratch.
  38568. * Could be useful to regenerate the texture if it is setup to render only once.
  38569. */
  38570. resetRefreshCounter(): void;
  38571. /**
  38572. * Define the refresh rate of the texture or the rendering frequency.
  38573. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38574. */
  38575. get refreshRate(): number;
  38576. set refreshRate(value: number);
  38577. /**
  38578. * Adds a post process to the render target rendering passes.
  38579. * @param postProcess define the post process to add
  38580. */
  38581. addPostProcess(postProcess: PostProcess): void;
  38582. /**
  38583. * Clear all the post processes attached to the render target
  38584. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  38585. */
  38586. clearPostProcesses(dispose?: boolean): void;
  38587. /**
  38588. * Remove one of the post process from the list of attached post processes to the texture
  38589. * @param postProcess define the post process to remove from the list
  38590. */
  38591. removePostProcess(postProcess: PostProcess): void;
  38592. /** @hidden */
  38593. _shouldRender(): boolean;
  38594. /**
  38595. * Gets the actual render size of the texture.
  38596. * @returns the width of the render size
  38597. */
  38598. getRenderSize(): number;
  38599. /**
  38600. * Gets the actual render width of the texture.
  38601. * @returns the width of the render size
  38602. */
  38603. getRenderWidth(): number;
  38604. /**
  38605. * Gets the actual render height of the texture.
  38606. * @returns the height of the render size
  38607. */
  38608. getRenderHeight(): number;
  38609. /**
  38610. * Gets the actual number of layers of the texture.
  38611. * @returns the number of layers
  38612. */
  38613. getRenderLayers(): number;
  38614. /**
  38615. * Get if the texture can be rescaled or not.
  38616. */
  38617. get canRescale(): boolean;
  38618. /**
  38619. * Resize the texture using a ratio.
  38620. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  38621. */
  38622. scale(ratio: number): void;
  38623. /**
  38624. * Get the texture reflection matrix used to rotate/transform the reflection.
  38625. * @returns the reflection matrix
  38626. */
  38627. getReflectionTextureMatrix(): Matrix;
  38628. /**
  38629. * Resize the texture to a new desired size.
  38630. * Be carrefull as it will recreate all the data in the new texture.
  38631. * @param size Define the new size. It can be:
  38632. * - a number for squared texture,
  38633. * - an object containing { width: number, height: number }
  38634. * - or an object containing a ratio { ratio: number }
  38635. */
  38636. resize(size: number | {
  38637. width: number;
  38638. height: number;
  38639. } | {
  38640. ratio: number;
  38641. }): void;
  38642. private _defaultRenderListPrepared;
  38643. /**
  38644. * Renders all the objects from the render list into the texture.
  38645. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  38646. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  38647. */
  38648. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38649. private _bestReflectionRenderTargetDimension;
  38650. private _prepareRenderingManager;
  38651. /**
  38652. * @hidden
  38653. * @param faceIndex face index to bind to if this is a cubetexture
  38654. * @param layer defines the index of the texture to bind in the array
  38655. */
  38656. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  38657. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38658. private renderToTarget;
  38659. /**
  38660. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38661. * This allowed control for front to back rendering or reversly depending of the special needs.
  38662. *
  38663. * @param renderingGroupId The rendering group id corresponding to its index
  38664. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38665. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38666. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38667. */
  38668. 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;
  38669. /**
  38670. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38671. *
  38672. * @param renderingGroupId The rendering group id corresponding to its index
  38673. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38674. */
  38675. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38676. /**
  38677. * Clones the texture.
  38678. * @returns the cloned texture
  38679. */
  38680. clone(): RenderTargetTexture;
  38681. /**
  38682. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  38683. * @returns The JSON representation of the texture
  38684. */
  38685. serialize(): any;
  38686. /**
  38687. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  38688. */
  38689. disposeFramebufferObjects(): void;
  38690. /**
  38691. * Dispose the texture and release its associated resources.
  38692. */
  38693. dispose(): void;
  38694. /** @hidden */
  38695. _rebuild(): void;
  38696. /**
  38697. * Clear the info related to rendering groups preventing retention point in material dispose.
  38698. */
  38699. freeRenderingGroups(): void;
  38700. /**
  38701. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  38702. * @returns the view count
  38703. */
  38704. getViewCount(): number;
  38705. }
  38706. }
  38707. declare module BABYLON {
  38708. /**
  38709. * Options to be used when creating an effect.
  38710. */
  38711. export interface IEffectCreationOptions {
  38712. /**
  38713. * Atrributes that will be used in the shader.
  38714. */
  38715. attributes: string[];
  38716. /**
  38717. * Uniform varible names that will be set in the shader.
  38718. */
  38719. uniformsNames: string[];
  38720. /**
  38721. * Uniform buffer variable names that will be set in the shader.
  38722. */
  38723. uniformBuffersNames: string[];
  38724. /**
  38725. * Sampler texture variable names that will be set in the shader.
  38726. */
  38727. samplers: string[];
  38728. /**
  38729. * Define statements that will be set in the shader.
  38730. */
  38731. defines: any;
  38732. /**
  38733. * Possible fallbacks for this effect to improve performance when needed.
  38734. */
  38735. fallbacks: Nullable<IEffectFallbacks>;
  38736. /**
  38737. * Callback that will be called when the shader is compiled.
  38738. */
  38739. onCompiled: Nullable<(effect: Effect) => void>;
  38740. /**
  38741. * Callback that will be called if an error occurs during shader compilation.
  38742. */
  38743. onError: Nullable<(effect: Effect, errors: string) => void>;
  38744. /**
  38745. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38746. */
  38747. indexParameters?: any;
  38748. /**
  38749. * Max number of lights that can be used in the shader.
  38750. */
  38751. maxSimultaneousLights?: number;
  38752. /**
  38753. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38754. */
  38755. transformFeedbackVaryings?: Nullable<string[]>;
  38756. /**
  38757. * 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
  38758. */
  38759. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38760. /**
  38761. * Is this effect rendering to several color attachments ?
  38762. */
  38763. multiTarget?: boolean;
  38764. }
  38765. /**
  38766. * Effect containing vertex and fragment shader that can be executed on an object.
  38767. */
  38768. export class Effect implements IDisposable {
  38769. /**
  38770. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38771. */
  38772. static ShadersRepository: string;
  38773. /**
  38774. * Enable logging of the shader code when a compilation error occurs
  38775. */
  38776. static LogShaderCodeOnCompilationError: boolean;
  38777. /**
  38778. * Name of the effect.
  38779. */
  38780. name: any;
  38781. /**
  38782. * String container all the define statements that should be set on the shader.
  38783. */
  38784. defines: string;
  38785. /**
  38786. * Callback that will be called when the shader is compiled.
  38787. */
  38788. onCompiled: Nullable<(effect: Effect) => void>;
  38789. /**
  38790. * Callback that will be called if an error occurs during shader compilation.
  38791. */
  38792. onError: Nullable<(effect: Effect, errors: string) => void>;
  38793. /**
  38794. * Callback that will be called when effect is bound.
  38795. */
  38796. onBind: Nullable<(effect: Effect) => void>;
  38797. /**
  38798. * Unique ID of the effect.
  38799. */
  38800. uniqueId: number;
  38801. /**
  38802. * Observable that will be called when the shader is compiled.
  38803. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38804. */
  38805. onCompileObservable: Observable<Effect>;
  38806. /**
  38807. * Observable that will be called if an error occurs during shader compilation.
  38808. */
  38809. onErrorObservable: Observable<Effect>;
  38810. /** @hidden */
  38811. _onBindObservable: Nullable<Observable<Effect>>;
  38812. /**
  38813. * @hidden
  38814. * Specifies if the effect was previously ready
  38815. */
  38816. _wasPreviouslyReady: boolean;
  38817. /**
  38818. * Observable that will be called when effect is bound.
  38819. */
  38820. get onBindObservable(): Observable<Effect>;
  38821. /** @hidden */
  38822. _bonesComputationForcedToCPU: boolean;
  38823. /** @hidden */
  38824. _uniformBuffersNames: {
  38825. [key: string]: number;
  38826. };
  38827. /** @hidden */
  38828. _samplerList: string[];
  38829. /** @hidden */
  38830. _multiTarget: boolean;
  38831. private static _uniqueIdSeed;
  38832. private _engine;
  38833. private _uniformBuffersNamesList;
  38834. private _uniformsNames;
  38835. private _samplers;
  38836. private _isReady;
  38837. private _compilationError;
  38838. private _allFallbacksProcessed;
  38839. private _attributesNames;
  38840. private _attributes;
  38841. private _attributeLocationByName;
  38842. private _uniforms;
  38843. /**
  38844. * Key for the effect.
  38845. * @hidden
  38846. */
  38847. _key: string;
  38848. private _indexParameters;
  38849. private _fallbacks;
  38850. private _vertexSourceCodeOverride;
  38851. private _fragmentSourceCodeOverride;
  38852. private _transformFeedbackVaryings;
  38853. /**
  38854. * Compiled shader to webGL program.
  38855. * @hidden
  38856. */
  38857. _pipelineContext: Nullable<IPipelineContext>;
  38858. /** @hidden */
  38859. _vertexSourceCode: string;
  38860. /** @hidden */
  38861. _fragmentSourceCode: string;
  38862. /** @hidden */
  38863. private _rawVertexSourceCode;
  38864. /** @hidden */
  38865. private _rawFragmentSourceCode;
  38866. private static _baseCache;
  38867. private _processingContext;
  38868. /**
  38869. * Instantiates an effect.
  38870. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38871. * @param baseName Name of the effect.
  38872. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38873. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38874. * @param samplers List of sampler variables that will be passed to the shader.
  38875. * @param engine Engine to be used to render the effect
  38876. * @param defines Define statements to be added to the shader.
  38877. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38878. * @param onCompiled Callback that will be called when the shader is compiled.
  38879. * @param onError Callback that will be called if an error occurs during shader compilation.
  38880. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38881. * @param key Effect Key identifying uniquely compiled shader variants
  38882. */
  38883. 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);
  38884. private _useFinalCode;
  38885. /**
  38886. * Unique key for this effect
  38887. */
  38888. get key(): string;
  38889. /**
  38890. * If the effect has been compiled and prepared.
  38891. * @returns if the effect is compiled and prepared.
  38892. */
  38893. isReady(): boolean;
  38894. private _isReadyInternal;
  38895. /**
  38896. * The engine the effect was initialized with.
  38897. * @returns the engine.
  38898. */
  38899. getEngine(): Engine;
  38900. /**
  38901. * The pipeline context for this effect
  38902. * @returns the associated pipeline context
  38903. */
  38904. getPipelineContext(): Nullable<IPipelineContext>;
  38905. /**
  38906. * The set of names of attribute variables for the shader.
  38907. * @returns An array of attribute names.
  38908. */
  38909. getAttributesNames(): string[];
  38910. /**
  38911. * Returns the attribute at the given index.
  38912. * @param index The index of the attribute.
  38913. * @returns The location of the attribute.
  38914. */
  38915. getAttributeLocation(index: number): number;
  38916. /**
  38917. * Returns the attribute based on the name of the variable.
  38918. * @param name of the attribute to look up.
  38919. * @returns the attribute location.
  38920. */
  38921. getAttributeLocationByName(name: string): number;
  38922. /**
  38923. * The number of attributes.
  38924. * @returns the numnber of attributes.
  38925. */
  38926. getAttributesCount(): number;
  38927. /**
  38928. * Gets the index of a uniform variable.
  38929. * @param uniformName of the uniform to look up.
  38930. * @returns the index.
  38931. */
  38932. getUniformIndex(uniformName: string): number;
  38933. /**
  38934. * Returns the attribute based on the name of the variable.
  38935. * @param uniformName of the uniform to look up.
  38936. * @returns the location of the uniform.
  38937. */
  38938. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38939. /**
  38940. * Returns an array of sampler variable names
  38941. * @returns The array of sampler variable names.
  38942. */
  38943. getSamplers(): string[];
  38944. /**
  38945. * Returns an array of uniform variable names
  38946. * @returns The array of uniform variable names.
  38947. */
  38948. getUniformNames(): string[];
  38949. /**
  38950. * Returns an array of uniform buffer variable names
  38951. * @returns The array of uniform buffer variable names.
  38952. */
  38953. getUniformBuffersNames(): string[];
  38954. /**
  38955. * Returns the index parameters used to create the effect
  38956. * @returns The index parameters object
  38957. */
  38958. getIndexParameters(): any;
  38959. /**
  38960. * The error from the last compilation.
  38961. * @returns the error string.
  38962. */
  38963. getCompilationError(): string;
  38964. /**
  38965. * Gets a boolean indicating that all fallbacks were used during compilation
  38966. * @returns true if all fallbacks were used
  38967. */
  38968. allFallbacksProcessed(): boolean;
  38969. /**
  38970. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38971. * @param func The callback to be used.
  38972. */
  38973. executeWhenCompiled(func: (effect: Effect) => void): void;
  38974. private _checkIsReady;
  38975. private _loadShader;
  38976. /**
  38977. * Gets the vertex shader source code of this effect
  38978. */
  38979. get vertexSourceCode(): string;
  38980. /**
  38981. * Gets the fragment shader source code of this effect
  38982. */
  38983. get fragmentSourceCode(): string;
  38984. /**
  38985. * Gets the vertex shader source code before it has been processed by the preprocessor
  38986. */
  38987. get rawVertexSourceCode(): string;
  38988. /**
  38989. * Gets the fragment shader source code before it has been processed by the preprocessor
  38990. */
  38991. get rawFragmentSourceCode(): string;
  38992. /**
  38993. * Recompiles the webGL program
  38994. * @param vertexSourceCode The source code for the vertex shader.
  38995. * @param fragmentSourceCode The source code for the fragment shader.
  38996. * @param onCompiled Callback called when completed.
  38997. * @param onError Callback called on error.
  38998. * @hidden
  38999. */
  39000. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39001. /**
  39002. * Prepares the effect
  39003. * @hidden
  39004. */
  39005. _prepareEffect(): void;
  39006. private _getShaderCodeAndErrorLine;
  39007. private _processCompilationErrors;
  39008. /**
  39009. * Checks if the effect is supported. (Must be called after compilation)
  39010. */
  39011. get isSupported(): boolean;
  39012. /**
  39013. * Binds a texture to the engine to be used as output of the shader.
  39014. * @param channel Name of the output variable.
  39015. * @param texture Texture to bind.
  39016. * @hidden
  39017. */
  39018. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39019. /**
  39020. * Sets a texture on the engine to be used in the shader.
  39021. * @param channel Name of the sampler variable.
  39022. * @param texture Texture to set.
  39023. */
  39024. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39025. /**
  39026. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39027. * @param channel Name of the sampler variable.
  39028. * @param texture Texture to set.
  39029. */
  39030. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39031. /**
  39032. * Sets an array of textures on the engine to be used in the shader.
  39033. * @param channel Name of the variable.
  39034. * @param textures Textures to set.
  39035. */
  39036. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39037. /**
  39038. * 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)
  39039. * @param channel Name of the sampler variable.
  39040. * @param postProcess Post process to get the input texture from.
  39041. */
  39042. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39043. /**
  39044. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39045. * 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)
  39046. * @param channel Name of the sampler variable.
  39047. * @param postProcess Post process to get the output texture from.
  39048. */
  39049. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39050. /**
  39051. * Binds a buffer to a uniform.
  39052. * @param buffer Buffer to bind.
  39053. * @param name Name of the uniform variable to bind to.
  39054. */
  39055. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39056. /**
  39057. * Binds block to a uniform.
  39058. * @param blockName Name of the block to bind.
  39059. * @param index Index to bind.
  39060. */
  39061. bindUniformBlock(blockName: string, index: number): void;
  39062. /**
  39063. * Sets an interger value on a uniform variable.
  39064. * @param uniformName Name of the variable.
  39065. * @param value Value to be set.
  39066. * @returns this effect.
  39067. */
  39068. setInt(uniformName: string, value: number): Effect;
  39069. /**
  39070. * Sets an int2 value on a uniform variable.
  39071. * @param uniformName Name of the variable.
  39072. * @param x First int in int2.
  39073. * @param y Second int in int2.
  39074. * @returns this effect.
  39075. */
  39076. setInt2(uniformName: string, x: number, y: number): Effect;
  39077. /**
  39078. * Sets an int3 value on a uniform variable.
  39079. * @param uniformName Name of the variable.
  39080. * @param x First int in int3.
  39081. * @param y Second int in int3.
  39082. * @param z Third int in int3.
  39083. * @returns this effect.
  39084. */
  39085. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39086. /**
  39087. * Sets an int4 value on a uniform variable.
  39088. * @param uniformName Name of the variable.
  39089. * @param x First int in int4.
  39090. * @param y Second int in int4.
  39091. * @param z Third int in int4.
  39092. * @param w Fourth int in int4.
  39093. * @returns this effect.
  39094. */
  39095. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39096. /**
  39097. * Sets an int array on a uniform variable.
  39098. * @param uniformName Name of the variable.
  39099. * @param array array to be set.
  39100. * @returns this effect.
  39101. */
  39102. setIntArray(uniformName: string, array: Int32Array): Effect;
  39103. /**
  39104. * 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)
  39105. * @param uniformName Name of the variable.
  39106. * @param array array to be set.
  39107. * @returns this effect.
  39108. */
  39109. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39110. /**
  39111. * 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)
  39112. * @param uniformName Name of the variable.
  39113. * @param array array to be set.
  39114. * @returns this effect.
  39115. */
  39116. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39117. /**
  39118. * 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)
  39119. * @param uniformName Name of the variable.
  39120. * @param array array to be set.
  39121. * @returns this effect.
  39122. */
  39123. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39124. /**
  39125. * Sets an float array on a uniform variable.
  39126. * @param uniformName Name of the variable.
  39127. * @param array array to be set.
  39128. * @returns this effect.
  39129. */
  39130. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39131. /**
  39132. * 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)
  39133. * @param uniformName Name of the variable.
  39134. * @param array array to be set.
  39135. * @returns this effect.
  39136. */
  39137. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39138. /**
  39139. * 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)
  39140. * @param uniformName Name of the variable.
  39141. * @param array array to be set.
  39142. * @returns this effect.
  39143. */
  39144. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39145. /**
  39146. * 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)
  39147. * @param uniformName Name of the variable.
  39148. * @param array array to be set.
  39149. * @returns this effect.
  39150. */
  39151. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39152. /**
  39153. * Sets an array on a uniform variable.
  39154. * @param uniformName Name of the variable.
  39155. * @param array array to be set.
  39156. * @returns this effect.
  39157. */
  39158. setArray(uniformName: string, array: number[]): Effect;
  39159. /**
  39160. * 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)
  39161. * @param uniformName Name of the variable.
  39162. * @param array array to be set.
  39163. * @returns this effect.
  39164. */
  39165. setArray2(uniformName: string, array: number[]): Effect;
  39166. /**
  39167. * 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)
  39168. * @param uniformName Name of the variable.
  39169. * @param array array to be set.
  39170. * @returns this effect.
  39171. */
  39172. setArray3(uniformName: string, array: number[]): Effect;
  39173. /**
  39174. * 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)
  39175. * @param uniformName Name of the variable.
  39176. * @param array array to be set.
  39177. * @returns this effect.
  39178. */
  39179. setArray4(uniformName: string, array: number[]): Effect;
  39180. /**
  39181. * Sets matrices on a uniform variable.
  39182. * @param uniformName Name of the variable.
  39183. * @param matrices matrices to be set.
  39184. * @returns this effect.
  39185. */
  39186. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39187. /**
  39188. * Sets matrix on a uniform variable.
  39189. * @param uniformName Name of the variable.
  39190. * @param matrix matrix to be set.
  39191. * @returns this effect.
  39192. */
  39193. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39194. /**
  39195. * 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)
  39196. * @param uniformName Name of the variable.
  39197. * @param matrix matrix to be set.
  39198. * @returns this effect.
  39199. */
  39200. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39201. /**
  39202. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39203. * @param uniformName Name of the variable.
  39204. * @param matrix matrix to be set.
  39205. * @returns this effect.
  39206. */
  39207. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39208. /**
  39209. * Sets a float on a uniform variable.
  39210. * @param uniformName Name of the variable.
  39211. * @param value value to be set.
  39212. * @returns this effect.
  39213. */
  39214. setFloat(uniformName: string, value: number): Effect;
  39215. /**
  39216. * Sets a boolean on a uniform variable.
  39217. * @param uniformName Name of the variable.
  39218. * @param bool value to be set.
  39219. * @returns this effect.
  39220. */
  39221. setBool(uniformName: string, bool: boolean): Effect;
  39222. /**
  39223. * Sets a Vector2 on a uniform variable.
  39224. * @param uniformName Name of the variable.
  39225. * @param vector2 vector2 to be set.
  39226. * @returns this effect.
  39227. */
  39228. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39229. /**
  39230. * Sets a float2 on a uniform variable.
  39231. * @param uniformName Name of the variable.
  39232. * @param x First float in float2.
  39233. * @param y Second float in float2.
  39234. * @returns this effect.
  39235. */
  39236. setFloat2(uniformName: string, x: number, y: number): Effect;
  39237. /**
  39238. * Sets a Vector3 on a uniform variable.
  39239. * @param uniformName Name of the variable.
  39240. * @param vector3 Value to be set.
  39241. * @returns this effect.
  39242. */
  39243. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39244. /**
  39245. * Sets a float3 on a uniform variable.
  39246. * @param uniformName Name of the variable.
  39247. * @param x First float in float3.
  39248. * @param y Second float in float3.
  39249. * @param z Third float in float3.
  39250. * @returns this effect.
  39251. */
  39252. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39253. /**
  39254. * Sets a Vector4 on a uniform variable.
  39255. * @param uniformName Name of the variable.
  39256. * @param vector4 Value to be set.
  39257. * @returns this effect.
  39258. */
  39259. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39260. /**
  39261. * Sets a float4 on a uniform variable.
  39262. * @param uniformName Name of the variable.
  39263. * @param x First float in float4.
  39264. * @param y Second float in float4.
  39265. * @param z Third float in float4.
  39266. * @param w Fourth float in float4.
  39267. * @returns this effect.
  39268. */
  39269. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39270. /**
  39271. * Sets a Color3 on a uniform variable.
  39272. * @param uniformName Name of the variable.
  39273. * @param color3 Value to be set.
  39274. * @returns this effect.
  39275. */
  39276. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39277. /**
  39278. * Sets a Color4 on a uniform variable.
  39279. * @param uniformName Name of the variable.
  39280. * @param color3 Value to be set.
  39281. * @param alpha Alpha value to be set.
  39282. * @returns this effect.
  39283. */
  39284. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39285. /**
  39286. * Sets a Color4 on a uniform variable
  39287. * @param uniformName defines the name of the variable
  39288. * @param color4 defines the value to be set
  39289. * @returns this effect.
  39290. */
  39291. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39292. /**
  39293. * Release all associated resources.
  39294. **/
  39295. dispose(): void;
  39296. /**
  39297. * This function will add a new shader to the shader store
  39298. * @param name the name of the shader
  39299. * @param pixelShader optional pixel shader content
  39300. * @param vertexShader optional vertex shader content
  39301. */
  39302. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39303. /**
  39304. * Store of each shader (The can be looked up using effect.key)
  39305. */
  39306. static ShadersStore: {
  39307. [key: string]: string;
  39308. };
  39309. /**
  39310. * Store of each included file for a shader (The can be looked up using effect.key)
  39311. */
  39312. static IncludesShadersStore: {
  39313. [key: string]: string;
  39314. };
  39315. /**
  39316. * Resets the cache of effects.
  39317. */
  39318. static ResetCache(): void;
  39319. }
  39320. }
  39321. declare module BABYLON {
  39322. /**
  39323. * Interface used to describe the capabilities of the engine relatively to the current browser
  39324. */
  39325. export interface EngineCapabilities {
  39326. /** Maximum textures units per fragment shader */
  39327. maxTexturesImageUnits: number;
  39328. /** Maximum texture units per vertex shader */
  39329. maxVertexTextureImageUnits: number;
  39330. /** Maximum textures units in the entire pipeline */
  39331. maxCombinedTexturesImageUnits: number;
  39332. /** Maximum texture size */
  39333. maxTextureSize: number;
  39334. /** Maximum texture samples */
  39335. maxSamples?: number;
  39336. /** Maximum cube texture size */
  39337. maxCubemapTextureSize: number;
  39338. /** Maximum render texture size */
  39339. maxRenderTextureSize: number;
  39340. /** Maximum number of vertex attributes */
  39341. maxVertexAttribs: number;
  39342. /** Maximum number of varyings */
  39343. maxVaryingVectors: number;
  39344. /** Maximum number of uniforms per vertex shader */
  39345. maxVertexUniformVectors: number;
  39346. /** Maximum number of uniforms per fragment shader */
  39347. maxFragmentUniformVectors: number;
  39348. /** Defines if standard derivates (dx/dy) are supported */
  39349. standardDerivatives: boolean;
  39350. /** Defines if s3tc texture compression is supported */
  39351. s3tc?: WEBGL_compressed_texture_s3tc;
  39352. /** Defines if pvrtc texture compression is supported */
  39353. pvrtc: any;
  39354. /** Defines if etc1 texture compression is supported */
  39355. etc1: any;
  39356. /** Defines if etc2 texture compression is supported */
  39357. etc2: any;
  39358. /** Defines if astc texture compression is supported */
  39359. astc: any;
  39360. /** Defines if bptc texture compression is supported */
  39361. bptc: any;
  39362. /** Defines if float textures are supported */
  39363. textureFloat: boolean;
  39364. /** Defines if vertex array objects are supported */
  39365. vertexArrayObject: boolean;
  39366. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39367. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39368. /** Gets the maximum level of anisotropy supported */
  39369. maxAnisotropy: number;
  39370. /** Defines if instancing is supported */
  39371. instancedArrays: boolean;
  39372. /** Defines if 32 bits indices are supported */
  39373. uintIndices: boolean;
  39374. /** Defines if high precision shaders are supported */
  39375. highPrecisionShaderSupported: boolean;
  39376. /** Defines if depth reading in the fragment shader is supported */
  39377. fragmentDepthSupported: boolean;
  39378. /** Defines if float texture linear filtering is supported*/
  39379. textureFloatLinearFiltering: boolean;
  39380. /** Defines if rendering to float textures is supported */
  39381. textureFloatRender: boolean;
  39382. /** Defines if half float textures are supported*/
  39383. textureHalfFloat: boolean;
  39384. /** Defines if half float texture linear filtering is supported*/
  39385. textureHalfFloatLinearFiltering: boolean;
  39386. /** Defines if rendering to half float textures is supported */
  39387. textureHalfFloatRender: boolean;
  39388. /** Defines if textureLOD shader command is supported */
  39389. textureLOD: boolean;
  39390. /** Defines if draw buffers extension is supported */
  39391. drawBuffersExtension: boolean;
  39392. /** Defines if depth textures are supported */
  39393. depthTextureExtension: boolean;
  39394. /** Defines if float color buffer are supported */
  39395. colorBufferFloat: boolean;
  39396. /** Gets disjoint timer query extension (null if not supported) */
  39397. timerQuery?: EXT_disjoint_timer_query;
  39398. /** Defines if timestamp can be used with timer query */
  39399. canUseTimestampForTimerQuery: boolean;
  39400. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39401. multiview?: any;
  39402. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39403. oculusMultiview?: any;
  39404. /** Function used to let the system compiles shaders in background */
  39405. parallelShaderCompile?: {
  39406. COMPLETION_STATUS_KHR: number;
  39407. };
  39408. /** Max number of texture samples for MSAA */
  39409. maxMSAASamples: number;
  39410. /** Defines if the blend min max extension is supported */
  39411. blendMinMax: boolean;
  39412. /** 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 */
  39413. canUseGLInstanceID: boolean;
  39414. }
  39415. }
  39416. declare module BABYLON {
  39417. /**
  39418. * @hidden
  39419. **/
  39420. export class DepthCullingState {
  39421. private _isDepthTestDirty;
  39422. private _isDepthMaskDirty;
  39423. private _isDepthFuncDirty;
  39424. private _isCullFaceDirty;
  39425. private _isCullDirty;
  39426. private _isZOffsetDirty;
  39427. private _isFrontFaceDirty;
  39428. private _depthTest;
  39429. private _depthMask;
  39430. private _depthFunc;
  39431. private _cull;
  39432. private _cullFace;
  39433. private _zOffset;
  39434. private _frontFace;
  39435. /**
  39436. * Initializes the state.
  39437. */
  39438. constructor();
  39439. get isDirty(): boolean;
  39440. get zOffset(): number;
  39441. set zOffset(value: number);
  39442. get cullFace(): Nullable<number>;
  39443. set cullFace(value: Nullable<number>);
  39444. get cull(): Nullable<boolean>;
  39445. set cull(value: Nullable<boolean>);
  39446. get depthFunc(): Nullable<number>;
  39447. set depthFunc(value: Nullable<number>);
  39448. get depthMask(): boolean;
  39449. set depthMask(value: boolean);
  39450. get depthTest(): boolean;
  39451. set depthTest(value: boolean);
  39452. get frontFace(): Nullable<number>;
  39453. set frontFace(value: Nullable<number>);
  39454. reset(): void;
  39455. apply(gl: WebGLRenderingContext): void;
  39456. }
  39457. }
  39458. declare module BABYLON {
  39459. /**
  39460. * @hidden
  39461. **/
  39462. export class StencilState {
  39463. /** 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 */
  39464. static readonly ALWAYS: number;
  39465. /** Passed to stencilOperation to specify that stencil value must be kept */
  39466. static readonly KEEP: number;
  39467. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39468. static readonly REPLACE: number;
  39469. private _isStencilTestDirty;
  39470. private _isStencilMaskDirty;
  39471. private _isStencilFuncDirty;
  39472. private _isStencilOpDirty;
  39473. private _stencilTest;
  39474. private _stencilMask;
  39475. private _stencilFunc;
  39476. private _stencilFuncRef;
  39477. private _stencilFuncMask;
  39478. private _stencilOpStencilFail;
  39479. private _stencilOpDepthFail;
  39480. private _stencilOpStencilDepthPass;
  39481. get isDirty(): boolean;
  39482. get stencilFunc(): number;
  39483. set stencilFunc(value: number);
  39484. get stencilFuncRef(): number;
  39485. set stencilFuncRef(value: number);
  39486. get stencilFuncMask(): number;
  39487. set stencilFuncMask(value: number);
  39488. get stencilOpStencilFail(): number;
  39489. set stencilOpStencilFail(value: number);
  39490. get stencilOpDepthFail(): number;
  39491. set stencilOpDepthFail(value: number);
  39492. get stencilOpStencilDepthPass(): number;
  39493. set stencilOpStencilDepthPass(value: number);
  39494. get stencilMask(): number;
  39495. set stencilMask(value: number);
  39496. get stencilTest(): boolean;
  39497. set stencilTest(value: boolean);
  39498. constructor();
  39499. reset(): void;
  39500. apply(gl: WebGLRenderingContext): void;
  39501. }
  39502. }
  39503. declare module BABYLON {
  39504. /**
  39505. * @hidden
  39506. **/
  39507. export class AlphaState {
  39508. _blendFunctionParameters: Nullable<number>[];
  39509. _blendEquationParameters: Nullable<number>[];
  39510. _blendConstants: Nullable<number>[];
  39511. _isBlendConstantsDirty: boolean;
  39512. private _alphaBlend;
  39513. private _isAlphaBlendDirty;
  39514. private _isBlendFunctionParametersDirty;
  39515. private _isBlendEquationParametersDirty;
  39516. /**
  39517. * Initializes the state.
  39518. */
  39519. constructor();
  39520. get isDirty(): boolean;
  39521. get alphaBlend(): boolean;
  39522. set alphaBlend(value: boolean);
  39523. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39524. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39525. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39526. reset(): void;
  39527. apply(gl: WebGLRenderingContext): void;
  39528. }
  39529. }
  39530. declare module BABYLON {
  39531. /** @hidden */
  39532. export class WebGLShaderProcessor implements IShaderProcessor {
  39533. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39534. }
  39535. }
  39536. declare module BABYLON {
  39537. /** @hidden */
  39538. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39539. attributeProcessor(attribute: string): string;
  39540. varyingProcessor(varying: string, isFragment: boolean): string;
  39541. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39542. }
  39543. }
  39544. declare module BABYLON {
  39545. /**
  39546. * Interface for attribute information associated with buffer instanciation
  39547. */
  39548. export interface InstancingAttributeInfo {
  39549. /**
  39550. * Name of the GLSL attribute
  39551. * if attribute index is not specified, this is used to retrieve the index from the effect
  39552. */
  39553. attributeName: string;
  39554. /**
  39555. * Index/offset of the attribute in the vertex shader
  39556. * if not specified, this will be computes from the name.
  39557. */
  39558. index?: number;
  39559. /**
  39560. * size of the attribute, 1, 2, 3 or 4
  39561. */
  39562. attributeSize: number;
  39563. /**
  39564. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39565. */
  39566. offset: number;
  39567. /**
  39568. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39569. * default to 1
  39570. */
  39571. divisor?: number;
  39572. /**
  39573. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39574. * default is FLOAT
  39575. */
  39576. attributeType?: number;
  39577. /**
  39578. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39579. */
  39580. normalized?: boolean;
  39581. }
  39582. }
  39583. declare module BABYLON {
  39584. /** @hidden */
  39585. export interface EngineFeatures {
  39586. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39587. forceBitmapOverHTMLImageElement: boolean;
  39588. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  39589. supportRenderAndCopyToLodForFloatTextures: boolean;
  39590. /** Indicates that the engine support handling depth/stencil textures */
  39591. supportDepthStencilTexture: boolean;
  39592. /** Indicates that the engine support shadow samplers */
  39593. supportShadowSamplers: boolean;
  39594. /** 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 */
  39595. uniformBufferHardCheckMatrix: boolean;
  39596. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  39597. allowTexturePrefiltering: boolean;
  39598. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  39599. trackUbosInFrame: boolean;
  39600. /** Indicates that the Cascaded Shadow Map technic is supported */
  39601. supportCSM: boolean;
  39602. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  39603. basisNeedsPOT: boolean;
  39604. /** Indicates that the engine supports 3D textures */
  39605. support3DTextures: boolean;
  39606. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  39607. needTypeSuffixInShaderConstants: boolean;
  39608. /** Indicates that MSAA is supported */
  39609. supportMSAA: boolean;
  39610. /** Indicates that SSAO2 is supported */
  39611. supportSSAO2: boolean;
  39612. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  39613. supportExtendedTextureFormats: boolean;
  39614. /** Indicates that the switch/case construct is supported in shaders */
  39615. supportSwitchCaseInShader: boolean;
  39616. /** @hidden */
  39617. _collectUbosUpdatedInFrame: boolean;
  39618. }
  39619. }
  39620. declare module BABYLON {
  39621. /** @hidden */
  39622. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  39623. private _webGLTexture;
  39624. private _context;
  39625. get underlyingResource(): Nullable<WebGLTexture>;
  39626. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  39627. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  39628. set(hardwareTexture: WebGLTexture): void;
  39629. reset(): void;
  39630. release(): void;
  39631. }
  39632. }
  39633. declare module BABYLON {
  39634. interface ThinEngine {
  39635. /**
  39636. * Update a video texture
  39637. * @param texture defines the texture to update
  39638. * @param video defines the video element to use
  39639. * @param invertY defines if data must be stored with Y axis inverted
  39640. */
  39641. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39642. }
  39643. }
  39644. declare module BABYLON {
  39645. interface ThinEngine {
  39646. /**
  39647. * Creates a dynamic texture
  39648. * @param width defines the width of the texture
  39649. * @param height defines the height of the texture
  39650. * @param generateMipMaps defines if the engine should generate the mip levels
  39651. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39652. * @returns the dynamic texture inside an InternalTexture
  39653. */
  39654. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39655. /**
  39656. * Update the content of a dynamic texture
  39657. * @param texture defines the texture to update
  39658. * @param source defines the source containing the data
  39659. * @param invertY defines if data must be stored with Y axis inverted
  39660. * @param premulAlpha defines if alpha is stored as premultiplied
  39661. * @param format defines the format of the data
  39662. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39663. */
  39664. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39665. }
  39666. }
  39667. declare module BABYLON {
  39668. /**
  39669. * Settings for finer control over video usage
  39670. */
  39671. export interface VideoTextureSettings {
  39672. /**
  39673. * Applies `autoplay` to video, if specified
  39674. */
  39675. autoPlay?: boolean;
  39676. /**
  39677. * Applies `muted` to video, if specified
  39678. */
  39679. muted?: boolean;
  39680. /**
  39681. * Applies `loop` to video, if specified
  39682. */
  39683. loop?: boolean;
  39684. /**
  39685. * Automatically updates internal texture from video at every frame in the render loop
  39686. */
  39687. autoUpdateTexture: boolean;
  39688. /**
  39689. * Image src displayed during the video loading or until the user interacts with the video.
  39690. */
  39691. poster?: string;
  39692. }
  39693. /**
  39694. * If you want to display a video in your scene, this is the special texture for that.
  39695. * This special texture works similar to other textures, with the exception of a few parameters.
  39696. * @see https://doc.babylonjs.com/how_to/video_texture
  39697. */
  39698. export class VideoTexture extends Texture {
  39699. /**
  39700. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39701. */
  39702. readonly autoUpdateTexture: boolean;
  39703. /**
  39704. * The video instance used by the texture internally
  39705. */
  39706. readonly video: HTMLVideoElement;
  39707. private _onUserActionRequestedObservable;
  39708. /**
  39709. * Event triggerd when a dom action is required by the user to play the video.
  39710. * This happens due to recent changes in browser policies preventing video to auto start.
  39711. */
  39712. get onUserActionRequestedObservable(): Observable<Texture>;
  39713. private _generateMipMaps;
  39714. private _stillImageCaptured;
  39715. private _displayingPosterTexture;
  39716. private _settings;
  39717. private _createInternalTextureOnEvent;
  39718. private _frameId;
  39719. private _currentSrc;
  39720. /**
  39721. * Creates a video texture.
  39722. * If you want to display a video in your scene, this is the special texture for that.
  39723. * This special texture works similar to other textures, with the exception of a few parameters.
  39724. * @see https://doc.babylonjs.com/how_to/video_texture
  39725. * @param name optional name, will detect from video source, if not defined
  39726. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39727. * @param scene is obviously the current scene.
  39728. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39729. * @param invertY is false by default but can be used to invert video on Y axis
  39730. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39731. * @param settings allows finer control over video usage
  39732. */
  39733. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39734. private _getName;
  39735. private _getVideo;
  39736. private _createInternalTexture;
  39737. private reset;
  39738. /**
  39739. * @hidden Internal method to initiate `update`.
  39740. */
  39741. _rebuild(): void;
  39742. /**
  39743. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39744. */
  39745. update(): void;
  39746. /**
  39747. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39748. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39749. */
  39750. updateTexture(isVisible: boolean): void;
  39751. protected _updateInternalTexture: () => void;
  39752. /**
  39753. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39754. * @param url New url.
  39755. */
  39756. updateURL(url: string): void;
  39757. /**
  39758. * Clones the texture.
  39759. * @returns the cloned texture
  39760. */
  39761. clone(): VideoTexture;
  39762. /**
  39763. * Dispose the texture and release its associated resources.
  39764. */
  39765. dispose(): void;
  39766. /**
  39767. * Creates a video texture straight from a stream.
  39768. * @param scene Define the scene the texture should be created in
  39769. * @param stream Define the stream the texture should be created from
  39770. * @returns The created video texture as a promise
  39771. */
  39772. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39773. /**
  39774. * Creates a video texture straight from your WebCam video feed.
  39775. * @param scene Define the scene the texture should be created in
  39776. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39777. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39778. * @returns The created video texture as a promise
  39779. */
  39780. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39781. minWidth: number;
  39782. maxWidth: number;
  39783. minHeight: number;
  39784. maxHeight: number;
  39785. deviceId: string;
  39786. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39787. /**
  39788. * Creates a video texture straight from your WebCam video feed.
  39789. * @param scene Define the scene the texture should be created in
  39790. * @param onReady Define a callback to triggered once the texture will be ready
  39791. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39792. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39793. */
  39794. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39795. minWidth: number;
  39796. maxWidth: number;
  39797. minHeight: number;
  39798. maxHeight: number;
  39799. deviceId: string;
  39800. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39801. }
  39802. }
  39803. declare module BABYLON {
  39804. /**
  39805. * Defines the interface used by objects working like Scene
  39806. * @hidden
  39807. */
  39808. export interface ISceneLike {
  39809. _addPendingData(data: any): void;
  39810. _removePendingData(data: any): void;
  39811. offlineProvider: IOfflineProvider;
  39812. }
  39813. /**
  39814. * Information about the current host
  39815. */
  39816. export interface HostInformation {
  39817. /**
  39818. * Defines if the current host is a mobile
  39819. */
  39820. isMobile: boolean;
  39821. }
  39822. /** Interface defining initialization parameters for Engine class */
  39823. export interface EngineOptions extends WebGLContextAttributes {
  39824. /**
  39825. * Defines if the engine should no exceed a specified device ratio
  39826. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39827. */
  39828. limitDeviceRatio?: number;
  39829. /**
  39830. * Defines if webvr should be enabled automatically
  39831. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39832. */
  39833. autoEnableWebVR?: boolean;
  39834. /**
  39835. * Defines if webgl2 should be turned off even if supported
  39836. * @see https://doc.babylonjs.com/features/webgl2
  39837. */
  39838. disableWebGL2Support?: boolean;
  39839. /**
  39840. * Defines if webaudio should be initialized as well
  39841. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39842. */
  39843. audioEngine?: boolean;
  39844. /**
  39845. * Defines if animations should run using a deterministic lock step
  39846. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39847. */
  39848. deterministicLockstep?: boolean;
  39849. /** Defines the maximum steps to use with deterministic lock step mode */
  39850. lockstepMaxSteps?: number;
  39851. /** Defines the seconds between each deterministic lock step */
  39852. timeStep?: number;
  39853. /**
  39854. * Defines that engine should ignore context lost events
  39855. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39856. */
  39857. doNotHandleContextLost?: boolean;
  39858. /**
  39859. * Defines that engine should ignore modifying touch action attribute and style
  39860. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39861. */
  39862. doNotHandleTouchAction?: boolean;
  39863. /**
  39864. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39865. */
  39866. useHighPrecisionFloats?: boolean;
  39867. /**
  39868. * Make the canvas XR Compatible for XR sessions
  39869. */
  39870. xrCompatible?: boolean;
  39871. /**
  39872. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39873. */
  39874. useHighPrecisionMatrix?: boolean;
  39875. /**
  39876. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39877. */
  39878. failIfMajorPerformanceCaveat?: boolean;
  39879. }
  39880. /**
  39881. * The base engine class (root of all engines)
  39882. */
  39883. export class ThinEngine {
  39884. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39885. static ExceptionList: ({
  39886. key: string;
  39887. capture: string;
  39888. captureConstraint: number;
  39889. targets: string[];
  39890. } | {
  39891. key: string;
  39892. capture: null;
  39893. captureConstraint: null;
  39894. targets: string[];
  39895. })[];
  39896. /** @hidden */
  39897. static _TextureLoaders: IInternalTextureLoader[];
  39898. /**
  39899. * Returns the current npm package of the sdk
  39900. */
  39901. static get NpmPackage(): string;
  39902. /**
  39903. * Returns the current version of the framework
  39904. */
  39905. static get Version(): string;
  39906. /**
  39907. * Returns a string describing the current engine
  39908. */
  39909. get description(): string;
  39910. /**
  39911. * Returns the name of the engine
  39912. */
  39913. get name(): string;
  39914. /**
  39915. * Returns the version of the engine
  39916. */
  39917. get version(): number;
  39918. /**
  39919. * Gets or sets the epsilon value used by collision engine
  39920. */
  39921. static CollisionsEpsilon: number;
  39922. /**
  39923. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39924. */
  39925. static get ShadersRepository(): string;
  39926. static set ShadersRepository(value: string);
  39927. /** @hidden */
  39928. _shaderProcessor: Nullable<IShaderProcessor>;
  39929. /**
  39930. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39931. */
  39932. forcePOTTextures: boolean;
  39933. /**
  39934. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39935. */
  39936. isFullscreen: boolean;
  39937. /**
  39938. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39939. */
  39940. cullBackFaces: boolean;
  39941. /**
  39942. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39943. */
  39944. renderEvenInBackground: boolean;
  39945. /**
  39946. * Gets or sets a boolean indicating that cache can be kept between frames
  39947. */
  39948. preventCacheWipeBetweenFrames: boolean;
  39949. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39950. validateShaderPrograms: boolean;
  39951. /**
  39952. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39953. * This can provide greater z depth for distant objects.
  39954. */
  39955. useReverseDepthBuffer: boolean;
  39956. /**
  39957. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39958. */
  39959. disableUniformBuffers: boolean;
  39960. private _frameId;
  39961. /**
  39962. * Gets the current frame id
  39963. */
  39964. get frameId(): number;
  39965. /** @hidden */
  39966. _uniformBuffers: UniformBuffer[];
  39967. /**
  39968. * Gets a boolean indicating that the engine supports uniform buffers
  39969. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39970. */
  39971. get supportsUniformBuffers(): boolean;
  39972. /** @hidden */
  39973. _gl: WebGLRenderingContext;
  39974. /** @hidden */
  39975. _webGLVersion: number;
  39976. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39977. protected _windowIsBackground: boolean;
  39978. protected _creationOptions: EngineOptions;
  39979. protected _highPrecisionShadersAllowed: boolean;
  39980. /** @hidden */
  39981. get _shouldUseHighPrecisionShader(): boolean;
  39982. /**
  39983. * Gets a boolean indicating that only power of 2 textures are supported
  39984. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  39985. */
  39986. get needPOTTextures(): boolean;
  39987. /** @hidden */
  39988. _badOS: boolean;
  39989. /** @hidden */
  39990. _badDesktopOS: boolean;
  39991. protected _hardwareScalingLevel: number;
  39992. /** @hidden */
  39993. _caps: EngineCapabilities;
  39994. /** @hidden */
  39995. _features: EngineFeatures;
  39996. protected _isStencilEnable: boolean;
  39997. private _glVersion;
  39998. private _glRenderer;
  39999. private _glVendor;
  40000. /** @hidden */
  40001. _videoTextureSupported: boolean;
  40002. protected _renderingQueueLaunched: boolean;
  40003. protected _activeRenderLoops: (() => void)[];
  40004. /**
  40005. * Observable signaled when a context lost event is raised
  40006. */
  40007. onContextLostObservable: Observable<ThinEngine>;
  40008. /**
  40009. * Observable signaled when a context restored event is raised
  40010. */
  40011. onContextRestoredObservable: Observable<ThinEngine>;
  40012. private _onContextLost;
  40013. private _onContextRestored;
  40014. protected _contextWasLost: boolean;
  40015. /** @hidden */
  40016. _doNotHandleContextLost: boolean;
  40017. /**
  40018. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40019. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40020. */
  40021. get doNotHandleContextLost(): boolean;
  40022. set doNotHandleContextLost(value: boolean);
  40023. /**
  40024. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40025. */
  40026. disableVertexArrayObjects: boolean;
  40027. /** @hidden */
  40028. protected _colorWrite: boolean;
  40029. /** @hidden */
  40030. protected _colorWriteChanged: boolean;
  40031. /** @hidden */
  40032. protected _depthCullingState: DepthCullingState;
  40033. /** @hidden */
  40034. protected _stencilState: StencilState;
  40035. /** @hidden */
  40036. _alphaState: AlphaState;
  40037. /** @hidden */
  40038. _alphaMode: number;
  40039. /** @hidden */
  40040. _alphaEquation: number;
  40041. /** @hidden */
  40042. _internalTexturesCache: InternalTexture[];
  40043. /** @hidden */
  40044. protected _activeChannel: number;
  40045. private _currentTextureChannel;
  40046. /** @hidden */
  40047. protected _boundTexturesCache: {
  40048. [key: string]: Nullable<InternalTexture>;
  40049. };
  40050. /** @hidden */
  40051. protected _currentEffect: Nullable<Effect>;
  40052. /** @hidden */
  40053. protected _currentProgram: Nullable<WebGLProgram>;
  40054. protected _compiledEffects: {
  40055. [key: string]: Effect;
  40056. };
  40057. private _vertexAttribArraysEnabled;
  40058. /** @hidden */
  40059. protected _cachedViewport: Nullable<IViewportLike>;
  40060. private _cachedVertexArrayObject;
  40061. /** @hidden */
  40062. protected _cachedVertexBuffers: any;
  40063. /** @hidden */
  40064. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40065. /** @hidden */
  40066. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40067. /** @hidden */
  40068. _currentRenderTarget: Nullable<InternalTexture>;
  40069. private _uintIndicesCurrentlySet;
  40070. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40071. /** @hidden */
  40072. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40073. /** @hidden */
  40074. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40075. private _currentBufferPointers;
  40076. private _currentInstanceLocations;
  40077. private _currentInstanceBuffers;
  40078. private _textureUnits;
  40079. /** @hidden */
  40080. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40081. /** @hidden */
  40082. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40083. /** @hidden */
  40084. _boundRenderFunction: any;
  40085. private _vaoRecordInProgress;
  40086. private _mustWipeVertexAttributes;
  40087. private _emptyTexture;
  40088. private _emptyCubeTexture;
  40089. private _emptyTexture3D;
  40090. private _emptyTexture2DArray;
  40091. /** @hidden */
  40092. _frameHandler: number;
  40093. private _nextFreeTextureSlots;
  40094. private _maxSimultaneousTextures;
  40095. private _activeRequests;
  40096. /** @hidden */
  40097. _transformTextureUrl: Nullable<(url: string) => string>;
  40098. /**
  40099. * Gets information about the current host
  40100. */
  40101. hostInformation: HostInformation;
  40102. protected get _supportsHardwareTextureRescaling(): boolean;
  40103. private _framebufferDimensionsObject;
  40104. /**
  40105. * sets the object from which width and height will be taken from when getting render width and height
  40106. * Will fallback to the gl object
  40107. * @param dimensions the framebuffer width and height that will be used.
  40108. */
  40109. set framebufferDimensionsObject(dimensions: Nullable<{
  40110. framebufferWidth: number;
  40111. framebufferHeight: number;
  40112. }>);
  40113. /**
  40114. * Gets the current viewport
  40115. */
  40116. get currentViewport(): Nullable<IViewportLike>;
  40117. /**
  40118. * Gets the default empty texture
  40119. */
  40120. get emptyTexture(): InternalTexture;
  40121. /**
  40122. * Gets the default empty 3D texture
  40123. */
  40124. get emptyTexture3D(): InternalTexture;
  40125. /**
  40126. * Gets the default empty 2D array texture
  40127. */
  40128. get emptyTexture2DArray(): InternalTexture;
  40129. /**
  40130. * Gets the default empty cube texture
  40131. */
  40132. get emptyCubeTexture(): InternalTexture;
  40133. /**
  40134. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40135. */
  40136. premultipliedAlpha: boolean;
  40137. /**
  40138. * Observable event triggered before each texture is initialized
  40139. */
  40140. onBeforeTextureInitObservable: Observable<Texture>;
  40141. /** @hidden */
  40142. protected _isWebGPU: boolean;
  40143. /**
  40144. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40145. */
  40146. get isWebGPU(): boolean;
  40147. /** @hidden */
  40148. protected _shaderPlatformName: string;
  40149. /**
  40150. * Gets the shader platfrom name used by the effects.
  40151. */
  40152. get shaderPlatformName(): string;
  40153. /**
  40154. * Creates a new engine
  40155. * @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
  40156. * @param antialias defines enable antialiasing (default: false)
  40157. * @param options defines further options to be sent to the getContext() function
  40158. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40159. */
  40160. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40161. /**
  40162. * @hidden
  40163. */
  40164. _debugPushGroup(groupName: string, targetObject?: number): void;
  40165. /**
  40166. * @hidden
  40167. */
  40168. _debugPopGroup(targetObject?: number): void;
  40169. /**
  40170. * @hidden
  40171. */
  40172. _debugInsertMarker(text: string, targetObject?: number): void;
  40173. /**
  40174. * Shared initialization across engines types.
  40175. * @param canvas The canvas associated with this instance of the engine.
  40176. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40177. * @param audioEngine Defines if an audio engine should be created by default
  40178. */
  40179. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40180. /**
  40181. * Gets a shader processor implementation fitting with the current engine type.
  40182. * @returns The shader processor implementation.
  40183. */
  40184. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40185. /** @hidden */
  40186. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40187. private _rebuildInternalTextures;
  40188. private _rebuildEffects;
  40189. /**
  40190. * Gets a boolean indicating if all created effects are ready
  40191. * @returns true if all effects are ready
  40192. */
  40193. areAllEffectsReady(): boolean;
  40194. protected _rebuildBuffers(): void;
  40195. protected _initGLContext(): void;
  40196. protected _initFeatures(): void;
  40197. /**
  40198. * Gets version of the current webGL context
  40199. * Keep it for back compat - use version instead
  40200. */
  40201. get webGLVersion(): number;
  40202. /**
  40203. * Gets a string identifying the name of the class
  40204. * @returns "Engine" string
  40205. */
  40206. getClassName(): string;
  40207. /**
  40208. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40209. */
  40210. get isStencilEnable(): boolean;
  40211. /** @hidden */
  40212. _prepareWorkingCanvas(): void;
  40213. /**
  40214. * Reset the texture cache to empty state
  40215. */
  40216. resetTextureCache(): void;
  40217. /**
  40218. * Gets an object containing information about the current webGL context
  40219. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40220. */
  40221. getGlInfo(): {
  40222. vendor: string;
  40223. renderer: string;
  40224. version: string;
  40225. };
  40226. /**
  40227. * Defines the hardware scaling level.
  40228. * By default the hardware scaling level is computed from the window device ratio.
  40229. * 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.
  40230. * @param level defines the level to use
  40231. */
  40232. setHardwareScalingLevel(level: number): void;
  40233. /**
  40234. * Gets the current hardware scaling level.
  40235. * By default the hardware scaling level is computed from the window device ratio.
  40236. * 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.
  40237. * @returns a number indicating the current hardware scaling level
  40238. */
  40239. getHardwareScalingLevel(): number;
  40240. /**
  40241. * Gets the list of loaded textures
  40242. * @returns an array containing all loaded textures
  40243. */
  40244. getLoadedTexturesCache(): InternalTexture[];
  40245. /**
  40246. * Gets the object containing all engine capabilities
  40247. * @returns the EngineCapabilities object
  40248. */
  40249. getCaps(): EngineCapabilities;
  40250. /**
  40251. * stop executing a render loop function and remove it from the execution array
  40252. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40253. */
  40254. stopRenderLoop(renderFunction?: () => void): void;
  40255. /** @hidden */
  40256. _renderLoop(): void;
  40257. /**
  40258. * Gets the HTML canvas attached with the current webGL context
  40259. * @returns a HTML canvas
  40260. */
  40261. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40262. /**
  40263. * Gets host window
  40264. * @returns the host window object
  40265. */
  40266. getHostWindow(): Nullable<Window>;
  40267. /**
  40268. * Gets the current render width
  40269. * @param useScreen defines if screen size must be used (or the current render target if any)
  40270. * @returns a number defining the current render width
  40271. */
  40272. getRenderWidth(useScreen?: boolean): number;
  40273. /**
  40274. * Gets the current render height
  40275. * @param useScreen defines if screen size must be used (or the current render target if any)
  40276. * @returns a number defining the current render height
  40277. */
  40278. getRenderHeight(useScreen?: boolean): number;
  40279. /**
  40280. * Can be used to override the current requestAnimationFrame requester.
  40281. * @hidden
  40282. */
  40283. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40284. /**
  40285. * Register and execute a render loop. The engine can have more than one render function
  40286. * @param renderFunction defines the function to continuously execute
  40287. */
  40288. runRenderLoop(renderFunction: () => void): void;
  40289. /**
  40290. * Clear the current render buffer or the current render target (if any is set up)
  40291. * @param color defines the color to use
  40292. * @param backBuffer defines if the back buffer must be cleared
  40293. * @param depth defines if the depth buffer must be cleared
  40294. * @param stencil defines if the stencil buffer must be cleared
  40295. */
  40296. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40297. protected _viewportCached: {
  40298. x: number;
  40299. y: number;
  40300. z: number;
  40301. w: number;
  40302. };
  40303. /** @hidden */
  40304. _viewport(x: number, y: number, width: number, height: number): void;
  40305. /**
  40306. * Set the WebGL's viewport
  40307. * @param viewport defines the viewport element to be used
  40308. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40309. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40310. */
  40311. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40312. /**
  40313. * Begin a new frame
  40314. */
  40315. beginFrame(): void;
  40316. /**
  40317. * Enf the current frame
  40318. */
  40319. endFrame(): void;
  40320. /**
  40321. * Resize the view according to the canvas' size
  40322. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40323. */
  40324. resize(forceSetSize?: boolean): void;
  40325. /**
  40326. * Force a specific size of the canvas
  40327. * @param width defines the new canvas' width
  40328. * @param height defines the new canvas' height
  40329. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40330. * @returns true if the size was changed
  40331. */
  40332. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40333. /**
  40334. * Binds the frame buffer to the specified texture.
  40335. * @param texture The texture to render to or null for the default canvas
  40336. * @param faceIndex The face of the texture to render to in case of cube texture
  40337. * @param requiredWidth The width of the target to render to
  40338. * @param requiredHeight The height of the target to render to
  40339. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40340. * @param lodLevel defines the lod level to bind to the frame buffer
  40341. * @param layer defines the 2d array index to bind to frame buffer to
  40342. */
  40343. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40344. /** @hidden */
  40345. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40346. /**
  40347. * Unbind the current render target texture from the webGL context
  40348. * @param texture defines the render target texture to unbind
  40349. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40350. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40351. */
  40352. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40353. /**
  40354. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40355. */
  40356. flushFramebuffer(): void;
  40357. /**
  40358. * Unbind the current render target and bind the default framebuffer
  40359. */
  40360. restoreDefaultFramebuffer(): void;
  40361. /** @hidden */
  40362. protected _resetVertexBufferBinding(): void;
  40363. /**
  40364. * Creates a vertex buffer
  40365. * @param data the data for the vertex buffer
  40366. * @returns the new WebGL static buffer
  40367. */
  40368. createVertexBuffer(data: DataArray): DataBuffer;
  40369. private _createVertexBuffer;
  40370. /**
  40371. * Creates a dynamic vertex buffer
  40372. * @param data the data for the dynamic vertex buffer
  40373. * @returns the new WebGL dynamic buffer
  40374. */
  40375. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40376. protected _resetIndexBufferBinding(): void;
  40377. /**
  40378. * Creates a new index buffer
  40379. * @param indices defines the content of the index buffer
  40380. * @param updatable defines if the index buffer must be updatable
  40381. * @returns a new webGL buffer
  40382. */
  40383. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40384. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40385. /**
  40386. * Bind a webGL buffer to the webGL context
  40387. * @param buffer defines the buffer to bind
  40388. */
  40389. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40390. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40391. private bindBuffer;
  40392. /**
  40393. * update the bound buffer with the given data
  40394. * @param data defines the data to update
  40395. */
  40396. updateArrayBuffer(data: Float32Array): void;
  40397. private _vertexAttribPointer;
  40398. /** @hidden */
  40399. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40400. private _bindVertexBuffersAttributes;
  40401. /**
  40402. * Records a vertex array object
  40403. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40404. * @param vertexBuffers defines the list of vertex buffers to store
  40405. * @param indexBuffer defines the index buffer to store
  40406. * @param effect defines the effect to store
  40407. * @returns the new vertex array object
  40408. */
  40409. recordVertexArrayObject(vertexBuffers: {
  40410. [key: string]: VertexBuffer;
  40411. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40412. /**
  40413. * Bind a specific vertex array object
  40414. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40415. * @param vertexArrayObject defines the vertex array object to bind
  40416. * @param indexBuffer defines the index buffer to bind
  40417. */
  40418. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40419. /**
  40420. * Bind webGl buffers directly to the webGL context
  40421. * @param vertexBuffer defines the vertex buffer to bind
  40422. * @param indexBuffer defines the index buffer to bind
  40423. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40424. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40425. * @param effect defines the effect associated with the vertex buffer
  40426. */
  40427. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40428. private _unbindVertexArrayObject;
  40429. /**
  40430. * Bind a list of vertex buffers to the webGL context
  40431. * @param vertexBuffers defines the list of vertex buffers to bind
  40432. * @param indexBuffer defines the index buffer to bind
  40433. * @param effect defines the effect associated with the vertex buffers
  40434. */
  40435. bindBuffers(vertexBuffers: {
  40436. [key: string]: Nullable<VertexBuffer>;
  40437. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40438. /**
  40439. * Unbind all instance attributes
  40440. */
  40441. unbindInstanceAttributes(): void;
  40442. /**
  40443. * Release and free the memory of a vertex array object
  40444. * @param vao defines the vertex array object to delete
  40445. */
  40446. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40447. /** @hidden */
  40448. _releaseBuffer(buffer: DataBuffer): boolean;
  40449. protected _deleteBuffer(buffer: DataBuffer): void;
  40450. /**
  40451. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40452. * @param instancesBuffer defines the webGL buffer to update and bind
  40453. * @param data defines the data to store in the buffer
  40454. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40455. */
  40456. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40457. /**
  40458. * Bind the content of a webGL buffer used with instantiation
  40459. * @param instancesBuffer defines the webGL buffer to bind
  40460. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40461. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40462. */
  40463. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40464. /**
  40465. * Disable the instance attribute corresponding to the name in parameter
  40466. * @param name defines the name of the attribute to disable
  40467. */
  40468. disableInstanceAttributeByName(name: string): void;
  40469. /**
  40470. * Disable the instance attribute corresponding to the location in parameter
  40471. * @param attributeLocation defines the attribute location of the attribute to disable
  40472. */
  40473. disableInstanceAttribute(attributeLocation: number): void;
  40474. /**
  40475. * Disable the attribute corresponding to the location in parameter
  40476. * @param attributeLocation defines the attribute location of the attribute to disable
  40477. */
  40478. disableAttributeByIndex(attributeLocation: number): void;
  40479. /**
  40480. * Send a draw order
  40481. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40482. * @param indexStart defines the starting index
  40483. * @param indexCount defines the number of index to draw
  40484. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40485. */
  40486. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40487. /**
  40488. * Draw a list of points
  40489. * @param verticesStart defines the index of first vertex to draw
  40490. * @param verticesCount defines the count of vertices to draw
  40491. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40492. */
  40493. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40494. /**
  40495. * Draw a list of unindexed primitives
  40496. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40497. * @param verticesStart defines the index of first vertex to draw
  40498. * @param verticesCount defines the count of vertices to draw
  40499. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40500. */
  40501. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40502. /**
  40503. * Draw a list of indexed primitives
  40504. * @param fillMode defines the primitive to use
  40505. * @param indexStart defines the starting index
  40506. * @param indexCount defines the number of index to draw
  40507. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40508. */
  40509. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40510. /**
  40511. * Draw a list of unindexed primitives
  40512. * @param fillMode defines the primitive to use
  40513. * @param verticesStart defines the index of first vertex to draw
  40514. * @param verticesCount defines the count of vertices to draw
  40515. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40516. */
  40517. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40518. private _drawMode;
  40519. /** @hidden */
  40520. protected _reportDrawCall(): void;
  40521. /** @hidden */
  40522. _releaseEffect(effect: Effect): void;
  40523. /** @hidden */
  40524. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40525. /**
  40526. * Create a new effect (used to store vertex/fragment shaders)
  40527. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40528. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40529. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40530. * @param samplers defines an array of string used to represent textures
  40531. * @param defines defines the string containing the defines to use to compile the shaders
  40532. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40533. * @param onCompiled defines a function to call when the effect creation is successful
  40534. * @param onError defines a function to call when the effect creation has failed
  40535. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40536. * @returns the new Effect
  40537. */
  40538. 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;
  40539. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40540. private _compileShader;
  40541. private _compileRawShader;
  40542. /** @hidden */
  40543. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40544. /**
  40545. * Directly creates a webGL program
  40546. * @param pipelineContext defines the pipeline context to attach to
  40547. * @param vertexCode defines the vertex shader code to use
  40548. * @param fragmentCode defines the fragment shader code to use
  40549. * @param context defines the webGL context to use (if not set, the current one will be used)
  40550. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40551. * @returns the new webGL program
  40552. */
  40553. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40554. /**
  40555. * Creates a webGL program
  40556. * @param pipelineContext defines the pipeline context to attach to
  40557. * @param vertexCode defines the vertex shader code to use
  40558. * @param fragmentCode defines the fragment shader code to use
  40559. * @param defines defines the string containing the defines to use to compile the shaders
  40560. * @param context defines the webGL context to use (if not set, the current one will be used)
  40561. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40562. * @returns the new webGL program
  40563. */
  40564. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40565. /**
  40566. * Creates a new pipeline context
  40567. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40568. * @returns the new pipeline
  40569. */
  40570. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40571. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40572. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40573. /** @hidden */
  40574. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40575. /** @hidden */
  40576. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40577. /** @hidden */
  40578. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40579. /**
  40580. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40581. * @param pipelineContext defines the pipeline context to use
  40582. * @param uniformsNames defines the list of uniform names
  40583. * @returns an array of webGL uniform locations
  40584. */
  40585. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40586. /**
  40587. * Gets the list of active attributes for a given webGL program
  40588. * @param pipelineContext defines the pipeline context to use
  40589. * @param attributesNames defines the list of attribute names to get
  40590. * @returns an array of indices indicating the offset of each attribute
  40591. */
  40592. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40593. /**
  40594. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40595. * @param effect defines the effect to activate
  40596. */
  40597. enableEffect(effect: Nullable<Effect>): void;
  40598. /**
  40599. * Set the value of an uniform to a number (int)
  40600. * @param uniform defines the webGL uniform location where to store the value
  40601. * @param value defines the int number to store
  40602. * @returns true if the value was set
  40603. */
  40604. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40605. /**
  40606. * Set the value of an uniform to a int2
  40607. * @param uniform defines the webGL uniform location where to store the value
  40608. * @param x defines the 1st component of the value
  40609. * @param y defines the 2nd component of the value
  40610. * @returns true if the value was set
  40611. */
  40612. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40613. /**
  40614. * Set the value of an uniform to a int3
  40615. * @param uniform defines the webGL uniform location where to store the value
  40616. * @param x defines the 1st component of the value
  40617. * @param y defines the 2nd component of the value
  40618. * @param z defines the 3rd component of the value
  40619. * @returns true if the value was set
  40620. */
  40621. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40622. /**
  40623. * Set the value of an uniform to a int4
  40624. * @param uniform defines the webGL uniform location where to store the value
  40625. * @param x defines the 1st component of the value
  40626. * @param y defines the 2nd component of the value
  40627. * @param z defines the 3rd component of the value
  40628. * @param w defines the 4th component of the value
  40629. * @returns true if the value was set
  40630. */
  40631. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40632. /**
  40633. * Set the value of an uniform to an array of int32
  40634. * @param uniform defines the webGL uniform location where to store the value
  40635. * @param array defines the array of int32 to store
  40636. * @returns true if the value was set
  40637. */
  40638. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40639. /**
  40640. * Set the value of an uniform to an array of int32 (stored as vec2)
  40641. * @param uniform defines the webGL uniform location where to store the value
  40642. * @param array defines the array of int32 to store
  40643. * @returns true if the value was set
  40644. */
  40645. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40646. /**
  40647. * Set the value of an uniform to an array of int32 (stored as vec3)
  40648. * @param uniform defines the webGL uniform location where to store the value
  40649. * @param array defines the array of int32 to store
  40650. * @returns true if the value was set
  40651. */
  40652. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40653. /**
  40654. * Set the value of an uniform to an array of int32 (stored as vec4)
  40655. * @param uniform defines the webGL uniform location where to store the value
  40656. * @param array defines the array of int32 to store
  40657. * @returns true if the value was set
  40658. */
  40659. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40660. /**
  40661. * Set the value of an uniform to an array of number
  40662. * @param uniform defines the webGL uniform location where to store the value
  40663. * @param array defines the array of number to store
  40664. * @returns true if the value was set
  40665. */
  40666. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40667. /**
  40668. * Set the value of an uniform to an array of number (stored as vec2)
  40669. * @param uniform defines the webGL uniform location where to store the value
  40670. * @param array defines the array of number to store
  40671. * @returns true if the value was set
  40672. */
  40673. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40674. /**
  40675. * Set the value of an uniform to an array of number (stored as vec3)
  40676. * @param uniform defines the webGL uniform location where to store the value
  40677. * @param array defines the array of number to store
  40678. * @returns true if the value was set
  40679. */
  40680. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40681. /**
  40682. * Set the value of an uniform to an array of number (stored as vec4)
  40683. * @param uniform defines the webGL uniform location where to store the value
  40684. * @param array defines the array of number to store
  40685. * @returns true if the value was set
  40686. */
  40687. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40688. /**
  40689. * Set the value of an uniform to an array of float32 (stored as matrices)
  40690. * @param uniform defines the webGL uniform location where to store the value
  40691. * @param matrices defines the array of float32 to store
  40692. * @returns true if the value was set
  40693. */
  40694. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40695. /**
  40696. * Set the value of an uniform to a matrix (3x3)
  40697. * @param uniform defines the webGL uniform location where to store the value
  40698. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40699. * @returns true if the value was set
  40700. */
  40701. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40702. /**
  40703. * Set the value of an uniform to a matrix (2x2)
  40704. * @param uniform defines the webGL uniform location where to store the value
  40705. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40706. * @returns true if the value was set
  40707. */
  40708. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40709. /**
  40710. * Set the value of an uniform to a number (float)
  40711. * @param uniform defines the webGL uniform location where to store the value
  40712. * @param value defines the float number to store
  40713. * @returns true if the value was transfered
  40714. */
  40715. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40716. /**
  40717. * Set the value of an uniform to a vec2
  40718. * @param uniform defines the webGL uniform location where to store the value
  40719. * @param x defines the 1st component of the value
  40720. * @param y defines the 2nd component of the value
  40721. * @returns true if the value was set
  40722. */
  40723. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40724. /**
  40725. * Set the value of an uniform to a vec3
  40726. * @param uniform defines the webGL uniform location where to store the value
  40727. * @param x defines the 1st component of the value
  40728. * @param y defines the 2nd component of the value
  40729. * @param z defines the 3rd component of the value
  40730. * @returns true if the value was set
  40731. */
  40732. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40733. /**
  40734. * Set the value of an uniform to a vec4
  40735. * @param uniform defines the webGL uniform location where to store the value
  40736. * @param x defines the 1st component of the value
  40737. * @param y defines the 2nd component of the value
  40738. * @param z defines the 3rd component of the value
  40739. * @param w defines the 4th component of the value
  40740. * @returns true if the value was set
  40741. */
  40742. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40743. /**
  40744. * Apply all cached states (depth, culling, stencil and alpha)
  40745. */
  40746. applyStates(): void;
  40747. /**
  40748. * Enable or disable color writing
  40749. * @param enable defines the state to set
  40750. */
  40751. setColorWrite(enable: boolean): void;
  40752. /**
  40753. * Gets a boolean indicating if color writing is enabled
  40754. * @returns the current color writing state
  40755. */
  40756. getColorWrite(): boolean;
  40757. /**
  40758. * Gets the depth culling state manager
  40759. */
  40760. get depthCullingState(): DepthCullingState;
  40761. /**
  40762. * Gets the alpha state manager
  40763. */
  40764. get alphaState(): AlphaState;
  40765. /**
  40766. * Gets the stencil state manager
  40767. */
  40768. get stencilState(): StencilState;
  40769. /**
  40770. * Clears the list of texture accessible through engine.
  40771. * This can help preventing texture load conflict due to name collision.
  40772. */
  40773. clearInternalTexturesCache(): void;
  40774. /**
  40775. * Force the entire cache to be cleared
  40776. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40777. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40778. */
  40779. wipeCaches(bruteForce?: boolean): void;
  40780. /** @hidden */
  40781. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40782. min: number;
  40783. mag: number;
  40784. };
  40785. /** @hidden */
  40786. protected _createTexture(): WebGLTexture;
  40787. /** @hidden */
  40788. _createHardwareTexture(): HardwareTextureWrapper;
  40789. 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 | {
  40790. width: number;
  40791. height: number;
  40792. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40793. width: number;
  40794. height: number;
  40795. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40796. width: number;
  40797. height: number;
  40798. }, 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;
  40799. /**
  40800. * Usually called from Texture.ts.
  40801. * Passed information to create a WebGLTexture
  40802. * @param url defines a value which contains one of the following:
  40803. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40804. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40805. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40806. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40807. * @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)
  40808. * @param scene needed for loading to the correct scene
  40809. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40810. * @param onLoad optional callback to be called upon successful completion
  40811. * @param onError optional callback to be called upon failure
  40812. * @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
  40813. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40814. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40815. * @param forcedExtension defines the extension to use to pick the right loader
  40816. * @param mimeType defines an optional mime type
  40817. * @param loaderOptions options to be passed to the loader
  40818. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40819. */
  40820. 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;
  40821. /**
  40822. * Loads an image as an HTMLImageElement.
  40823. * @param input url string, ArrayBuffer, or Blob to load
  40824. * @param onLoad callback called when the image successfully loads
  40825. * @param onError callback called when the image fails to load
  40826. * @param offlineProvider offline provider for caching
  40827. * @param mimeType optional mime type
  40828. * @returns the HTMLImageElement of the loaded image
  40829. * @hidden
  40830. */
  40831. 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>;
  40832. /**
  40833. * @hidden
  40834. */
  40835. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40836. private _unpackFlipYCached;
  40837. /**
  40838. * In case you are sharing the context with other applications, it might
  40839. * be interested to not cache the unpack flip y state to ensure a consistent
  40840. * value would be set.
  40841. */
  40842. enableUnpackFlipYCached: boolean;
  40843. /** @hidden */
  40844. _unpackFlipY(value: boolean): void;
  40845. /** @hidden */
  40846. _getUnpackAlignement(): number;
  40847. private _getTextureTarget;
  40848. /**
  40849. * Update the sampling mode of a given texture
  40850. * @param samplingMode defines the required sampling mode
  40851. * @param texture defines the texture to update
  40852. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40853. */
  40854. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40855. /**
  40856. * Update the dimensions of a texture
  40857. * @param texture texture to update
  40858. * @param width new width of the texture
  40859. * @param height new height of the texture
  40860. * @param depth new depth of the texture
  40861. */
  40862. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  40863. /**
  40864. * Update the sampling mode of a given texture
  40865. * @param texture defines the texture to update
  40866. * @param wrapU defines the texture wrap mode of the u coordinates
  40867. * @param wrapV defines the texture wrap mode of the v coordinates
  40868. * @param wrapR defines the texture wrap mode of the r coordinates
  40869. */
  40870. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40871. /** @hidden */
  40872. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40873. width: number;
  40874. height: number;
  40875. layers?: number;
  40876. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  40877. /** @hidden */
  40878. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40879. /** @hidden */
  40880. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40881. /**
  40882. * Update a portion of an internal texture
  40883. * @param texture defines the texture to update
  40884. * @param imageData defines the data to store into the texture
  40885. * @param xOffset defines the x coordinates of the update rectangle
  40886. * @param yOffset defines the y coordinates of the update rectangle
  40887. * @param width defines the width of the update rectangle
  40888. * @param height defines the height of the update rectangle
  40889. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40890. * @param lod defines the lod level to update (0 by default)
  40891. */
  40892. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40893. /** @hidden */
  40894. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40895. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40896. private _prepareWebGLTexture;
  40897. /** @hidden */
  40898. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40899. private _getDepthStencilBuffer;
  40900. /** @hidden */
  40901. _releaseFramebufferObjects(texture: InternalTexture): void;
  40902. /** @hidden */
  40903. _releaseTexture(texture: InternalTexture): void;
  40904. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40905. protected _setProgram(program: WebGLProgram): void;
  40906. protected _boundUniforms: {
  40907. [key: number]: WebGLUniformLocation;
  40908. };
  40909. /**
  40910. * Binds an effect to the webGL context
  40911. * @param effect defines the effect to bind
  40912. */
  40913. bindSamplers(effect: Effect): void;
  40914. private _activateCurrentTexture;
  40915. /** @hidden */
  40916. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40917. /** @hidden */
  40918. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  40919. /**
  40920. * Unbind all textures from the webGL context
  40921. */
  40922. unbindAllTextures(): void;
  40923. /**
  40924. * Sets a texture to the according uniform.
  40925. * @param channel The texture channel
  40926. * @param uniform The uniform to set
  40927. * @param texture The texture to apply
  40928. * @param name The name of the uniform in the effect
  40929. */
  40930. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  40931. private _bindSamplerUniformToChannel;
  40932. private _getTextureWrapMode;
  40933. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  40934. /**
  40935. * Sets an array of texture to the webGL context
  40936. * @param channel defines the channel where the texture array must be set
  40937. * @param uniform defines the associated uniform location
  40938. * @param textures defines the array of textures to bind
  40939. * @param name name of the channel
  40940. */
  40941. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  40942. /** @hidden */
  40943. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40944. private _setTextureParameterFloat;
  40945. private _setTextureParameterInteger;
  40946. /**
  40947. * Unbind all vertex attributes from the webGL context
  40948. */
  40949. unbindAllAttributes(): void;
  40950. /**
  40951. * 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
  40952. */
  40953. releaseEffects(): void;
  40954. /**
  40955. * Dispose and release all associated resources
  40956. */
  40957. dispose(): void;
  40958. /**
  40959. * Attach a new callback raised when context lost event is fired
  40960. * @param callback defines the callback to call
  40961. */
  40962. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40963. /**
  40964. * Attach a new callback raised when context restored event is fired
  40965. * @param callback defines the callback to call
  40966. */
  40967. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40968. /**
  40969. * Get the current error code of the webGL context
  40970. * @returns the error code
  40971. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40972. */
  40973. getError(): number;
  40974. private _canRenderToFloatFramebuffer;
  40975. private _canRenderToHalfFloatFramebuffer;
  40976. private _canRenderToFramebuffer;
  40977. /** @hidden */
  40978. _getWebGLTextureType(type: number): number;
  40979. /** @hidden */
  40980. _getInternalFormat(format: number): number;
  40981. /** @hidden */
  40982. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  40983. /** @hidden */
  40984. _getRGBAMultiSampleBufferFormat(type: number): number;
  40985. /** @hidden */
  40986. _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;
  40987. /**
  40988. * Loads a file from a url
  40989. * @param url url to load
  40990. * @param onSuccess callback called when the file successfully loads
  40991. * @param onProgress callback called while file is loading (if the server supports this mode)
  40992. * @param offlineProvider defines the offline provider for caching
  40993. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  40994. * @param onError callback called when the file fails to load
  40995. * @returns a file request object
  40996. * @hidden
  40997. */
  40998. 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;
  40999. /**
  41000. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41001. * @param x defines the x coordinate of the rectangle where pixels must be read
  41002. * @param y defines the y coordinate of the rectangle where pixels must be read
  41003. * @param width defines the width of the rectangle where pixels must be read
  41004. * @param height defines the height of the rectangle where pixels must be read
  41005. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41006. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41007. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41008. */
  41009. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41010. private static _IsSupported;
  41011. private static _HasMajorPerformanceCaveat;
  41012. /**
  41013. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41014. */
  41015. static get IsSupported(): boolean;
  41016. /**
  41017. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41018. * @returns true if the engine can be created
  41019. * @ignorenaming
  41020. */
  41021. static isSupported(): boolean;
  41022. /**
  41023. * 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)
  41024. */
  41025. static get HasMajorPerformanceCaveat(): boolean;
  41026. /**
  41027. * Find the next highest power of two.
  41028. * @param x Number to start search from.
  41029. * @return Next highest power of two.
  41030. */
  41031. static CeilingPOT(x: number): number;
  41032. /**
  41033. * Find the next lowest power of two.
  41034. * @param x Number to start search from.
  41035. * @return Next lowest power of two.
  41036. */
  41037. static FloorPOT(x: number): number;
  41038. /**
  41039. * Find the nearest power of two.
  41040. * @param x Number to start search from.
  41041. * @return Next nearest power of two.
  41042. */
  41043. static NearestPOT(x: number): number;
  41044. /**
  41045. * Get the closest exponent of two
  41046. * @param value defines the value to approximate
  41047. * @param max defines the maximum value to return
  41048. * @param mode defines how to define the closest value
  41049. * @returns closest exponent of two of the given value
  41050. */
  41051. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41052. /**
  41053. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41054. * @param func - the function to be called
  41055. * @param requester - the object that will request the next frame. Falls back to window.
  41056. * @returns frame number
  41057. */
  41058. static QueueNewFrame(func: () => void, requester?: any): number;
  41059. /**
  41060. * Gets host document
  41061. * @returns the host document object
  41062. */
  41063. getHostDocument(): Nullable<Document>;
  41064. }
  41065. }
  41066. declare module BABYLON {
  41067. /**
  41068. * Defines the source of the internal texture
  41069. */
  41070. export enum InternalTextureSource {
  41071. /**
  41072. * The source of the texture data is unknown
  41073. */
  41074. Unknown = 0,
  41075. /**
  41076. * Texture data comes from an URL
  41077. */
  41078. Url = 1,
  41079. /**
  41080. * Texture data is only used for temporary storage
  41081. */
  41082. Temp = 2,
  41083. /**
  41084. * Texture data comes from raw data (ArrayBuffer)
  41085. */
  41086. Raw = 3,
  41087. /**
  41088. * Texture content is dynamic (video or dynamic texture)
  41089. */
  41090. Dynamic = 4,
  41091. /**
  41092. * Texture content is generated by rendering to it
  41093. */
  41094. RenderTarget = 5,
  41095. /**
  41096. * Texture content is part of a multi render target process
  41097. */
  41098. MultiRenderTarget = 6,
  41099. /**
  41100. * Texture data comes from a cube data file
  41101. */
  41102. Cube = 7,
  41103. /**
  41104. * Texture data comes from a raw cube data
  41105. */
  41106. CubeRaw = 8,
  41107. /**
  41108. * Texture data come from a prefiltered cube data file
  41109. */
  41110. CubePrefiltered = 9,
  41111. /**
  41112. * Texture content is raw 3D data
  41113. */
  41114. Raw3D = 10,
  41115. /**
  41116. * Texture content is raw 2D array data
  41117. */
  41118. Raw2DArray = 11,
  41119. /**
  41120. * Texture content is a depth texture
  41121. */
  41122. Depth = 12,
  41123. /**
  41124. * Texture data comes from a raw cube data encoded with RGBD
  41125. */
  41126. CubeRawRGBD = 13
  41127. }
  41128. /**
  41129. * Class used to store data associated with WebGL texture data for the engine
  41130. * This class should not be used directly
  41131. */
  41132. export class InternalTexture {
  41133. /** @hidden */
  41134. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41135. /**
  41136. * Defines if the texture is ready
  41137. */
  41138. isReady: boolean;
  41139. /**
  41140. * Defines if the texture is a cube texture
  41141. */
  41142. isCube: boolean;
  41143. /**
  41144. * Defines if the texture contains 3D data
  41145. */
  41146. is3D: boolean;
  41147. /**
  41148. * Defines if the texture contains 2D array data
  41149. */
  41150. is2DArray: boolean;
  41151. /**
  41152. * Defines if the texture contains multiview data
  41153. */
  41154. isMultiview: boolean;
  41155. /**
  41156. * Gets the URL used to load this texture
  41157. */
  41158. url: string;
  41159. /** @hidden */
  41160. _originalUrl: string;
  41161. /**
  41162. * Gets the sampling mode of the texture
  41163. */
  41164. samplingMode: number;
  41165. /**
  41166. * Gets a boolean indicating if the texture needs mipmaps generation
  41167. */
  41168. generateMipMaps: boolean;
  41169. /**
  41170. * Gets the number of samples used by the texture (WebGL2+ only)
  41171. */
  41172. samples: number;
  41173. /**
  41174. * Gets the type of the texture (int, float...)
  41175. */
  41176. type: number;
  41177. /**
  41178. * Gets the format of the texture (RGB, RGBA...)
  41179. */
  41180. format: number;
  41181. /**
  41182. * Observable called when the texture is loaded
  41183. */
  41184. onLoadedObservable: Observable<InternalTexture>;
  41185. /**
  41186. * Gets the width of the texture
  41187. */
  41188. width: number;
  41189. /**
  41190. * Gets the height of the texture
  41191. */
  41192. height: number;
  41193. /**
  41194. * Gets the depth of the texture
  41195. */
  41196. depth: number;
  41197. /**
  41198. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41199. */
  41200. baseWidth: number;
  41201. /**
  41202. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41203. */
  41204. baseHeight: number;
  41205. /**
  41206. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41207. */
  41208. baseDepth: number;
  41209. /**
  41210. * Gets a boolean indicating if the texture is inverted on Y axis
  41211. */
  41212. invertY: boolean;
  41213. /** @hidden */
  41214. _invertVScale: boolean;
  41215. /** @hidden */
  41216. _associatedChannel: number;
  41217. /** @hidden */
  41218. _source: InternalTextureSource;
  41219. /** @hidden */
  41220. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41221. /** @hidden */
  41222. _bufferView: Nullable<ArrayBufferView>;
  41223. /** @hidden */
  41224. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41225. /** @hidden */
  41226. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41227. /** @hidden */
  41228. _size: number;
  41229. /** @hidden */
  41230. _extension: string;
  41231. /** @hidden */
  41232. _files: Nullable<string[]>;
  41233. /** @hidden */
  41234. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41235. /** @hidden */
  41236. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41237. /** @hidden */
  41238. _framebuffer: Nullable<WebGLFramebuffer>;
  41239. /** @hidden */
  41240. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41241. /** @hidden */
  41242. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41243. /** @hidden */
  41244. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41245. /** @hidden */
  41246. _attachments: Nullable<number[]>;
  41247. /** @hidden */
  41248. _textureArray: Nullable<InternalTexture[]>;
  41249. /** @hidden */
  41250. _cachedCoordinatesMode: Nullable<number>;
  41251. /** @hidden */
  41252. _cachedWrapU: Nullable<number>;
  41253. /** @hidden */
  41254. _cachedWrapV: Nullable<number>;
  41255. /** @hidden */
  41256. _cachedWrapR: Nullable<number>;
  41257. /** @hidden */
  41258. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41259. /** @hidden */
  41260. _isDisabled: boolean;
  41261. /** @hidden */
  41262. _compression: Nullable<string>;
  41263. /** @hidden */
  41264. _generateStencilBuffer: boolean;
  41265. /** @hidden */
  41266. _generateDepthBuffer: boolean;
  41267. /** @hidden */
  41268. _comparisonFunction: number;
  41269. /** @hidden */
  41270. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41271. /** @hidden */
  41272. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41273. /** @hidden */
  41274. _sphericalPolynomialComputed: boolean;
  41275. /** @hidden */
  41276. _lodGenerationScale: number;
  41277. /** @hidden */
  41278. _lodGenerationOffset: number;
  41279. /** @hidden */
  41280. _depthStencilTexture: Nullable<InternalTexture>;
  41281. /** @hidden */
  41282. _colorTextureArray: Nullable<WebGLTexture>;
  41283. /** @hidden */
  41284. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41285. /** @hidden */
  41286. _lodTextureHigh: Nullable<BaseTexture>;
  41287. /** @hidden */
  41288. _lodTextureMid: Nullable<BaseTexture>;
  41289. /** @hidden */
  41290. _lodTextureLow: Nullable<BaseTexture>;
  41291. /** @hidden */
  41292. _isRGBD: boolean;
  41293. /** @hidden */
  41294. _linearSpecularLOD: boolean;
  41295. /** @hidden */
  41296. _irradianceTexture: Nullable<BaseTexture>;
  41297. /** @hidden */
  41298. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41299. /** @hidden */
  41300. _references: number;
  41301. /** @hidden */
  41302. _gammaSpace: Nullable<boolean>;
  41303. /** @hidden */
  41304. _hasAlpha: Nullable<boolean>;
  41305. private _engine;
  41306. private _uniqueId;
  41307. private static _Counter;
  41308. /** Gets the unique id of the internal texture */
  41309. get uniqueId(): number;
  41310. /**
  41311. * Gets the Engine the texture belongs to.
  41312. * @returns The babylon engine
  41313. */
  41314. getEngine(): ThinEngine;
  41315. /**
  41316. * Gets the data source type of the texture
  41317. */
  41318. get source(): InternalTextureSource;
  41319. /**
  41320. * Creates a new InternalTexture
  41321. * @param engine defines the engine to use
  41322. * @param source defines the type of data that will be used
  41323. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41324. */
  41325. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41326. /**
  41327. * Increments the number of references (ie. the number of Texture that point to it)
  41328. */
  41329. incrementReferences(): void;
  41330. /**
  41331. * Change the size of the texture (not the size of the content)
  41332. * @param width defines the new width
  41333. * @param height defines the new height
  41334. * @param depth defines the new depth (1 by default)
  41335. */
  41336. updateSize(width: int, height: int, depth?: int): void;
  41337. /** @hidden */
  41338. _rebuild(): void;
  41339. /** @hidden */
  41340. _swapAndDie(target: InternalTexture): void;
  41341. /**
  41342. * Dispose the current allocated resources
  41343. */
  41344. dispose(): void;
  41345. }
  41346. }
  41347. declare module BABYLON {
  41348. /**
  41349. * Interface used to present a loading screen while loading a scene
  41350. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41351. */
  41352. export interface ILoadingScreen {
  41353. /**
  41354. * Function called to display the loading screen
  41355. */
  41356. displayLoadingUI: () => void;
  41357. /**
  41358. * Function called to hide the loading screen
  41359. */
  41360. hideLoadingUI: () => void;
  41361. /**
  41362. * Gets or sets the color to use for the background
  41363. */
  41364. loadingUIBackgroundColor: string;
  41365. /**
  41366. * Gets or sets the text to display while loading
  41367. */
  41368. loadingUIText: string;
  41369. }
  41370. /**
  41371. * Class used for the default loading screen
  41372. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41373. */
  41374. export class DefaultLoadingScreen implements ILoadingScreen {
  41375. private _renderingCanvas;
  41376. private _loadingText;
  41377. private _loadingDivBackgroundColor;
  41378. private _loadingDiv;
  41379. private _loadingTextDiv;
  41380. /** Gets or sets the logo url to use for the default loading screen */
  41381. static DefaultLogoUrl: string;
  41382. /** Gets or sets the spinner url to use for the default loading screen */
  41383. static DefaultSpinnerUrl: string;
  41384. /**
  41385. * Creates a new default loading screen
  41386. * @param _renderingCanvas defines the canvas used to render the scene
  41387. * @param _loadingText defines the default text to display
  41388. * @param _loadingDivBackgroundColor defines the default background color
  41389. */
  41390. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41391. /**
  41392. * Function called to display the loading screen
  41393. */
  41394. displayLoadingUI(): void;
  41395. /**
  41396. * Function called to hide the loading screen
  41397. */
  41398. hideLoadingUI(): void;
  41399. /**
  41400. * Gets or sets the text to display while loading
  41401. */
  41402. set loadingUIText(text: string);
  41403. get loadingUIText(): string;
  41404. /**
  41405. * Gets or sets the color to use for the background
  41406. */
  41407. get loadingUIBackgroundColor(): string;
  41408. set loadingUIBackgroundColor(color: string);
  41409. private _resizeLoadingUI;
  41410. }
  41411. }
  41412. declare module BABYLON {
  41413. /**
  41414. * Interface for any object that can request an animation frame
  41415. */
  41416. export interface ICustomAnimationFrameRequester {
  41417. /**
  41418. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41419. */
  41420. renderFunction?: Function;
  41421. /**
  41422. * Called to request the next frame to render to
  41423. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41424. */
  41425. requestAnimationFrame: Function;
  41426. /**
  41427. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41428. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41429. */
  41430. requestID?: number;
  41431. }
  41432. }
  41433. declare module BABYLON {
  41434. /**
  41435. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41436. */
  41437. export class PerformanceMonitor {
  41438. private _enabled;
  41439. private _rollingFrameTime;
  41440. private _lastFrameTimeMs;
  41441. /**
  41442. * constructor
  41443. * @param frameSampleSize The number of samples required to saturate the sliding window
  41444. */
  41445. constructor(frameSampleSize?: number);
  41446. /**
  41447. * Samples current frame
  41448. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41449. */
  41450. sampleFrame(timeMs?: number): void;
  41451. /**
  41452. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41453. */
  41454. get averageFrameTime(): number;
  41455. /**
  41456. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41457. */
  41458. get averageFrameTimeVariance(): number;
  41459. /**
  41460. * Returns the frame time of the most recent frame
  41461. */
  41462. get instantaneousFrameTime(): number;
  41463. /**
  41464. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41465. */
  41466. get averageFPS(): number;
  41467. /**
  41468. * Returns the average framerate in frames per second using the most recent frame time
  41469. */
  41470. get instantaneousFPS(): number;
  41471. /**
  41472. * Returns true if enough samples have been taken to completely fill the sliding window
  41473. */
  41474. get isSaturated(): boolean;
  41475. /**
  41476. * Enables contributions to the sliding window sample set
  41477. */
  41478. enable(): void;
  41479. /**
  41480. * Disables contributions to the sliding window sample set
  41481. * Samples will not be interpolated over the disabled period
  41482. */
  41483. disable(): void;
  41484. /**
  41485. * Returns true if sampling is enabled
  41486. */
  41487. get isEnabled(): boolean;
  41488. /**
  41489. * Resets performance monitor
  41490. */
  41491. reset(): void;
  41492. }
  41493. /**
  41494. * RollingAverage
  41495. *
  41496. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41497. */
  41498. export class RollingAverage {
  41499. /**
  41500. * Current average
  41501. */
  41502. average: number;
  41503. /**
  41504. * Current variance
  41505. */
  41506. variance: number;
  41507. protected _samples: Array<number>;
  41508. protected _sampleCount: number;
  41509. protected _pos: number;
  41510. protected _m2: number;
  41511. /**
  41512. * constructor
  41513. * @param length The number of samples required to saturate the sliding window
  41514. */
  41515. constructor(length: number);
  41516. /**
  41517. * Adds a sample to the sample set
  41518. * @param v The sample value
  41519. */
  41520. add(v: number): void;
  41521. /**
  41522. * Returns previously added values or null if outside of history or outside the sliding window domain
  41523. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41524. * @return Value previously recorded with add() or null if outside of range
  41525. */
  41526. history(i: number): number;
  41527. /**
  41528. * Returns true if enough samples have been taken to completely fill the sliding window
  41529. * @return true if sample-set saturated
  41530. */
  41531. isSaturated(): boolean;
  41532. /**
  41533. * Resets the rolling average (equivalent to 0 samples taken so far)
  41534. */
  41535. reset(): void;
  41536. /**
  41537. * Wraps a value around the sample range boundaries
  41538. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41539. * @return Wrapped position in sample range
  41540. */
  41541. protected _wrapPosition(i: number): number;
  41542. }
  41543. }
  41544. declare module BABYLON {
  41545. /**
  41546. * This class is used to track a performance counter which is number based.
  41547. * The user has access to many properties which give statistics of different nature.
  41548. *
  41549. * The implementer can track two kinds of Performance Counter: time and count.
  41550. * 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.
  41551. * 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.
  41552. */
  41553. export class PerfCounter {
  41554. /**
  41555. * Gets or sets a global boolean to turn on and off all the counters
  41556. */
  41557. static Enabled: boolean;
  41558. /**
  41559. * Returns the smallest value ever
  41560. */
  41561. get min(): number;
  41562. /**
  41563. * Returns the biggest value ever
  41564. */
  41565. get max(): number;
  41566. /**
  41567. * Returns the average value since the performance counter is running
  41568. */
  41569. get average(): number;
  41570. /**
  41571. * Returns the average value of the last second the counter was monitored
  41572. */
  41573. get lastSecAverage(): number;
  41574. /**
  41575. * Returns the current value
  41576. */
  41577. get current(): number;
  41578. /**
  41579. * Gets the accumulated total
  41580. */
  41581. get total(): number;
  41582. /**
  41583. * Gets the total value count
  41584. */
  41585. get count(): number;
  41586. /**
  41587. * Creates a new counter
  41588. */
  41589. constructor();
  41590. /**
  41591. * Call this method to start monitoring a new frame.
  41592. * 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.
  41593. */
  41594. fetchNewFrame(): void;
  41595. /**
  41596. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41597. * @param newCount the count value to add to the monitored count
  41598. * @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.
  41599. */
  41600. addCount(newCount: number, fetchResult: boolean): void;
  41601. /**
  41602. * Start monitoring this performance counter
  41603. */
  41604. beginMonitoring(): void;
  41605. /**
  41606. * Compute the time lapsed since the previous beginMonitoring() call.
  41607. * @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
  41608. */
  41609. endMonitoring(newFrame?: boolean): void;
  41610. private _fetchResult;
  41611. private _startMonitoringTime;
  41612. private _min;
  41613. private _max;
  41614. private _average;
  41615. private _current;
  41616. private _totalValueCount;
  41617. private _totalAccumulated;
  41618. private _lastSecAverage;
  41619. private _lastSecAccumulated;
  41620. private _lastSecTime;
  41621. private _lastSecValueCount;
  41622. }
  41623. }
  41624. declare module BABYLON {
  41625. interface ThinEngine {
  41626. /** @hidden */
  41627. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41628. }
  41629. }
  41630. declare module BABYLON {
  41631. /**
  41632. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41633. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41634. */
  41635. export class Analyser {
  41636. /**
  41637. * Gets or sets the smoothing
  41638. * @ignorenaming
  41639. */
  41640. SMOOTHING: number;
  41641. /**
  41642. * Gets or sets the FFT table size
  41643. * @ignorenaming
  41644. */
  41645. FFT_SIZE: number;
  41646. /**
  41647. * Gets or sets the bar graph amplitude
  41648. * @ignorenaming
  41649. */
  41650. BARGRAPHAMPLITUDE: number;
  41651. /**
  41652. * Gets or sets the position of the debug canvas
  41653. * @ignorenaming
  41654. */
  41655. DEBUGCANVASPOS: {
  41656. x: number;
  41657. y: number;
  41658. };
  41659. /**
  41660. * Gets or sets the debug canvas size
  41661. * @ignorenaming
  41662. */
  41663. DEBUGCANVASSIZE: {
  41664. width: number;
  41665. height: number;
  41666. };
  41667. private _byteFreqs;
  41668. private _byteTime;
  41669. private _floatFreqs;
  41670. private _webAudioAnalyser;
  41671. private _debugCanvas;
  41672. private _debugCanvasContext;
  41673. private _scene;
  41674. private _registerFunc;
  41675. private _audioEngine;
  41676. /**
  41677. * Creates a new analyser
  41678. * @param scene defines hosting scene
  41679. */
  41680. constructor(scene: Scene);
  41681. /**
  41682. * Get the number of data values you will have to play with for the visualization
  41683. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41684. * @returns a number
  41685. */
  41686. getFrequencyBinCount(): number;
  41687. /**
  41688. * Gets the current frequency data as a byte array
  41689. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41690. * @returns a Uint8Array
  41691. */
  41692. getByteFrequencyData(): Uint8Array;
  41693. /**
  41694. * Gets the current waveform as a byte array
  41695. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41696. * @returns a Uint8Array
  41697. */
  41698. getByteTimeDomainData(): Uint8Array;
  41699. /**
  41700. * Gets the current frequency data as a float array
  41701. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41702. * @returns a Float32Array
  41703. */
  41704. getFloatFrequencyData(): Float32Array;
  41705. /**
  41706. * Renders the debug canvas
  41707. */
  41708. drawDebugCanvas(): void;
  41709. /**
  41710. * Stops rendering the debug canvas and removes it
  41711. */
  41712. stopDebugCanvas(): void;
  41713. /**
  41714. * Connects two audio nodes
  41715. * @param inputAudioNode defines first node to connect
  41716. * @param outputAudioNode defines second node to connect
  41717. */
  41718. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41719. /**
  41720. * Releases all associated resources
  41721. */
  41722. dispose(): void;
  41723. }
  41724. }
  41725. declare module BABYLON {
  41726. /**
  41727. * This represents an audio engine and it is responsible
  41728. * to play, synchronize and analyse sounds throughout the application.
  41729. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41730. */
  41731. export interface IAudioEngine extends IDisposable {
  41732. /**
  41733. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41734. */
  41735. readonly canUseWebAudio: boolean;
  41736. /**
  41737. * Gets the current AudioContext if available.
  41738. */
  41739. readonly audioContext: Nullable<AudioContext>;
  41740. /**
  41741. * The master gain node defines the global audio volume of your audio engine.
  41742. */
  41743. readonly masterGain: GainNode;
  41744. /**
  41745. * Gets whether or not mp3 are supported by your browser.
  41746. */
  41747. readonly isMP3supported: boolean;
  41748. /**
  41749. * Gets whether or not ogg are supported by your browser.
  41750. */
  41751. readonly isOGGsupported: boolean;
  41752. /**
  41753. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41754. * @ignoreNaming
  41755. */
  41756. WarnedWebAudioUnsupported: boolean;
  41757. /**
  41758. * Defines if the audio engine relies on a custom unlocked button.
  41759. * In this case, the embedded button will not be displayed.
  41760. */
  41761. useCustomUnlockedButton: boolean;
  41762. /**
  41763. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41764. */
  41765. readonly unlocked: boolean;
  41766. /**
  41767. * Event raised when audio has been unlocked on the browser.
  41768. */
  41769. onAudioUnlockedObservable: Observable<IAudioEngine>;
  41770. /**
  41771. * Event raised when audio has been locked on the browser.
  41772. */
  41773. onAudioLockedObservable: Observable<IAudioEngine>;
  41774. /**
  41775. * Flags the audio engine in Locked state.
  41776. * This happens due to new browser policies preventing audio to autoplay.
  41777. */
  41778. lock(): void;
  41779. /**
  41780. * Unlocks the audio engine once a user action has been done on the dom.
  41781. * This is helpful to resume play once browser policies have been satisfied.
  41782. */
  41783. unlock(): void;
  41784. /**
  41785. * Gets the global volume sets on the master gain.
  41786. * @returns the global volume if set or -1 otherwise
  41787. */
  41788. getGlobalVolume(): number;
  41789. /**
  41790. * Sets the global volume of your experience (sets on the master gain).
  41791. * @param newVolume Defines the new global volume of the application
  41792. */
  41793. setGlobalVolume(newVolume: number): void;
  41794. /**
  41795. * Connect the audio engine to an audio analyser allowing some amazing
  41796. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41797. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41798. * @param analyser The analyser to connect to the engine
  41799. */
  41800. connectToAnalyser(analyser: Analyser): void;
  41801. }
  41802. }
  41803. declare module BABYLON {
  41804. /**
  41805. * Defines the interface used by display changed events
  41806. */
  41807. export interface IDisplayChangedEventArgs {
  41808. /** Gets the vrDisplay object (if any) */
  41809. vrDisplay: Nullable<any>;
  41810. /** Gets a boolean indicating if webVR is supported */
  41811. vrSupported: boolean;
  41812. }
  41813. /**
  41814. * Defines the interface used by objects containing a viewport (like a camera)
  41815. */
  41816. interface IViewportOwnerLike {
  41817. /**
  41818. * Gets or sets the viewport
  41819. */
  41820. viewport: IViewportLike;
  41821. }
  41822. /**
  41823. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41824. */
  41825. export class Engine extends ThinEngine {
  41826. /** Defines that alpha blending is disabled */
  41827. static readonly ALPHA_DISABLE: number;
  41828. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41829. static readonly ALPHA_ADD: number;
  41830. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41831. static readonly ALPHA_COMBINE: number;
  41832. /** Defines that alpha blending to DEST - SRC * DEST */
  41833. static readonly ALPHA_SUBTRACT: number;
  41834. /** Defines that alpha blending to SRC * DEST */
  41835. static readonly ALPHA_MULTIPLY: number;
  41836. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41837. static readonly ALPHA_MAXIMIZED: number;
  41838. /** Defines that alpha blending to SRC + DEST */
  41839. static readonly ALPHA_ONEONE: number;
  41840. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41841. static readonly ALPHA_PREMULTIPLIED: number;
  41842. /**
  41843. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41844. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41845. */
  41846. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41847. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41848. static readonly ALPHA_INTERPOLATE: number;
  41849. /**
  41850. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41851. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41852. */
  41853. static readonly ALPHA_SCREENMODE: number;
  41854. /** Defines that the ressource is not delayed*/
  41855. static readonly DELAYLOADSTATE_NONE: number;
  41856. /** Defines that the ressource was successfully delay loaded */
  41857. static readonly DELAYLOADSTATE_LOADED: number;
  41858. /** Defines that the ressource is currently delay loading */
  41859. static readonly DELAYLOADSTATE_LOADING: number;
  41860. /** Defines that the ressource is delayed and has not started loading */
  41861. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41862. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41863. static readonly NEVER: number;
  41864. /** 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 */
  41865. static readonly ALWAYS: number;
  41866. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41867. static readonly LESS: number;
  41868. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41869. static readonly EQUAL: number;
  41870. /** 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 */
  41871. static readonly LEQUAL: number;
  41872. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41873. static readonly GREATER: number;
  41874. /** 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 */
  41875. static readonly GEQUAL: number;
  41876. /** 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 */
  41877. static readonly NOTEQUAL: number;
  41878. /** Passed to stencilOperation to specify that stencil value must be kept */
  41879. static readonly KEEP: number;
  41880. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41881. static readonly REPLACE: number;
  41882. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41883. static readonly INCR: number;
  41884. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41885. static readonly DECR: number;
  41886. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41887. static readonly INVERT: number;
  41888. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41889. static readonly INCR_WRAP: number;
  41890. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41891. static readonly DECR_WRAP: number;
  41892. /** Texture is not repeating outside of 0..1 UVs */
  41893. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41894. /** Texture is repeating outside of 0..1 UVs */
  41895. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41896. /** Texture is repeating and mirrored */
  41897. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41898. /** ALPHA */
  41899. static readonly TEXTUREFORMAT_ALPHA: number;
  41900. /** LUMINANCE */
  41901. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41902. /** LUMINANCE_ALPHA */
  41903. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41904. /** RGB */
  41905. static readonly TEXTUREFORMAT_RGB: number;
  41906. /** RGBA */
  41907. static readonly TEXTUREFORMAT_RGBA: number;
  41908. /** RED */
  41909. static readonly TEXTUREFORMAT_RED: number;
  41910. /** RED (2nd reference) */
  41911. static readonly TEXTUREFORMAT_R: number;
  41912. /** RG */
  41913. static readonly TEXTUREFORMAT_RG: number;
  41914. /** RED_INTEGER */
  41915. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41916. /** RED_INTEGER (2nd reference) */
  41917. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41918. /** RG_INTEGER */
  41919. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41920. /** RGB_INTEGER */
  41921. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41922. /** RGBA_INTEGER */
  41923. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41924. /** UNSIGNED_BYTE */
  41925. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41926. /** UNSIGNED_BYTE (2nd reference) */
  41927. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41928. /** FLOAT */
  41929. static readonly TEXTURETYPE_FLOAT: number;
  41930. /** HALF_FLOAT */
  41931. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41932. /** BYTE */
  41933. static readonly TEXTURETYPE_BYTE: number;
  41934. /** SHORT */
  41935. static readonly TEXTURETYPE_SHORT: number;
  41936. /** UNSIGNED_SHORT */
  41937. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41938. /** INT */
  41939. static readonly TEXTURETYPE_INT: number;
  41940. /** UNSIGNED_INT */
  41941. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41942. /** UNSIGNED_SHORT_4_4_4_4 */
  41943. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41944. /** UNSIGNED_SHORT_5_5_5_1 */
  41945. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41946. /** UNSIGNED_SHORT_5_6_5 */
  41947. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41948. /** UNSIGNED_INT_2_10_10_10_REV */
  41949. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41950. /** UNSIGNED_INT_24_8 */
  41951. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41952. /** UNSIGNED_INT_10F_11F_11F_REV */
  41953. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41954. /** UNSIGNED_INT_5_9_9_9_REV */
  41955. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41956. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41957. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41958. /** nearest is mag = nearest and min = nearest and mip = none */
  41959. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41960. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41961. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41962. /** Trilinear is mag = linear and min = linear and mip = linear */
  41963. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41964. /** nearest is mag = nearest and min = nearest and mip = linear */
  41965. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41966. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41967. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  41968. /** Trilinear is mag = linear and min = linear and mip = linear */
  41969. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41970. /** mag = nearest and min = nearest and mip = nearest */
  41971. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41972. /** mag = nearest and min = linear and mip = nearest */
  41973. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41974. /** mag = nearest and min = linear and mip = linear */
  41975. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  41976. /** mag = nearest and min = linear and mip = none */
  41977. static readonly TEXTURE_NEAREST_LINEAR: number;
  41978. /** mag = nearest and min = nearest and mip = none */
  41979. static readonly TEXTURE_NEAREST_NEAREST: number;
  41980. /** mag = linear and min = nearest and mip = nearest */
  41981. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  41982. /** mag = linear and min = nearest and mip = linear */
  41983. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  41984. /** mag = linear and min = linear and mip = none */
  41985. static readonly TEXTURE_LINEAR_LINEAR: number;
  41986. /** mag = linear and min = nearest and mip = none */
  41987. static readonly TEXTURE_LINEAR_NEAREST: number;
  41988. /** Explicit coordinates mode */
  41989. static readonly TEXTURE_EXPLICIT_MODE: number;
  41990. /** Spherical coordinates mode */
  41991. static readonly TEXTURE_SPHERICAL_MODE: number;
  41992. /** Planar coordinates mode */
  41993. static readonly TEXTURE_PLANAR_MODE: number;
  41994. /** Cubic coordinates mode */
  41995. static readonly TEXTURE_CUBIC_MODE: number;
  41996. /** Projection coordinates mode */
  41997. static readonly TEXTURE_PROJECTION_MODE: number;
  41998. /** Skybox coordinates mode */
  41999. static readonly TEXTURE_SKYBOX_MODE: number;
  42000. /** Inverse Cubic coordinates mode */
  42001. static readonly TEXTURE_INVCUBIC_MODE: number;
  42002. /** Equirectangular coordinates mode */
  42003. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42004. /** Equirectangular Fixed coordinates mode */
  42005. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42006. /** Equirectangular Fixed Mirrored coordinates mode */
  42007. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42008. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42009. static readonly SCALEMODE_FLOOR: number;
  42010. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42011. static readonly SCALEMODE_NEAREST: number;
  42012. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42013. static readonly SCALEMODE_CEILING: number;
  42014. /**
  42015. * Returns the current npm package of the sdk
  42016. */
  42017. static get NpmPackage(): string;
  42018. /**
  42019. * Returns the current version of the framework
  42020. */
  42021. static get Version(): string;
  42022. /** Gets the list of created engines */
  42023. static get Instances(): Engine[];
  42024. /**
  42025. * Gets the latest created engine
  42026. */
  42027. static get LastCreatedEngine(): Nullable<Engine>;
  42028. /**
  42029. * Gets the latest created scene
  42030. */
  42031. static get LastCreatedScene(): Nullable<Scene>;
  42032. /**
  42033. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42034. * @param flag defines which part of the materials must be marked as dirty
  42035. * @param predicate defines a predicate used to filter which materials should be affected
  42036. */
  42037. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42038. /**
  42039. * Method called to create the default loading screen.
  42040. * This can be overriden in your own app.
  42041. * @param canvas The rendering canvas element
  42042. * @returns The loading screen
  42043. */
  42044. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42045. /**
  42046. * Method called to create the default rescale post process on each engine.
  42047. */
  42048. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42049. /**
  42050. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42051. **/
  42052. enableOfflineSupport: boolean;
  42053. /**
  42054. * 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)
  42055. **/
  42056. disableManifestCheck: boolean;
  42057. /**
  42058. * Gets the list of created scenes
  42059. */
  42060. scenes: Scene[];
  42061. /**
  42062. * Event raised when a new scene is created
  42063. */
  42064. onNewSceneAddedObservable: Observable<Scene>;
  42065. /**
  42066. * Gets the list of created postprocesses
  42067. */
  42068. postProcesses: PostProcess[];
  42069. /**
  42070. * Gets a boolean indicating if the pointer is currently locked
  42071. */
  42072. isPointerLock: boolean;
  42073. /**
  42074. * Observable event triggered each time the rendering canvas is resized
  42075. */
  42076. onResizeObservable: Observable<Engine>;
  42077. /**
  42078. * Observable event triggered each time the canvas loses focus
  42079. */
  42080. onCanvasBlurObservable: Observable<Engine>;
  42081. /**
  42082. * Observable event triggered each time the canvas gains focus
  42083. */
  42084. onCanvasFocusObservable: Observable<Engine>;
  42085. /**
  42086. * Observable event triggered each time the canvas receives pointerout event
  42087. */
  42088. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42089. /**
  42090. * Observable raised when the engine begins a new frame
  42091. */
  42092. onBeginFrameObservable: Observable<Engine>;
  42093. /**
  42094. * If set, will be used to request the next animation frame for the render loop
  42095. */
  42096. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42097. /**
  42098. * Observable raised when the engine ends the current frame
  42099. */
  42100. onEndFrameObservable: Observable<Engine>;
  42101. /**
  42102. * Observable raised when the engine is about to compile a shader
  42103. */
  42104. onBeforeShaderCompilationObservable: Observable<Engine>;
  42105. /**
  42106. * Observable raised when the engine has jsut compiled a shader
  42107. */
  42108. onAfterShaderCompilationObservable: Observable<Engine>;
  42109. /**
  42110. * Gets the audio engine
  42111. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42112. * @ignorenaming
  42113. */
  42114. static audioEngine: IAudioEngine;
  42115. /**
  42116. * Default AudioEngine factory responsible of creating the Audio Engine.
  42117. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42118. */
  42119. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42120. /**
  42121. * Default offline support factory responsible of creating a tool used to store data locally.
  42122. * By default, this will create a Database object if the workload has been embedded.
  42123. */
  42124. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42125. private _loadingScreen;
  42126. private _pointerLockRequested;
  42127. private _rescalePostProcess;
  42128. protected _deterministicLockstep: boolean;
  42129. protected _lockstepMaxSteps: number;
  42130. protected _timeStep: number;
  42131. protected get _supportsHardwareTextureRescaling(): boolean;
  42132. private _fps;
  42133. private _deltaTime;
  42134. /** @hidden */
  42135. _drawCalls: PerfCounter;
  42136. /** 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 */
  42137. canvasTabIndex: number;
  42138. /**
  42139. * Turn this value on if you want to pause FPS computation when in background
  42140. */
  42141. disablePerformanceMonitorInBackground: boolean;
  42142. private _performanceMonitor;
  42143. /**
  42144. * Gets the performance monitor attached to this engine
  42145. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42146. */
  42147. get performanceMonitor(): PerformanceMonitor;
  42148. private _onFocus;
  42149. private _onBlur;
  42150. private _onCanvasPointerOut;
  42151. private _onCanvasBlur;
  42152. private _onCanvasFocus;
  42153. private _onFullscreenChange;
  42154. private _onPointerLockChange;
  42155. /**
  42156. * Gets the HTML element used to attach event listeners
  42157. * @returns a HTML element
  42158. */
  42159. getInputElement(): Nullable<HTMLElement>;
  42160. /**
  42161. * Creates a new engine
  42162. * @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
  42163. * @param antialias defines enable antialiasing (default: false)
  42164. * @param options defines further options to be sent to the getContext() function
  42165. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42166. */
  42167. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42168. /**
  42169. * Shared initialization across engines types.
  42170. * @param canvas The canvas associated with this instance of the engine.
  42171. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42172. * @param audioEngine Defines if an audio engine should be created by default
  42173. */
  42174. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42175. /**
  42176. * Gets current aspect ratio
  42177. * @param viewportOwner defines the camera to use to get the aspect ratio
  42178. * @param useScreen defines if screen size must be used (or the current render target if any)
  42179. * @returns a number defining the aspect ratio
  42180. */
  42181. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42182. /**
  42183. * Gets current screen aspect ratio
  42184. * @returns a number defining the aspect ratio
  42185. */
  42186. getScreenAspectRatio(): number;
  42187. /**
  42188. * Gets the client rect of the HTML canvas attached with the current webGL context
  42189. * @returns a client rectanglee
  42190. */
  42191. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42192. /**
  42193. * Gets the client rect of the HTML element used for events
  42194. * @returns a client rectanglee
  42195. */
  42196. getInputElementClientRect(): Nullable<ClientRect>;
  42197. /**
  42198. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42199. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42200. * @returns true if engine is in deterministic lock step mode
  42201. */
  42202. isDeterministicLockStep(): boolean;
  42203. /**
  42204. * Gets the max steps when engine is running in deterministic lock step
  42205. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42206. * @returns the max steps
  42207. */
  42208. getLockstepMaxSteps(): number;
  42209. /**
  42210. * Returns the time in ms between steps when using deterministic lock step.
  42211. * @returns time step in (ms)
  42212. */
  42213. getTimeStep(): number;
  42214. /**
  42215. * Force the mipmap generation for the given render target texture
  42216. * @param texture defines the render target texture to use
  42217. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42218. */
  42219. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42220. /** States */
  42221. /**
  42222. * Set various states to the webGL context
  42223. * @param culling defines backface culling state
  42224. * @param zOffset defines the value to apply to zOffset (0 by default)
  42225. * @param force defines if states must be applied even if cache is up to date
  42226. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42227. */
  42228. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42229. /**
  42230. * Set the z offset to apply to current rendering
  42231. * @param value defines the offset to apply
  42232. */
  42233. setZOffset(value: number): void;
  42234. /**
  42235. * Gets the current value of the zOffset
  42236. * @returns the current zOffset state
  42237. */
  42238. getZOffset(): number;
  42239. /**
  42240. * Gets a boolean indicating if depth testing is enabled
  42241. * @returns the current state
  42242. */
  42243. getDepthBuffer(): boolean;
  42244. /**
  42245. * Enable or disable depth buffering
  42246. * @param enable defines the state to set
  42247. */
  42248. setDepthBuffer(enable: boolean): void;
  42249. /**
  42250. * Gets a boolean indicating if depth writing is enabled
  42251. * @returns the current depth writing state
  42252. */
  42253. getDepthWrite(): boolean;
  42254. /**
  42255. * Enable or disable depth writing
  42256. * @param enable defines the state to set
  42257. */
  42258. setDepthWrite(enable: boolean): void;
  42259. /**
  42260. * Gets a boolean indicating if stencil buffer is enabled
  42261. * @returns the current stencil buffer state
  42262. */
  42263. getStencilBuffer(): boolean;
  42264. /**
  42265. * Enable or disable the stencil buffer
  42266. * @param enable defines if the stencil buffer must be enabled or disabled
  42267. */
  42268. setStencilBuffer(enable: boolean): void;
  42269. /**
  42270. * Gets the current stencil mask
  42271. * @returns a number defining the new stencil mask to use
  42272. */
  42273. getStencilMask(): number;
  42274. /**
  42275. * Sets the current stencil mask
  42276. * @param mask defines the new stencil mask to use
  42277. */
  42278. setStencilMask(mask: number): void;
  42279. /**
  42280. * Gets the current stencil function
  42281. * @returns a number defining the stencil function to use
  42282. */
  42283. getStencilFunction(): number;
  42284. /**
  42285. * Gets the current stencil reference value
  42286. * @returns a number defining the stencil reference value to use
  42287. */
  42288. getStencilFunctionReference(): number;
  42289. /**
  42290. * Gets the current stencil mask
  42291. * @returns a number defining the stencil mask to use
  42292. */
  42293. getStencilFunctionMask(): number;
  42294. /**
  42295. * Sets the current stencil function
  42296. * @param stencilFunc defines the new stencil function to use
  42297. */
  42298. setStencilFunction(stencilFunc: number): void;
  42299. /**
  42300. * Sets the current stencil reference
  42301. * @param reference defines the new stencil reference to use
  42302. */
  42303. setStencilFunctionReference(reference: number): void;
  42304. /**
  42305. * Sets the current stencil mask
  42306. * @param mask defines the new stencil mask to use
  42307. */
  42308. setStencilFunctionMask(mask: number): void;
  42309. /**
  42310. * Gets the current stencil operation when stencil fails
  42311. * @returns a number defining stencil operation to use when stencil fails
  42312. */
  42313. getStencilOperationFail(): number;
  42314. /**
  42315. * Gets the current stencil operation when depth fails
  42316. * @returns a number defining stencil operation to use when depth fails
  42317. */
  42318. getStencilOperationDepthFail(): number;
  42319. /**
  42320. * Gets the current stencil operation when stencil passes
  42321. * @returns a number defining stencil operation to use when stencil passes
  42322. */
  42323. getStencilOperationPass(): number;
  42324. /**
  42325. * Sets the stencil operation to use when stencil fails
  42326. * @param operation defines the stencil operation to use when stencil fails
  42327. */
  42328. setStencilOperationFail(operation: number): void;
  42329. /**
  42330. * Sets the stencil operation to use when depth fails
  42331. * @param operation defines the stencil operation to use when depth fails
  42332. */
  42333. setStencilOperationDepthFail(operation: number): void;
  42334. /**
  42335. * Sets the stencil operation to use when stencil passes
  42336. * @param operation defines the stencil operation to use when stencil passes
  42337. */
  42338. setStencilOperationPass(operation: number): void;
  42339. /**
  42340. * Sets a boolean indicating if the dithering state is enabled or disabled
  42341. * @param value defines the dithering state
  42342. */
  42343. setDitheringState(value: boolean): void;
  42344. /**
  42345. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42346. * @param value defines the rasterizer state
  42347. */
  42348. setRasterizerState(value: boolean): void;
  42349. /**
  42350. * Gets the current depth function
  42351. * @returns a number defining the depth function
  42352. */
  42353. getDepthFunction(): Nullable<number>;
  42354. /**
  42355. * Sets the current depth function
  42356. * @param depthFunc defines the function to use
  42357. */
  42358. setDepthFunction(depthFunc: number): void;
  42359. /**
  42360. * Sets the current depth function to GREATER
  42361. */
  42362. setDepthFunctionToGreater(): void;
  42363. /**
  42364. * Sets the current depth function to GEQUAL
  42365. */
  42366. setDepthFunctionToGreaterOrEqual(): void;
  42367. /**
  42368. * Sets the current depth function to LESS
  42369. */
  42370. setDepthFunctionToLess(): void;
  42371. /**
  42372. * Sets the current depth function to LEQUAL
  42373. */
  42374. setDepthFunctionToLessOrEqual(): void;
  42375. private _cachedStencilBuffer;
  42376. private _cachedStencilFunction;
  42377. private _cachedStencilMask;
  42378. private _cachedStencilOperationPass;
  42379. private _cachedStencilOperationFail;
  42380. private _cachedStencilOperationDepthFail;
  42381. private _cachedStencilReference;
  42382. /**
  42383. * Caches the the state of the stencil buffer
  42384. */
  42385. cacheStencilState(): void;
  42386. /**
  42387. * Restores the state of the stencil buffer
  42388. */
  42389. restoreStencilState(): void;
  42390. /**
  42391. * Directly set the WebGL Viewport
  42392. * @param x defines the x coordinate of the viewport (in screen space)
  42393. * @param y defines the y coordinate of the viewport (in screen space)
  42394. * @param width defines the width of the viewport (in screen space)
  42395. * @param height defines the height of the viewport (in screen space)
  42396. * @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
  42397. */
  42398. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42399. /**
  42400. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42401. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42402. * @param y defines the y-coordinate of the corner of the clear rectangle
  42403. * @param width defines the width of the clear rectangle
  42404. * @param height defines the height of the clear rectangle
  42405. * @param clearColor defines the clear color
  42406. */
  42407. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42408. /**
  42409. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42410. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42411. * @param y defines the y-coordinate of the corner of the clear rectangle
  42412. * @param width defines the width of the clear rectangle
  42413. * @param height defines the height of the clear rectangle
  42414. */
  42415. enableScissor(x: number, y: number, width: number, height: number): void;
  42416. /**
  42417. * Disable previously set scissor test rectangle
  42418. */
  42419. disableScissor(): void;
  42420. protected _reportDrawCall(): void;
  42421. /**
  42422. * Initializes a webVR display and starts listening to display change events
  42423. * The onVRDisplayChangedObservable will be notified upon these changes
  42424. * @returns The onVRDisplayChangedObservable
  42425. */
  42426. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42427. /** @hidden */
  42428. _prepareVRComponent(): void;
  42429. /** @hidden */
  42430. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42431. /** @hidden */
  42432. _submitVRFrame(): void;
  42433. /**
  42434. * Call this function to leave webVR mode
  42435. * Will do nothing if webVR is not supported or if there is no webVR device
  42436. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42437. */
  42438. disableVR(): void;
  42439. /**
  42440. * Gets a boolean indicating that the system is in VR mode and is presenting
  42441. * @returns true if VR mode is engaged
  42442. */
  42443. isVRPresenting(): boolean;
  42444. /** @hidden */
  42445. _requestVRFrame(): void;
  42446. /** @hidden */
  42447. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42448. /**
  42449. * Gets the source code of the vertex shader associated with a specific webGL program
  42450. * @param program defines the program to use
  42451. * @returns a string containing the source code of the vertex shader associated with the program
  42452. */
  42453. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42454. /**
  42455. * Gets the source code of the fragment shader associated with a specific webGL program
  42456. * @param program defines the program to use
  42457. * @returns a string containing the source code of the fragment shader associated with the program
  42458. */
  42459. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42460. /**
  42461. * Sets a depth stencil texture from a render target to the according uniform.
  42462. * @param channel The texture channel
  42463. * @param uniform The uniform to set
  42464. * @param texture The render target texture containing the depth stencil texture to apply
  42465. * @param name The texture name
  42466. */
  42467. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42468. /**
  42469. * Sets a texture to the webGL context from a postprocess
  42470. * @param channel defines the channel to use
  42471. * @param postProcess defines the source postprocess
  42472. * @param name name of the channel
  42473. */
  42474. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42475. /**
  42476. * Binds the output of the passed in post process to the texture channel specified
  42477. * @param channel The channel the texture should be bound to
  42478. * @param postProcess The post process which's output should be bound
  42479. * @param name name of the channel
  42480. */
  42481. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42482. protected _rebuildBuffers(): void;
  42483. /** @hidden */
  42484. _renderFrame(): void;
  42485. _renderLoop(): void;
  42486. /** @hidden */
  42487. _renderViews(): boolean;
  42488. /**
  42489. * Toggle full screen mode
  42490. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42491. */
  42492. switchFullscreen(requestPointerLock: boolean): void;
  42493. /**
  42494. * Enters full screen mode
  42495. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42496. */
  42497. enterFullscreen(requestPointerLock: boolean): void;
  42498. /**
  42499. * Exits full screen mode
  42500. */
  42501. exitFullscreen(): void;
  42502. /**
  42503. * Enters Pointerlock mode
  42504. */
  42505. enterPointerlock(): void;
  42506. /**
  42507. * Exits Pointerlock mode
  42508. */
  42509. exitPointerlock(): void;
  42510. /**
  42511. * Begin a new frame
  42512. */
  42513. beginFrame(): void;
  42514. /**
  42515. * End the current frame
  42516. */
  42517. endFrame(): void;
  42518. /**
  42519. * Resize the view according to the canvas' size
  42520. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42521. */
  42522. resize(forceSetSize?: boolean): void;
  42523. /**
  42524. * Force a specific size of the canvas
  42525. * @param width defines the new canvas' width
  42526. * @param height defines the new canvas' height
  42527. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42528. * @returns true if the size was changed
  42529. */
  42530. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42531. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42532. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42533. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42534. _releaseTexture(texture: InternalTexture): void;
  42535. /**
  42536. * @hidden
  42537. * Rescales a texture
  42538. * @param source input texutre
  42539. * @param destination destination texture
  42540. * @param scene scene to use to render the resize
  42541. * @param internalFormat format to use when resizing
  42542. * @param onComplete callback to be called when resize has completed
  42543. */
  42544. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42545. /**
  42546. * Gets the current framerate
  42547. * @returns a number representing the framerate
  42548. */
  42549. getFps(): number;
  42550. /**
  42551. * Gets the time spent between current and previous frame
  42552. * @returns a number representing the delta time in ms
  42553. */
  42554. getDeltaTime(): number;
  42555. private _measureFps;
  42556. /** @hidden */
  42557. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42558. /**
  42559. * Updates the sample count of a render target texture
  42560. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42561. * @param texture defines the texture to update
  42562. * @param samples defines the sample count to set
  42563. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42564. */
  42565. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42566. /**
  42567. * Updates a depth texture Comparison Mode and Function.
  42568. * If the comparison Function is equal to 0, the mode will be set to none.
  42569. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42570. * @param texture The texture to set the comparison function for
  42571. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42572. */
  42573. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42574. /**
  42575. * Creates a webGL buffer to use with instanciation
  42576. * @param capacity defines the size of the buffer
  42577. * @returns the webGL buffer
  42578. */
  42579. createInstancesBuffer(capacity: number): DataBuffer;
  42580. /**
  42581. * Delete a webGL buffer used with instanciation
  42582. * @param buffer defines the webGL buffer to delete
  42583. */
  42584. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42585. private _clientWaitAsync;
  42586. /** @hidden */
  42587. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  42588. dispose(): void;
  42589. private _disableTouchAction;
  42590. /**
  42591. * Display the loading screen
  42592. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42593. */
  42594. displayLoadingUI(): void;
  42595. /**
  42596. * Hide the loading screen
  42597. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42598. */
  42599. hideLoadingUI(): void;
  42600. /**
  42601. * Gets the current loading screen object
  42602. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42603. */
  42604. get loadingScreen(): ILoadingScreen;
  42605. /**
  42606. * Sets the current loading screen object
  42607. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42608. */
  42609. set loadingScreen(loadingScreen: ILoadingScreen);
  42610. /**
  42611. * Sets the current loading screen text
  42612. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42613. */
  42614. set loadingUIText(text: string);
  42615. /**
  42616. * Sets the current loading screen background color
  42617. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42618. */
  42619. set loadingUIBackgroundColor(color: string);
  42620. /** Pointerlock and fullscreen */
  42621. /**
  42622. * Ask the browser to promote the current element to pointerlock mode
  42623. * @param element defines the DOM element to promote
  42624. */
  42625. static _RequestPointerlock(element: HTMLElement): void;
  42626. /**
  42627. * Asks the browser to exit pointerlock mode
  42628. */
  42629. static _ExitPointerlock(): void;
  42630. /**
  42631. * Ask the browser to promote the current element to fullscreen rendering mode
  42632. * @param element defines the DOM element to promote
  42633. */
  42634. static _RequestFullscreen(element: HTMLElement): void;
  42635. /**
  42636. * Asks the browser to exit fullscreen mode
  42637. */
  42638. static _ExitFullscreen(): void;
  42639. }
  42640. }
  42641. declare module BABYLON {
  42642. /**
  42643. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42644. * during the life time of the application.
  42645. */
  42646. export class EngineStore {
  42647. /** Gets the list of created engines */
  42648. static Instances: Engine[];
  42649. /** @hidden */
  42650. static _LastCreatedScene: Nullable<Scene>;
  42651. /**
  42652. * Gets the latest created engine
  42653. */
  42654. static get LastCreatedEngine(): Nullable<Engine>;
  42655. /**
  42656. * Gets the latest created scene
  42657. */
  42658. static get LastCreatedScene(): Nullable<Scene>;
  42659. /**
  42660. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42661. * @ignorenaming
  42662. */
  42663. static UseFallbackTexture: boolean;
  42664. /**
  42665. * Texture content used if a texture cannot loaded
  42666. * @ignorenaming
  42667. */
  42668. static FallbackTexture: string;
  42669. }
  42670. }
  42671. declare module BABYLON {
  42672. /**
  42673. * Helper class that provides a small promise polyfill
  42674. */
  42675. export class PromisePolyfill {
  42676. /**
  42677. * Static function used to check if the polyfill is required
  42678. * If this is the case then the function will inject the polyfill to window.Promise
  42679. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42680. */
  42681. static Apply(force?: boolean): void;
  42682. }
  42683. }
  42684. declare module BABYLON {
  42685. /**
  42686. * Interface for screenshot methods with describe argument called `size` as object with options
  42687. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42688. */
  42689. export interface IScreenshotSize {
  42690. /**
  42691. * number in pixels for canvas height
  42692. */
  42693. height?: number;
  42694. /**
  42695. * multiplier allowing render at a higher or lower resolution
  42696. * If value is defined then height and width will be ignored and taken from camera
  42697. */
  42698. precision?: number;
  42699. /**
  42700. * number in pixels for canvas width
  42701. */
  42702. width?: number;
  42703. }
  42704. }
  42705. declare module BABYLON {
  42706. interface IColor4Like {
  42707. r: float;
  42708. g: float;
  42709. b: float;
  42710. a: float;
  42711. }
  42712. /**
  42713. * Class containing a set of static utilities functions
  42714. */
  42715. export class Tools {
  42716. /**
  42717. * Gets or sets the base URL to use to load assets
  42718. */
  42719. static get BaseUrl(): string;
  42720. static set BaseUrl(value: string);
  42721. /**
  42722. * Enable/Disable Custom HTTP Request Headers globally.
  42723. * default = false
  42724. * @see CustomRequestHeaders
  42725. */
  42726. static UseCustomRequestHeaders: boolean;
  42727. /**
  42728. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42729. * i.e. when loading files, where the server/service expects an Authorization header
  42730. */
  42731. static CustomRequestHeaders: {
  42732. [key: string]: string;
  42733. };
  42734. /**
  42735. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42736. */
  42737. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42738. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42739. /**
  42740. * Default behaviour for cors in the application.
  42741. * It can be a string if the expected behavior is identical in the entire app.
  42742. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42743. */
  42744. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42745. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42746. /**
  42747. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42748. * @ignorenaming
  42749. */
  42750. static get UseFallbackTexture(): boolean;
  42751. static set UseFallbackTexture(value: boolean);
  42752. /**
  42753. * Use this object to register external classes like custom textures or material
  42754. * to allow the laoders to instantiate them
  42755. */
  42756. static get RegisteredExternalClasses(): {
  42757. [key: string]: Object;
  42758. };
  42759. static set RegisteredExternalClasses(classes: {
  42760. [key: string]: Object;
  42761. });
  42762. /**
  42763. * Texture content used if a texture cannot loaded
  42764. * @ignorenaming
  42765. */
  42766. static get fallbackTexture(): string;
  42767. static set fallbackTexture(value: string);
  42768. /**
  42769. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42770. * @param u defines the coordinate on X axis
  42771. * @param v defines the coordinate on Y axis
  42772. * @param width defines the width of the source data
  42773. * @param height defines the height of the source data
  42774. * @param pixels defines the source byte array
  42775. * @param color defines the output color
  42776. */
  42777. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42778. /**
  42779. * Interpolates between a and b via alpha
  42780. * @param a The lower value (returned when alpha = 0)
  42781. * @param b The upper value (returned when alpha = 1)
  42782. * @param alpha The interpolation-factor
  42783. * @return The mixed value
  42784. */
  42785. static Mix(a: number, b: number, alpha: number): number;
  42786. /**
  42787. * Tries to instantiate a new object from a given class name
  42788. * @param className defines the class name to instantiate
  42789. * @returns the new object or null if the system was not able to do the instantiation
  42790. */
  42791. static Instantiate(className: string): any;
  42792. /**
  42793. * Provides a slice function that will work even on IE
  42794. * @param data defines the array to slice
  42795. * @param start defines the start of the data (optional)
  42796. * @param end defines the end of the data (optional)
  42797. * @returns the new sliced array
  42798. */
  42799. static Slice<T>(data: T, start?: number, end?: number): T;
  42800. /**
  42801. * Provides a slice function that will work even on IE
  42802. * The difference between this and Slice is that this will force-convert to array
  42803. * @param data defines the array to slice
  42804. * @param start defines the start of the data (optional)
  42805. * @param end defines the end of the data (optional)
  42806. * @returns the new sliced array
  42807. */
  42808. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  42809. /**
  42810. * Polyfill for setImmediate
  42811. * @param action defines the action to execute after the current execution block
  42812. */
  42813. static SetImmediate(action: () => void): void;
  42814. /**
  42815. * Function indicating if a number is an exponent of 2
  42816. * @param value defines the value to test
  42817. * @returns true if the value is an exponent of 2
  42818. */
  42819. static IsExponentOfTwo(value: number): boolean;
  42820. private static _tmpFloatArray;
  42821. /**
  42822. * Returns the nearest 32-bit single precision float representation of a Number
  42823. * @param value A Number. If the parameter is of a different type, it will get converted
  42824. * to a number or to NaN if it cannot be converted
  42825. * @returns number
  42826. */
  42827. static FloatRound(value: number): number;
  42828. /**
  42829. * Extracts the filename from a path
  42830. * @param path defines the path to use
  42831. * @returns the filename
  42832. */
  42833. static GetFilename(path: string): string;
  42834. /**
  42835. * Extracts the "folder" part of a path (everything before the filename).
  42836. * @param uri The URI to extract the info from
  42837. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42838. * @returns The "folder" part of the path
  42839. */
  42840. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42841. /**
  42842. * Extracts text content from a DOM element hierarchy
  42843. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42844. */
  42845. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42846. /**
  42847. * Convert an angle in radians to degrees
  42848. * @param angle defines the angle to convert
  42849. * @returns the angle in degrees
  42850. */
  42851. static ToDegrees(angle: number): number;
  42852. /**
  42853. * Convert an angle in degrees to radians
  42854. * @param angle defines the angle to convert
  42855. * @returns the angle in radians
  42856. */
  42857. static ToRadians(angle: number): number;
  42858. /**
  42859. * Returns an array if obj is not an array
  42860. * @param obj defines the object to evaluate as an array
  42861. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42862. * @returns either obj directly if obj is an array or a new array containing obj
  42863. */
  42864. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42865. /**
  42866. * Gets the pointer prefix to use
  42867. * @param engine defines the engine we are finding the prefix for
  42868. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42869. */
  42870. static GetPointerPrefix(engine: Engine): string;
  42871. /**
  42872. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42873. * @param url define the url we are trying
  42874. * @param element define the dom element where to configure the cors policy
  42875. */
  42876. static SetCorsBehavior(url: string | string[], element: {
  42877. crossOrigin: string | null;
  42878. }): void;
  42879. /**
  42880. * Removes unwanted characters from an url
  42881. * @param url defines the url to clean
  42882. * @returns the cleaned url
  42883. */
  42884. static CleanUrl(url: string): string;
  42885. /**
  42886. * Gets or sets a function used to pre-process url before using them to load assets
  42887. */
  42888. static get PreprocessUrl(): (url: string) => string;
  42889. static set PreprocessUrl(processor: (url: string) => string);
  42890. /**
  42891. * Loads an image as an HTMLImageElement.
  42892. * @param input url string, ArrayBuffer, or Blob to load
  42893. * @param onLoad callback called when the image successfully loads
  42894. * @param onError callback called when the image fails to load
  42895. * @param offlineProvider offline provider for caching
  42896. * @param mimeType optional mime type
  42897. * @returns the HTMLImageElement of the loaded image
  42898. */
  42899. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42900. /**
  42901. * Loads a file from a url
  42902. * @param url url string, ArrayBuffer, or Blob to load
  42903. * @param onSuccess callback called when the file successfully loads
  42904. * @param onProgress callback called while file is loading (if the server supports this mode)
  42905. * @param offlineProvider defines the offline provider for caching
  42906. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42907. * @param onError callback called when the file fails to load
  42908. * @returns a file request object
  42909. */
  42910. 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;
  42911. /**
  42912. * Loads a file from a url
  42913. * @param url the file url to load
  42914. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42915. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42916. */
  42917. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42918. /**
  42919. * Load a script (identified by an url). When the url returns, the
  42920. * content of this file is added into a new script element, attached to the DOM (body element)
  42921. * @param scriptUrl defines the url of the script to laod
  42922. * @param onSuccess defines the callback called when the script is loaded
  42923. * @param onError defines the callback to call if an error occurs
  42924. * @param scriptId defines the id of the script element
  42925. */
  42926. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42927. /**
  42928. * Load an asynchronous script (identified by an url). When the url returns, the
  42929. * content of this file is added into a new script element, attached to the DOM (body element)
  42930. * @param scriptUrl defines the url of the script to laod
  42931. * @param scriptId defines the id of the script element
  42932. * @returns a promise request object
  42933. */
  42934. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42935. /**
  42936. * Loads a file from a blob
  42937. * @param fileToLoad defines the blob to use
  42938. * @param callback defines the callback to call when data is loaded
  42939. * @param progressCallback defines the callback to call during loading process
  42940. * @returns a file request object
  42941. */
  42942. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  42943. /**
  42944. * Reads a file from a File object
  42945. * @param file defines the file to load
  42946. * @param onSuccess defines the callback to call when data is loaded
  42947. * @param onProgress defines the callback to call during loading process
  42948. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42949. * @param onError defines the callback to call when an error occurs
  42950. * @returns a file request object
  42951. */
  42952. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42953. /**
  42954. * Creates a data url from a given string content
  42955. * @param content defines the content to convert
  42956. * @returns the new data url link
  42957. */
  42958. static FileAsURL(content: string): string;
  42959. /**
  42960. * Format the given number to a specific decimal format
  42961. * @param value defines the number to format
  42962. * @param decimals defines the number of decimals to use
  42963. * @returns the formatted string
  42964. */
  42965. static Format(value: number, decimals?: number): string;
  42966. /**
  42967. * Tries to copy an object by duplicating every property
  42968. * @param source defines the source object
  42969. * @param destination defines the target object
  42970. * @param doNotCopyList defines a list of properties to avoid
  42971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  42972. */
  42973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  42974. /**
  42975. * Gets a boolean indicating if the given object has no own property
  42976. * @param obj defines the object to test
  42977. * @returns true if object has no own property
  42978. */
  42979. static IsEmpty(obj: any): boolean;
  42980. /**
  42981. * Function used to register events at window level
  42982. * @param windowElement defines the Window object to use
  42983. * @param events defines the events to register
  42984. */
  42985. static RegisterTopRootEvents(windowElement: Window, events: {
  42986. name: string;
  42987. handler: Nullable<(e: FocusEvent) => any>;
  42988. }[]): void;
  42989. /**
  42990. * Function used to unregister events from window level
  42991. * @param windowElement defines the Window object to use
  42992. * @param events defines the events to unregister
  42993. */
  42994. static UnregisterTopRootEvents(windowElement: Window, events: {
  42995. name: string;
  42996. handler: Nullable<(e: FocusEvent) => any>;
  42997. }[]): void;
  42998. /**
  42999. * @ignore
  43000. */
  43001. static _ScreenshotCanvas: HTMLCanvasElement;
  43002. /**
  43003. * Dumps the current bound framebuffer
  43004. * @param width defines the rendering width
  43005. * @param height defines the rendering height
  43006. * @param engine defines the hosting engine
  43007. * @param successCallback defines the callback triggered once the data are available
  43008. * @param mimeType defines the mime type of the result
  43009. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43010. * @return a void promise
  43011. */
  43012. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43013. /**
  43014. * Dumps an array buffer
  43015. * @param width defines the rendering width
  43016. * @param height defines the rendering height
  43017. * @param data the data array
  43018. * @param successCallback defines the callback triggered once the data are available
  43019. * @param mimeType defines the mime type of the result
  43020. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43021. * @param invertY true to invert the picture in the Y dimension
  43022. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43023. */
  43024. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43025. /**
  43026. * Dumps an array buffer
  43027. * @param width defines the rendering width
  43028. * @param height defines the rendering height
  43029. * @param data the data array
  43030. * @param successCallback defines the callback triggered once the data are available
  43031. * @param mimeType defines the mime type of the result
  43032. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43033. * @param invertY true to invert the picture in the Y dimension
  43034. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43035. * @return a promise that resolve to the final data
  43036. */
  43037. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43038. /**
  43039. * Converts the canvas data to blob.
  43040. * This acts as a polyfill for browsers not supporting the to blob function.
  43041. * @param canvas Defines the canvas to extract the data from
  43042. * @param successCallback Defines the callback triggered once the data are available
  43043. * @param mimeType Defines the mime type of the result
  43044. */
  43045. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43046. /**
  43047. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43048. * @param successCallback defines the callback triggered once the data are available
  43049. * @param mimeType defines the mime type of the result
  43050. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43051. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43052. */
  43053. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43054. /**
  43055. * Downloads a blob in the browser
  43056. * @param blob defines the blob to download
  43057. * @param fileName defines the name of the downloaded file
  43058. */
  43059. static Download(blob: Blob, fileName: string): void;
  43060. /**
  43061. * Will return the right value of the noPreventDefault variable
  43062. * Needed to keep backwards compatibility to the old API.
  43063. *
  43064. * @param args arguments passed to the attachControl function
  43065. * @returns the correct value for noPreventDefault
  43066. */
  43067. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43068. /**
  43069. * Captures a screenshot of the current rendering
  43070. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43071. * @param engine defines the rendering engine
  43072. * @param camera defines the source camera
  43073. * @param size This parameter can be set to a single number or to an object with the
  43074. * following (optional) properties: precision, width, height. If a single number is passed,
  43075. * it will be used for both width and height. If an object is passed, the screenshot size
  43076. * will be derived from the parameters. The precision property is a multiplier allowing
  43077. * rendering at a higher or lower resolution
  43078. * @param successCallback defines the callback receives a single parameter which contains the
  43079. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43080. * src parameter of an <img> to display it
  43081. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43082. * Check your browser for supported MIME types
  43083. */
  43084. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43085. /**
  43086. * Captures a screenshot of the current rendering
  43087. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43088. * @param engine defines the rendering engine
  43089. * @param camera defines the source camera
  43090. * @param size This parameter can be set to a single number or to an object with the
  43091. * following (optional) properties: precision, width, height. If a single number is passed,
  43092. * it will be used for both width and height. If an object is passed, the screenshot size
  43093. * will be derived from the parameters. The precision property is a multiplier allowing
  43094. * rendering at a higher or lower resolution
  43095. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43096. * Check your browser for supported MIME types
  43097. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43098. * to the src parameter of an <img> to display it
  43099. */
  43100. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43101. /**
  43102. * Generates an image screenshot from the specified camera.
  43103. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43104. * @param engine The engine to use for rendering
  43105. * @param camera The camera to use for rendering
  43106. * @param size This parameter can be set to a single number or to an object with the
  43107. * following (optional) properties: precision, width, height. If a single number is passed,
  43108. * it will be used for both width and height. If an object is passed, the screenshot size
  43109. * will be derived from the parameters. The precision property is a multiplier allowing
  43110. * rendering at a higher or lower resolution
  43111. * @param successCallback The callback receives a single parameter which contains the
  43112. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43113. * src parameter of an <img> to display it
  43114. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43115. * Check your browser for supported MIME types
  43116. * @param samples Texture samples (default: 1)
  43117. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43118. * @param fileName A name for for the downloaded file.
  43119. */
  43120. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43121. /**
  43122. * Generates an image screenshot from the specified camera.
  43123. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43124. * @param engine The engine to use for rendering
  43125. * @param camera The camera to use for rendering
  43126. * @param size This parameter can be set to a single number or to an object with the
  43127. * following (optional) properties: precision, width, height. If a single number is passed,
  43128. * it will be used for both width and height. If an object is passed, the screenshot size
  43129. * will be derived from the parameters. The precision property is a multiplier allowing
  43130. * rendering at a higher or lower resolution
  43131. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43132. * Check your browser for supported MIME types
  43133. * @param samples Texture samples (default: 1)
  43134. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43135. * @param fileName A name for for the downloaded file.
  43136. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43137. * to the src parameter of an <img> to display it
  43138. */
  43139. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43140. /**
  43141. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43142. * Be aware Math.random() could cause collisions, but:
  43143. * "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"
  43144. * @returns a pseudo random id
  43145. */
  43146. static RandomId(): string;
  43147. /**
  43148. * Test if the given uri is a base64 string
  43149. * @param uri The uri to test
  43150. * @return True if the uri is a base64 string or false otherwise
  43151. */
  43152. static IsBase64(uri: string): boolean;
  43153. /**
  43154. * Decode the given base64 uri.
  43155. * @param uri The uri to decode
  43156. * @return The decoded base64 data.
  43157. */
  43158. static DecodeBase64(uri: string): ArrayBuffer;
  43159. /**
  43160. * Gets the absolute url.
  43161. * @param url the input url
  43162. * @return the absolute url
  43163. */
  43164. static GetAbsoluteUrl(url: string): string;
  43165. /**
  43166. * No log
  43167. */
  43168. static readonly NoneLogLevel: number;
  43169. /**
  43170. * Only message logs
  43171. */
  43172. static readonly MessageLogLevel: number;
  43173. /**
  43174. * Only warning logs
  43175. */
  43176. static readonly WarningLogLevel: number;
  43177. /**
  43178. * Only error logs
  43179. */
  43180. static readonly ErrorLogLevel: number;
  43181. /**
  43182. * All logs
  43183. */
  43184. static readonly AllLogLevel: number;
  43185. /**
  43186. * Gets a value indicating the number of loading errors
  43187. * @ignorenaming
  43188. */
  43189. static get errorsCount(): number;
  43190. /**
  43191. * Callback called when a new log is added
  43192. */
  43193. static OnNewCacheEntry: (entry: string) => void;
  43194. /**
  43195. * Log a message to the console
  43196. * @param message defines the message to log
  43197. */
  43198. static Log(message: string): void;
  43199. /**
  43200. * Write a warning message to the console
  43201. * @param message defines the message to log
  43202. */
  43203. static Warn(message: string): void;
  43204. /**
  43205. * Write an error message to the console
  43206. * @param message defines the message to log
  43207. */
  43208. static Error(message: string): void;
  43209. /**
  43210. * Gets current log cache (list of logs)
  43211. */
  43212. static get LogCache(): string;
  43213. /**
  43214. * Clears the log cache
  43215. */
  43216. static ClearLogCache(): void;
  43217. /**
  43218. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43219. */
  43220. static set LogLevels(level: number);
  43221. /**
  43222. * Checks if the window object exists
  43223. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43224. */
  43225. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43226. /**
  43227. * No performance log
  43228. */
  43229. static readonly PerformanceNoneLogLevel: number;
  43230. /**
  43231. * Use user marks to log performance
  43232. */
  43233. static readonly PerformanceUserMarkLogLevel: number;
  43234. /**
  43235. * Log performance to the console
  43236. */
  43237. static readonly PerformanceConsoleLogLevel: number;
  43238. private static _performance;
  43239. /**
  43240. * Sets the current performance log level
  43241. */
  43242. static set PerformanceLogLevel(level: number);
  43243. private static _StartPerformanceCounterDisabled;
  43244. private static _EndPerformanceCounterDisabled;
  43245. private static _StartUserMark;
  43246. private static _EndUserMark;
  43247. private static _StartPerformanceConsole;
  43248. private static _EndPerformanceConsole;
  43249. /**
  43250. * Starts a performance counter
  43251. */
  43252. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43253. /**
  43254. * Ends a specific performance coutner
  43255. */
  43256. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43257. /**
  43258. * Gets either window.performance.now() if supported or Date.now() else
  43259. */
  43260. static get Now(): number;
  43261. /**
  43262. * This method will return the name of the class used to create the instance of the given object.
  43263. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43264. * @param object the object to get the class name from
  43265. * @param isType defines if the object is actually a type
  43266. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43267. */
  43268. static GetClassName(object: any, isType?: boolean): string;
  43269. /**
  43270. * Gets the first element of an array satisfying a given predicate
  43271. * @param array defines the array to browse
  43272. * @param predicate defines the predicate to use
  43273. * @returns null if not found or the element
  43274. */
  43275. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43276. /**
  43277. * This method will return the name of the full name of the class, including its owning module (if any).
  43278. * 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).
  43279. * @param object the object to get the class name from
  43280. * @param isType defines if the object is actually a type
  43281. * @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.
  43282. * @ignorenaming
  43283. */
  43284. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43285. /**
  43286. * Returns a promise that resolves after the given amount of time.
  43287. * @param delay Number of milliseconds to delay
  43288. * @returns Promise that resolves after the given amount of time
  43289. */
  43290. static DelayAsync(delay: number): Promise<void>;
  43291. /**
  43292. * Utility function to detect if the current user agent is Safari
  43293. * @returns whether or not the current user agent is safari
  43294. */
  43295. static IsSafari(): boolean;
  43296. }
  43297. /**
  43298. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43299. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43300. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43301. * @param name The name of the class, case should be preserved
  43302. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43303. */
  43304. export function className(name: string, module?: string): (target: Object) => void;
  43305. /**
  43306. * An implementation of a loop for asynchronous functions.
  43307. */
  43308. export class AsyncLoop {
  43309. /**
  43310. * Defines the number of iterations for the loop
  43311. */
  43312. iterations: number;
  43313. /**
  43314. * Defines the current index of the loop.
  43315. */
  43316. index: number;
  43317. private _done;
  43318. private _fn;
  43319. private _successCallback;
  43320. /**
  43321. * Constructor.
  43322. * @param iterations the number of iterations.
  43323. * @param func the function to run each iteration
  43324. * @param successCallback the callback that will be called upon succesful execution
  43325. * @param offset starting offset.
  43326. */
  43327. constructor(
  43328. /**
  43329. * Defines the number of iterations for the loop
  43330. */
  43331. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43332. /**
  43333. * Execute the next iteration. Must be called after the last iteration was finished.
  43334. */
  43335. executeNext(): void;
  43336. /**
  43337. * Break the loop and run the success callback.
  43338. */
  43339. breakLoop(): void;
  43340. /**
  43341. * Create and run an async loop.
  43342. * @param iterations the number of iterations.
  43343. * @param fn the function to run each iteration
  43344. * @param successCallback the callback that will be called upon succesful execution
  43345. * @param offset starting offset.
  43346. * @returns the created async loop object
  43347. */
  43348. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43349. /**
  43350. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43351. * @param iterations total number of iterations
  43352. * @param syncedIterations number of synchronous iterations in each async iteration.
  43353. * @param fn the function to call each iteration.
  43354. * @param callback a success call back that will be called when iterating stops.
  43355. * @param breakFunction a break condition (optional)
  43356. * @param timeout timeout settings for the setTimeout function. default - 0.
  43357. * @returns the created async loop object
  43358. */
  43359. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43360. }
  43361. }
  43362. declare module BABYLON {
  43363. /**
  43364. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43365. * The underlying implementation relies on an associative array to ensure the best performances.
  43366. * The value can be anything including 'null' but except 'undefined'
  43367. */
  43368. export class StringDictionary<T> {
  43369. /**
  43370. * This will clear this dictionary and copy the content from the 'source' one.
  43371. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43372. * @param source the dictionary to take the content from and copy to this dictionary
  43373. */
  43374. copyFrom(source: StringDictionary<T>): void;
  43375. /**
  43376. * Get a value based from its key
  43377. * @param key the given key to get the matching value from
  43378. * @return the value if found, otherwise undefined is returned
  43379. */
  43380. get(key: string): T | undefined;
  43381. /**
  43382. * Get a value from its key or add it if it doesn't exist.
  43383. * This method will ensure you that a given key/data will be present in the dictionary.
  43384. * @param key the given key to get the matching value from
  43385. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43386. * The factory will only be invoked if there's no data for the given key.
  43387. * @return the value corresponding to the key.
  43388. */
  43389. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43390. /**
  43391. * Get a value from its key if present in the dictionary otherwise add it
  43392. * @param key the key to get the value from
  43393. * @param val if there's no such key/value pair in the dictionary add it with this value
  43394. * @return the value corresponding to the key
  43395. */
  43396. getOrAdd(key: string, val: T): T;
  43397. /**
  43398. * Check if there's a given key in the dictionary
  43399. * @param key the key to check for
  43400. * @return true if the key is present, false otherwise
  43401. */
  43402. contains(key: string): boolean;
  43403. /**
  43404. * Add a new key and its corresponding value
  43405. * @param key the key to add
  43406. * @param value the value corresponding to the key
  43407. * @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
  43408. */
  43409. add(key: string, value: T): boolean;
  43410. /**
  43411. * Update a specific value associated to a key
  43412. * @param key defines the key to use
  43413. * @param value defines the value to store
  43414. * @returns true if the value was updated (or false if the key was not found)
  43415. */
  43416. set(key: string, value: T): boolean;
  43417. /**
  43418. * Get the element of the given key and remove it from the dictionary
  43419. * @param key defines the key to search
  43420. * @returns the value associated with the key or null if not found
  43421. */
  43422. getAndRemove(key: string): Nullable<T>;
  43423. /**
  43424. * Remove a key/value from the dictionary.
  43425. * @param key the key to remove
  43426. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43427. */
  43428. remove(key: string): boolean;
  43429. /**
  43430. * Clear the whole content of the dictionary
  43431. */
  43432. clear(): void;
  43433. /**
  43434. * Gets the current count
  43435. */
  43436. get count(): number;
  43437. /**
  43438. * Execute a callback on each key/val of the dictionary.
  43439. * Note that you can remove any element in this dictionary in the callback implementation
  43440. * @param callback the callback to execute on a given key/value pair
  43441. */
  43442. forEach(callback: (key: string, val: T) => void): void;
  43443. /**
  43444. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43445. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43446. * Note that you can remove any element in this dictionary in the callback implementation
  43447. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43448. * @returns the first item
  43449. */
  43450. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43451. private _count;
  43452. private _data;
  43453. }
  43454. }
  43455. declare module BABYLON {
  43456. /** @hidden */
  43457. export interface ICollisionCoordinator {
  43458. createCollider(): Collider;
  43459. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43460. init(scene: Scene): void;
  43461. }
  43462. /** @hidden */
  43463. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43464. private _scene;
  43465. private _scaledPosition;
  43466. private _scaledVelocity;
  43467. private _finalPosition;
  43468. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43469. createCollider(): Collider;
  43470. init(scene: Scene): void;
  43471. private _collideWithWorld;
  43472. }
  43473. }
  43474. declare module BABYLON {
  43475. /**
  43476. * Class used to manage all inputs for the scene.
  43477. */
  43478. export class InputManager {
  43479. /** The distance in pixel that you have to move to prevent some events */
  43480. static DragMovementThreshold: number;
  43481. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43482. static LongPressDelay: number;
  43483. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43484. static DoubleClickDelay: number;
  43485. /** If you need to check double click without raising a single click at first click, enable this flag */
  43486. static ExclusiveDoubleClickMode: boolean;
  43487. /** 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. */
  43488. private _alreadyAttached;
  43489. private _alreadyAttachedTo;
  43490. private _wheelEventName;
  43491. private _onPointerMove;
  43492. private _onPointerDown;
  43493. private _onPointerUp;
  43494. private _initClickEvent;
  43495. private _initActionManager;
  43496. private _delayedSimpleClick;
  43497. private _delayedSimpleClickTimeout;
  43498. private _previousDelayedSimpleClickTimeout;
  43499. private _meshPickProceed;
  43500. private _previousButtonPressed;
  43501. private _currentPickResult;
  43502. private _previousPickResult;
  43503. private _totalPointersPressed;
  43504. private _doubleClickOccured;
  43505. private _pointerOverMesh;
  43506. private _pickedDownMesh;
  43507. private _pickedUpMesh;
  43508. private _pointerX;
  43509. private _pointerY;
  43510. private _unTranslatedPointerX;
  43511. private _unTranslatedPointerY;
  43512. private _startingPointerPosition;
  43513. private _previousStartingPointerPosition;
  43514. private _startingPointerTime;
  43515. private _previousStartingPointerTime;
  43516. private _pointerCaptures;
  43517. private _meshUnderPointerId;
  43518. private _onKeyDown;
  43519. private _onKeyUp;
  43520. private _keyboardIsAttached;
  43521. private _onCanvasFocusObserver;
  43522. private _onCanvasBlurObserver;
  43523. private _scene;
  43524. /**
  43525. * Creates a new InputManager
  43526. * @param scene defines the hosting scene
  43527. */
  43528. constructor(scene: Scene);
  43529. /**
  43530. * Gets the mesh that is currently under the pointer
  43531. */
  43532. get meshUnderPointer(): Nullable<AbstractMesh>;
  43533. /**
  43534. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43535. * @param pointerId the pointer id to use
  43536. * @returns The mesh under this pointer id or null if not found
  43537. */
  43538. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43539. /**
  43540. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43541. */
  43542. get unTranslatedPointer(): Vector2;
  43543. /**
  43544. * Gets or sets the current on-screen X position of the pointer
  43545. */
  43546. get pointerX(): number;
  43547. set pointerX(value: number);
  43548. /**
  43549. * Gets or sets the current on-screen Y position of the pointer
  43550. */
  43551. get pointerY(): number;
  43552. set pointerY(value: number);
  43553. private _updatePointerPosition;
  43554. private _processPointerMove;
  43555. private _setRayOnPointerInfo;
  43556. private _checkPrePointerObservable;
  43557. /**
  43558. * Use this method to simulate a pointer move on a mesh
  43559. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43560. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43561. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43562. */
  43563. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43564. /**
  43565. * Use this method to simulate a pointer down on a mesh
  43566. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43567. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43568. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43569. */
  43570. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43571. private _processPointerDown;
  43572. /** @hidden */
  43573. _isPointerSwiping(): boolean;
  43574. /**
  43575. * Use this method to simulate a pointer up on a mesh
  43576. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43577. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43578. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43579. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43580. */
  43581. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43582. private _processPointerUp;
  43583. /**
  43584. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43585. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43586. * @returns true if the pointer was captured
  43587. */
  43588. isPointerCaptured(pointerId?: number): boolean;
  43589. /**
  43590. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43591. * @param attachUp defines if you want to attach events to pointerup
  43592. * @param attachDown defines if you want to attach events to pointerdown
  43593. * @param attachMove defines if you want to attach events to pointermove
  43594. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43595. */
  43596. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43597. /**
  43598. * Detaches all event handlers
  43599. */
  43600. detachControl(): void;
  43601. /**
  43602. * Force the value of meshUnderPointer
  43603. * @param mesh defines the mesh to use
  43604. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43605. */
  43606. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43607. /**
  43608. * Gets the mesh under the pointer
  43609. * @returns a Mesh or null if no mesh is under the pointer
  43610. */
  43611. getPointerOverMesh(): Nullable<AbstractMesh>;
  43612. }
  43613. }
  43614. declare module BABYLON {
  43615. /**
  43616. * This class defines the direct association between an animation and a target
  43617. */
  43618. export class TargetedAnimation {
  43619. /**
  43620. * Animation to perform
  43621. */
  43622. animation: Animation;
  43623. /**
  43624. * Target to animate
  43625. */
  43626. target: any;
  43627. /**
  43628. * Returns the string "TargetedAnimation"
  43629. * @returns "TargetedAnimation"
  43630. */
  43631. getClassName(): string;
  43632. /**
  43633. * Serialize the object
  43634. * @returns the JSON object representing the current entity
  43635. */
  43636. serialize(): any;
  43637. }
  43638. /**
  43639. * Use this class to create coordinated animations on multiple targets
  43640. */
  43641. export class AnimationGroup implements IDisposable {
  43642. /** The name of the animation group */
  43643. name: string;
  43644. private _scene;
  43645. private _targetedAnimations;
  43646. private _animatables;
  43647. private _from;
  43648. private _to;
  43649. private _isStarted;
  43650. private _isPaused;
  43651. private _speedRatio;
  43652. private _loopAnimation;
  43653. private _isAdditive;
  43654. /**
  43655. * Gets or sets the unique id of the node
  43656. */
  43657. uniqueId: number;
  43658. /**
  43659. * This observable will notify when one animation have ended
  43660. */
  43661. onAnimationEndObservable: Observable<TargetedAnimation>;
  43662. /**
  43663. * Observer raised when one animation loops
  43664. */
  43665. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43666. /**
  43667. * Observer raised when all animations have looped
  43668. */
  43669. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43670. /**
  43671. * This observable will notify when all animations have ended.
  43672. */
  43673. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43674. /**
  43675. * This observable will notify when all animations have paused.
  43676. */
  43677. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43678. /**
  43679. * This observable will notify when all animations are playing.
  43680. */
  43681. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43682. /**
  43683. * Gets the first frame
  43684. */
  43685. get from(): number;
  43686. /**
  43687. * Gets the last frame
  43688. */
  43689. get to(): number;
  43690. /**
  43691. * Define if the animations are started
  43692. */
  43693. get isStarted(): boolean;
  43694. /**
  43695. * Gets a value indicating that the current group is playing
  43696. */
  43697. get isPlaying(): boolean;
  43698. /**
  43699. * Gets or sets the speed ratio to use for all animations
  43700. */
  43701. get speedRatio(): number;
  43702. /**
  43703. * Gets or sets the speed ratio to use for all animations
  43704. */
  43705. set speedRatio(value: number);
  43706. /**
  43707. * Gets or sets if all animations should loop or not
  43708. */
  43709. get loopAnimation(): boolean;
  43710. set loopAnimation(value: boolean);
  43711. /**
  43712. * Gets or sets if all animations should be evaluated additively
  43713. */
  43714. get isAdditive(): boolean;
  43715. set isAdditive(value: boolean);
  43716. /**
  43717. * Gets the targeted animations for this animation group
  43718. */
  43719. get targetedAnimations(): Array<TargetedAnimation>;
  43720. /**
  43721. * returning the list of animatables controlled by this animation group.
  43722. */
  43723. get animatables(): Array<Animatable>;
  43724. /**
  43725. * Gets the list of target animations
  43726. */
  43727. get children(): TargetedAnimation[];
  43728. /**
  43729. * Instantiates a new Animation Group.
  43730. * This helps managing several animations at once.
  43731. * @see https://doc.babylonjs.com/how_to/group
  43732. * @param name Defines the name of the group
  43733. * @param scene Defines the scene the group belongs to
  43734. */
  43735. constructor(
  43736. /** The name of the animation group */
  43737. name: string, scene?: Nullable<Scene>);
  43738. /**
  43739. * Add an animation (with its target) in the group
  43740. * @param animation defines the animation we want to add
  43741. * @param target defines the target of the animation
  43742. * @returns the TargetedAnimation object
  43743. */
  43744. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43745. /**
  43746. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43747. * It can add constant keys at begin or end
  43748. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43749. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43750. * @returns the animation group
  43751. */
  43752. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43753. private _animationLoopCount;
  43754. private _animationLoopFlags;
  43755. private _processLoop;
  43756. /**
  43757. * Start all animations on given targets
  43758. * @param loop defines if animations must loop
  43759. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43760. * @param from defines the from key (optional)
  43761. * @param to defines the to key (optional)
  43762. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43763. * @returns the current animation group
  43764. */
  43765. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43766. /**
  43767. * Pause all animations
  43768. * @returns the animation group
  43769. */
  43770. pause(): AnimationGroup;
  43771. /**
  43772. * Play all animations to initial state
  43773. * This function will start() the animations if they were not started or will restart() them if they were paused
  43774. * @param loop defines if animations must loop
  43775. * @returns the animation group
  43776. */
  43777. play(loop?: boolean): AnimationGroup;
  43778. /**
  43779. * Reset all animations to initial state
  43780. * @returns the animation group
  43781. */
  43782. reset(): AnimationGroup;
  43783. /**
  43784. * Restart animations from key 0
  43785. * @returns the animation group
  43786. */
  43787. restart(): AnimationGroup;
  43788. /**
  43789. * Stop all animations
  43790. * @returns the animation group
  43791. */
  43792. stop(): AnimationGroup;
  43793. /**
  43794. * Set animation weight for all animatables
  43795. * @param weight defines the weight to use
  43796. * @return the animationGroup
  43797. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43798. */
  43799. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43800. /**
  43801. * Synchronize and normalize all animatables with a source animatable
  43802. * @param root defines the root animatable to synchronize with
  43803. * @return the animationGroup
  43804. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43805. */
  43806. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43807. /**
  43808. * Goes to a specific frame in this animation group
  43809. * @param frame the frame number to go to
  43810. * @return the animationGroup
  43811. */
  43812. goToFrame(frame: number): AnimationGroup;
  43813. /**
  43814. * Dispose all associated resources
  43815. */
  43816. dispose(): void;
  43817. private _checkAnimationGroupEnded;
  43818. /**
  43819. * Clone the current animation group and returns a copy
  43820. * @param newName defines the name of the new group
  43821. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43822. * @returns the new aniamtion group
  43823. */
  43824. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43825. /**
  43826. * Serializes the animationGroup to an object
  43827. * @returns Serialized object
  43828. */
  43829. serialize(): any;
  43830. /**
  43831. * Returns a new AnimationGroup object parsed from the source provided.
  43832. * @param parsedAnimationGroup defines the source
  43833. * @param scene defines the scene that will receive the animationGroup
  43834. * @returns a new AnimationGroup
  43835. */
  43836. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43837. /**
  43838. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43839. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43840. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43841. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43842. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43843. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43844. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43845. */
  43846. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43847. /**
  43848. * Returns the string "AnimationGroup"
  43849. * @returns "AnimationGroup"
  43850. */
  43851. getClassName(): string;
  43852. /**
  43853. * Creates a detailled string about the object
  43854. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43855. * @returns a string representing the object
  43856. */
  43857. toString(fullDetails?: boolean): string;
  43858. }
  43859. }
  43860. declare module BABYLON {
  43861. /**
  43862. * @hidden
  43863. **/
  43864. export class _TimeToken {
  43865. _startTimeQuery: Nullable<WebGLQuery>;
  43866. _endTimeQuery: Nullable<WebGLQuery>;
  43867. _timeElapsedQuery: Nullable<WebGLQuery>;
  43868. _timeElapsedQueryEnded: boolean;
  43869. }
  43870. }
  43871. declare module BABYLON {
  43872. /** @hidden */
  43873. export enum ExtensionName {
  43874. DepthClamping = "depth-clamping",
  43875. Depth24UnormStencil8 = "depth24unorm-stencil8",
  43876. Depth32FloatStencil8 = "depth32float-stencil8",
  43877. PipelineStatisticsQuery = "pipeline-statistics-query",
  43878. TextureCompressionBC = "texture-compression-bc",
  43879. TimestampQuery = "timestamp-query"
  43880. }
  43881. /** @hidden */
  43882. export enum AddressMode {
  43883. ClampToEdge = "clamp-to-edge",
  43884. Repeat = "repeat",
  43885. MirrorRepeat = "mirror-repeat"
  43886. }
  43887. /** @hidden */
  43888. export enum BindingType {
  43889. UniformBuffer = "uniform-buffer",
  43890. StorageBuffer = "storage-buffer",
  43891. ReadonlyStorageBuffer = "readonly-storage-buffer",
  43892. Sampler = "sampler",
  43893. ComparisonSampler = "comparison-sampler",
  43894. SampledTexture = "sampled-texture",
  43895. ReadonlyStorageTexture = "readonly-storage-texture",
  43896. WriteonlyStorageTexture = "writeonly-storage-texture"
  43897. }
  43898. /** @hidden */
  43899. export enum BlendFactor {
  43900. Zero = "zero",
  43901. One = "one",
  43902. SrcColor = "src-color",
  43903. OneMinusSrcColor = "one-minus-src-color",
  43904. SrcAlpha = "src-alpha",
  43905. OneMinusSrcAlpha = "one-minus-src-alpha",
  43906. DstColor = "dst-color",
  43907. OneMinusDstColor = "one-minus-dst-color",
  43908. DstAlpha = "dst-alpha",
  43909. OneMinusDstAlpha = "one-minus-dst-alpha",
  43910. SrcAlphaSaturated = "src-alpha-saturated",
  43911. BlendColor = "blend-color",
  43912. OneMinusBlendColor = "one-minus-blend-color"
  43913. }
  43914. /** @hidden */
  43915. export enum BlendOperation {
  43916. Add = "add",
  43917. Subtract = "subtract",
  43918. ReverseSubtract = "reverse-subtract",
  43919. Min = "min",
  43920. Max = "max"
  43921. }
  43922. /** @hidden */
  43923. export enum CompareFunction {
  43924. Never = "never",
  43925. Less = "less",
  43926. Equal = "equal",
  43927. LessEqual = "less-equal",
  43928. Greater = "greater",
  43929. NotEqual = "not-equal",
  43930. GreaterEqual = "greater-equal",
  43931. Always = "always"
  43932. }
  43933. /** @hidden */
  43934. export enum CullMode {
  43935. None = "none",
  43936. Front = "front",
  43937. Back = "back"
  43938. }
  43939. /** @hidden */
  43940. export enum FilterMode {
  43941. Nearest = "nearest",
  43942. Linear = "linear"
  43943. }
  43944. /** @hidden */
  43945. export enum FrontFace {
  43946. CCW = "ccw",
  43947. CW = "cw"
  43948. }
  43949. /** @hidden */
  43950. export enum IndexFormat {
  43951. Uint16 = "uint16",
  43952. Uint32 = "uint32"
  43953. }
  43954. /** @hidden */
  43955. export enum InputStepMode {
  43956. Vertex = "vertex",
  43957. Instance = "instance"
  43958. }
  43959. /** @hidden */
  43960. export enum LoadOp {
  43961. Load = "load"
  43962. }
  43963. /** @hidden */
  43964. export enum PrimitiveTopology {
  43965. PointList = "point-list",
  43966. LineList = "line-list",
  43967. LineStrip = "line-strip",
  43968. TriangleList = "triangle-list",
  43969. TriangleStrip = "triangle-strip"
  43970. }
  43971. /** @hidden */
  43972. export enum StencilOperation {
  43973. Keep = "keep",
  43974. Zero = "zero",
  43975. Replace = "replace",
  43976. Invert = "invert",
  43977. IncrementClamp = "increment-clamp",
  43978. DecrementClamp = "decrement-clamp",
  43979. IncrementWrap = "increment-wrap",
  43980. DecrementWrap = "decrement-wrap"
  43981. }
  43982. /** @hidden */
  43983. export enum StoreOp {
  43984. Store = "store",
  43985. Clear = "clear"
  43986. }
  43987. /** @hidden */
  43988. export enum TextureDimension {
  43989. E1d = "1d",
  43990. E2d = "2d",
  43991. E3d = "3d"
  43992. }
  43993. /** @hidden */
  43994. export enum TextureFormat {
  43995. R8Unorm = "r8unorm",
  43996. R8Snorm = "r8snorm",
  43997. R8Uint = "r8uint",
  43998. R8Sint = "r8sint",
  43999. R16Uint = "r16uint",
  44000. R16Sint = "r16sint",
  44001. R16Float = "r16float",
  44002. RG8Unorm = "rg8unorm",
  44003. RG8Snorm = "rg8snorm",
  44004. RG8Uint = "rg8uint",
  44005. RG8Sint = "rg8sint",
  44006. R32Uint = "r32uint",
  44007. R32Sint = "r32sint",
  44008. R32Float = "r32float",
  44009. RG16Uint = "rg16uint",
  44010. RG16Sint = "rg16sint",
  44011. RG16Float = "rg16float",
  44012. RGBA8Unorm = "rgba8unorm",
  44013. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44014. RGBA8Snorm = "rgba8snorm",
  44015. RGBA8Uint = "rgba8uint",
  44016. RGBA8Sint = "rgba8sint",
  44017. BGRA8Unorm = "bgra8unorm",
  44018. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44019. RGB9E5UFloat = "rgb9e5ufloat",
  44020. RGB10A2Unorm = "rgb10a2unorm",
  44021. RG11B10UFloat = "rg11b10ufloat",
  44022. RG32Uint = "rg32uint",
  44023. RG32Sint = "rg32sint",
  44024. RG32Float = "rg32float",
  44025. RGBA16Uint = "rgba16uint",
  44026. RGBA16Sint = "rgba16sint",
  44027. RGBA16Float = "rgba16float",
  44028. RGBA32Uint = "rgba32uint",
  44029. RGBA32Sint = "rgba32sint",
  44030. RGBA32Float = "rgba32float",
  44031. Stencil8 = "stencil8",
  44032. Depth16Unorm = "depth16unorm",
  44033. Depth24Plus = "depth24plus",
  44034. Depth24PlusStencil8 = "depth24plus-stencil8",
  44035. Depth32Float = "depth32float",
  44036. BC1RGBAUNorm = "bc1-rgba-unorm",
  44037. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44038. BC2RGBAUnorm = "bc2-rgba-unorm",
  44039. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44040. BC3RGBAUnorm = "bc3-rgba-unorm",
  44041. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44042. BC4RUnorm = "bc4-r-unorm",
  44043. BC4RSnorm = "bc4-r-snorm",
  44044. BC5RGUnorm = "bc5-rg-unorm",
  44045. BC5RGSnorm = "bc5-rg-snorm",
  44046. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44047. BC6HRGBFloat = "bc6h-rgb-float",
  44048. BC7RGBAUnorm = "bc7-rgba-unorm",
  44049. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44050. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44051. Depth32FloatStencil8 = "depth32float-stencil8"
  44052. }
  44053. /** @hidden */
  44054. export enum TextureComponentType {
  44055. Float = "float",
  44056. Sint = "sint",
  44057. Uint = "uint",
  44058. DepthComparison = "depth-comparison"
  44059. }
  44060. /** @hidden */
  44061. export enum TextureViewDimension {
  44062. E1d = "1d",
  44063. E2d = "2d",
  44064. E2dArray = "2d-array",
  44065. Cube = "cube",
  44066. CubeArray = "cube-array",
  44067. E3d = "3d"
  44068. }
  44069. /** @hidden */
  44070. export enum VertexFormat {
  44071. Uchar2 = "uchar2",
  44072. Uchar4 = "uchar4",
  44073. Char2 = "char2",
  44074. Char4 = "char4",
  44075. Uchar2Norm = "uchar2norm",
  44076. Uchar4Norm = "uchar4norm",
  44077. Char2Norm = "char2norm",
  44078. Char4Norm = "char4norm",
  44079. Ushort2 = "ushort2",
  44080. Ushort4 = "ushort4",
  44081. Short2 = "short2",
  44082. Short4 = "short4",
  44083. Ushort2Norm = "ushort2norm",
  44084. Ushort4Norm = "ushort4norm",
  44085. Short2Norm = "short2norm",
  44086. Short4Norm = "short4norm",
  44087. Half2 = "half2",
  44088. Half4 = "half4",
  44089. Float = "float",
  44090. Float2 = "float2",
  44091. Float3 = "float3",
  44092. Float4 = "float4",
  44093. Uint = "uint",
  44094. Uint2 = "uint2",
  44095. Uint3 = "uint3",
  44096. Uint4 = "uint4",
  44097. Int = "int",
  44098. Int2 = "int2",
  44099. Int3 = "int3",
  44100. Int4 = "int4"
  44101. }
  44102. /** @hidden */
  44103. export enum TextureAspect {
  44104. All = "all",
  44105. StencilOnly = "stencil-only",
  44106. DepthOnly = "depth-only"
  44107. }
  44108. /** @hidden */
  44109. export enum CompilationMessageType {
  44110. Error = "error",
  44111. Warning = "warning",
  44112. Info = "info"
  44113. }
  44114. /** @hidden */
  44115. export enum QueryType {
  44116. Occlusion = "occlusion"
  44117. }
  44118. /** @hidden */
  44119. export enum BufferUsage {
  44120. MapRead = 1,
  44121. MapWrite = 2,
  44122. CopySrc = 4,
  44123. CopyDst = 8,
  44124. Index = 16,
  44125. Vertex = 32,
  44126. Uniform = 64,
  44127. Storage = 128,
  44128. Indirect = 256,
  44129. QueryResolve = 512
  44130. }
  44131. /** @hidden */
  44132. export enum ColorWrite {
  44133. Red = 1,
  44134. Green = 2,
  44135. Blue = 4,
  44136. Alpha = 8,
  44137. All = 15
  44138. }
  44139. /** @hidden */
  44140. export enum ShaderStage {
  44141. Vertex = 1,
  44142. Fragment = 2,
  44143. Compute = 4
  44144. }
  44145. /** @hidden */
  44146. export enum TextureUsage {
  44147. CopySrc = 1,
  44148. CopyDst = 2,
  44149. Sampled = 4,
  44150. Storage = 8,
  44151. OutputAttachment = 16
  44152. }
  44153. /** @hidden */
  44154. export enum MapMode {
  44155. Read = 1,
  44156. Write = 2
  44157. }
  44158. }
  44159. declare module BABYLON {
  44160. /** @hidden */
  44161. export interface WebGPUBindingInfo {
  44162. setIndex: number;
  44163. bindingIndex: number;
  44164. }
  44165. /** @hidden */
  44166. export interface WebGPUTextureSamplerBindingDescription {
  44167. sampler: WebGPUBindingInfo;
  44168. isTextureArray: boolean;
  44169. textures: Array<WebGPUBindingInfo>;
  44170. }
  44171. /** @hidden
  44172. * If the binding is a UBO, isSampler=isTexture=false
  44173. */
  44174. export interface WebGPUBindingDescription {
  44175. name: string;
  44176. usedInVertex: boolean;
  44177. usedInFragment: boolean;
  44178. isSampler: boolean;
  44179. isComparisonSampler?: boolean;
  44180. isTexture: boolean;
  44181. componentType?: GPUTextureComponentType;
  44182. textureDimension?: GPUTextureViewDimension;
  44183. }
  44184. /**
  44185. * @hidden
  44186. */
  44187. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44188. uboNextBindingIndex: number;
  44189. freeSetIndex: number;
  44190. freeBindingIndex: number;
  44191. availableVaryings: {
  44192. [key: string]: number;
  44193. };
  44194. availableAttributes: {
  44195. [key: string]: number;
  44196. };
  44197. availableUBOs: {
  44198. [key: string]: {
  44199. setIndex: number;
  44200. bindingIndex: number;
  44201. };
  44202. };
  44203. availableSamplers: {
  44204. [key: string]: WebGPUTextureSamplerBindingDescription;
  44205. };
  44206. leftOverUniforms: {
  44207. name: string;
  44208. type: string;
  44209. length: number;
  44210. }[];
  44211. orderedAttributes: string[];
  44212. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44213. private _attributeNextLocation;
  44214. private _varyingNextLocation;
  44215. constructor();
  44216. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44217. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44218. getNextFreeUBOBinding(): {
  44219. setIndex: number;
  44220. bindingIndex: number;
  44221. };
  44222. private _getNextFreeBinding;
  44223. }
  44224. }
  44225. declare module BABYLON {
  44226. /** @hidden */
  44227. export interface IWebGPUPipelineContextSamplerCache {
  44228. samplerBinding: number;
  44229. firstTextureName: string;
  44230. }
  44231. /** @hidden */
  44232. export interface IWebGPUPipelineContextTextureCache {
  44233. textureBinding: number;
  44234. texture: InternalTexture;
  44235. }
  44236. /** @hidden */
  44237. export interface IWebGPUPipelineContextVertexInputsCache {
  44238. indexBuffer: Nullable<GPUBuffer>;
  44239. indexOffset: number;
  44240. vertexStartSlot: number;
  44241. vertexBuffers: GPUBuffer[];
  44242. vertexOffsets: number[];
  44243. }
  44244. /** @hidden */
  44245. export interface IWebGPURenderPipelineStageDescriptor {
  44246. vertexStage: GPUProgrammableStageDescriptor;
  44247. fragmentStage?: GPUProgrammableStageDescriptor;
  44248. }
  44249. /** @hidden */
  44250. export class WebGPUPipelineContext implements IPipelineContext {
  44251. engine: WebGPUEngine;
  44252. shaderProcessingContext: WebGPUShaderProcessingContext;
  44253. leftOverUniformsByName: {
  44254. [name: string]: string;
  44255. };
  44256. sources: {
  44257. vertex: string;
  44258. fragment: string;
  44259. rawVertex: string;
  44260. rawFragment: string;
  44261. };
  44262. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44263. samplers: {
  44264. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44265. };
  44266. textures: {
  44267. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44268. };
  44269. bindGroupLayouts: GPUBindGroupLayout[];
  44270. /**
  44271. * Stores the uniform buffer
  44272. */
  44273. uniformBuffer: Nullable<UniformBuffer>;
  44274. onCompiled?: () => void;
  44275. get isAsync(): boolean;
  44276. get isReady(): boolean;
  44277. /** @hidden */
  44278. _name: string;
  44279. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44280. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44281. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44282. [key: string]: number;
  44283. }, uniformsNames: string[], uniforms: {
  44284. [key: string]: Nullable<WebGLUniformLocation>;
  44285. }, samplerList: string[], samplers: {
  44286. [key: string]: number;
  44287. }, attributesNames: string[], attributes: number[]): void;
  44288. /** @hidden */
  44289. /**
  44290. * Build the uniform buffer used in the material.
  44291. */
  44292. buildUniformLayout(): void;
  44293. /**
  44294. * Release all associated resources.
  44295. **/
  44296. dispose(): void;
  44297. /**
  44298. * Sets an integer value on a uniform variable.
  44299. * @param uniformName Name of the variable.
  44300. * @param value Value to be set.
  44301. */
  44302. setInt(uniformName: string, value: number): void;
  44303. /**
  44304. * Sets an int2 value on a uniform variable.
  44305. * @param uniformName Name of the variable.
  44306. * @param x First int in int2.
  44307. * @param y Second int in int2.
  44308. */
  44309. setInt2(uniformName: string, x: number, y: number): void;
  44310. /**
  44311. * Sets an int3 value on a uniform variable.
  44312. * @param uniformName Name of the variable.
  44313. * @param x First int in int3.
  44314. * @param y Second int in int3.
  44315. * @param z Third int in int3.
  44316. */
  44317. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44318. /**
  44319. * Sets an int4 value on a uniform variable.
  44320. * @param uniformName Name of the variable.
  44321. * @param x First int in int4.
  44322. * @param y Second int in int4.
  44323. * @param z Third int in int4.
  44324. * @param w Fourth int in int4.
  44325. */
  44326. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44327. /**
  44328. * Sets an int array on a uniform variable.
  44329. * @param uniformName Name of the variable.
  44330. * @param array array to be set.
  44331. */
  44332. setIntArray(uniformName: string, array: Int32Array): void;
  44333. /**
  44334. * 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)
  44335. * @param uniformName Name of the variable.
  44336. * @param array array to be set.
  44337. */
  44338. setIntArray2(uniformName: string, array: Int32Array): void;
  44339. /**
  44340. * 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)
  44341. * @param uniformName Name of the variable.
  44342. * @param array array to be set.
  44343. */
  44344. setIntArray3(uniformName: string, array: Int32Array): void;
  44345. /**
  44346. * 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)
  44347. * @param uniformName Name of the variable.
  44348. * @param array array to be set.
  44349. */
  44350. setIntArray4(uniformName: string, array: Int32Array): void;
  44351. /**
  44352. * Sets an array on a uniform variable.
  44353. * @param uniformName Name of the variable.
  44354. * @param array array to be set.
  44355. */
  44356. setArray(uniformName: string, array: number[]): void;
  44357. /**
  44358. * 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)
  44359. * @param uniformName Name of the variable.
  44360. * @param array array to be set.
  44361. */
  44362. setArray2(uniformName: string, array: number[]): void;
  44363. /**
  44364. * 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)
  44365. * @param uniformName Name of the variable.
  44366. * @param array array to be set.
  44367. * @returns this effect.
  44368. */
  44369. setArray3(uniformName: string, array: number[]): void;
  44370. /**
  44371. * 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)
  44372. * @param uniformName Name of the variable.
  44373. * @param array array to be set.
  44374. */
  44375. setArray4(uniformName: string, array: number[]): void;
  44376. /**
  44377. * Sets matrices on a uniform variable.
  44378. * @param uniformName Name of the variable.
  44379. * @param matrices matrices to be set.
  44380. */
  44381. setMatrices(uniformName: string, matrices: Float32Array): void;
  44382. /**
  44383. * Sets matrix on a uniform variable.
  44384. * @param uniformName Name of the variable.
  44385. * @param matrix matrix to be set.
  44386. */
  44387. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44388. /**
  44389. * 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)
  44390. * @param uniformName Name of the variable.
  44391. * @param matrix matrix to be set.
  44392. */
  44393. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44394. /**
  44395. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44396. * @param uniformName Name of the variable.
  44397. * @param matrix matrix to be set.
  44398. */
  44399. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44400. /**
  44401. * Sets a float on a uniform variable.
  44402. * @param uniformName Name of the variable.
  44403. * @param value value to be set.
  44404. * @returns this effect.
  44405. */
  44406. setFloat(uniformName: string, value: number): void;
  44407. /**
  44408. * Sets a Vector2 on a uniform variable.
  44409. * @param uniformName Name of the variable.
  44410. * @param vector2 vector2 to be set.
  44411. */
  44412. setVector2(uniformName: string, vector2: IVector2Like): void;
  44413. /**
  44414. * Sets a float2 on a uniform variable.
  44415. * @param uniformName Name of the variable.
  44416. * @param x First float in float2.
  44417. * @param y Second float in float2.
  44418. */
  44419. setFloat2(uniformName: string, x: number, y: number): void;
  44420. /**
  44421. * Sets a Vector3 on a uniform variable.
  44422. * @param uniformName Name of the variable.
  44423. * @param vector3 Value to be set.
  44424. */
  44425. setVector3(uniformName: string, vector3: IVector3Like): void;
  44426. /**
  44427. * Sets a float3 on a uniform variable.
  44428. * @param uniformName Name of the variable.
  44429. * @param x First float in float3.
  44430. * @param y Second float in float3.
  44431. * @param z Third float in float3.
  44432. */
  44433. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44434. /**
  44435. * Sets a Vector4 on a uniform variable.
  44436. * @param uniformName Name of the variable.
  44437. * @param vector4 Value to be set.
  44438. */
  44439. setVector4(uniformName: string, vector4: IVector4Like): void;
  44440. /**
  44441. * Sets a float4 on a uniform variable.
  44442. * @param uniformName Name of the variable.
  44443. * @param x First float in float4.
  44444. * @param y Second float in float4.
  44445. * @param z Third float in float4.
  44446. * @param w Fourth float in float4.
  44447. * @returns this effect.
  44448. */
  44449. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44450. /**
  44451. * Sets a Color3 on a uniform variable.
  44452. * @param uniformName Name of the variable.
  44453. * @param color3 Value to be set.
  44454. */
  44455. setColor3(uniformName: string, color3: IColor3Like): void;
  44456. /**
  44457. * Sets a Color4 on a uniform variable.
  44458. * @param uniformName Name of the variable.
  44459. * @param color3 Value to be set.
  44460. * @param alpha Alpha value to be set.
  44461. */
  44462. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44463. /**
  44464. * Sets a Color4 on a uniform variable
  44465. * @param uniformName defines the name of the variable
  44466. * @param color4 defines the value to be set
  44467. */
  44468. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44469. _getVertexShaderCode(): string | null;
  44470. _getFragmentShaderCode(): string | null;
  44471. }
  44472. }
  44473. declare module BABYLON {
  44474. /** @hidden */
  44475. export class WebGPUDataBuffer extends DataBuffer {
  44476. private _buffer;
  44477. constructor(resource: GPUBuffer);
  44478. get underlyingResource(): any;
  44479. }
  44480. }
  44481. declare module BABYLON {
  44482. /**
  44483. * Class used to inline functions in shader code
  44484. */
  44485. export class ShaderCodeInliner {
  44486. private static readonly _RegexpFindFunctionNameAndType;
  44487. private _sourceCode;
  44488. private _functionDescr;
  44489. private _numMaxIterations;
  44490. /** Gets or sets the token used to mark the functions to inline */
  44491. inlineToken: string;
  44492. /** Gets or sets the debug mode */
  44493. debug: boolean;
  44494. /** Gets the code after the inlining process */
  44495. get code(): string;
  44496. /**
  44497. * Initializes the inliner
  44498. * @param sourceCode shader code source to inline
  44499. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44500. */
  44501. constructor(sourceCode: string, numMaxIterations?: number);
  44502. /**
  44503. * Start the processing of the shader code
  44504. */
  44505. processCode(): void;
  44506. private _collectFunctions;
  44507. private _processInlining;
  44508. private _extractBetweenMarkers;
  44509. private _skipWhitespaces;
  44510. private _isIdentifierChar;
  44511. private _removeComments;
  44512. private _replaceFunctionCallsByCode;
  44513. private _findBackward;
  44514. private _escapeRegExp;
  44515. private _replaceNames;
  44516. }
  44517. }
  44518. declare module BABYLON {
  44519. /** @hidden */
  44520. export class WebGPUShaderProcessor implements IShaderProcessor {
  44521. protected _missingVaryings: Array<string>;
  44522. protected _textureArrayProcessing: Array<string>;
  44523. protected _preProcessors: {
  44524. [key: string]: string;
  44525. };
  44526. private _getArraySize;
  44527. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44528. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44529. [key: string]: string;
  44530. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44531. attributeProcessor(attribute: string, preProcessors: {
  44532. [key: string]: string;
  44533. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44534. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44535. [key: string]: string;
  44536. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44537. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44538. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44539. private _applyTextureArrayProcessing;
  44540. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44541. vertexCode: string;
  44542. fragmentCode: string;
  44543. };
  44544. }
  44545. }
  44546. declare module BABYLON {
  44547. /** @hidden */
  44548. export class WebGPUBufferManager {
  44549. private _device;
  44550. private _deferredReleaseBuffers;
  44551. private static _IsGPUBuffer;
  44552. constructor(device: GPUDevice);
  44553. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44554. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44555. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44556. private _FromHalfFloat;
  44557. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44558. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44559. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44560. destroyDeferredBuffers(): void;
  44561. }
  44562. }
  44563. declare module BABYLON {
  44564. /** @hidden */
  44565. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  44566. private _webgpuTexture;
  44567. private _webgpuMSAATexture;
  44568. get underlyingResource(): Nullable<GPUTexture>;
  44569. get msaaTexture(): Nullable<GPUTexture>;
  44570. set msaaTexture(texture: Nullable<GPUTexture>);
  44571. view: Nullable<GPUTextureView>;
  44572. format: GPUTextureFormat;
  44573. textureUsages: number;
  44574. constructor(existingTexture?: Nullable<GPUTexture>);
  44575. set(hardwareTexture: GPUTexture): void;
  44576. setMSAATexture(hardwareTexture: GPUTexture): void;
  44577. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  44578. createView(descriptor?: GPUTextureViewDescriptor): void;
  44579. reset(): void;
  44580. release(): void;
  44581. }
  44582. }
  44583. declare module BABYLON {
  44584. /** @hidden */
  44585. export class WebGPUTextureHelper {
  44586. private _device;
  44587. private _glslang;
  44588. private _bufferManager;
  44589. private _mipmapSampler;
  44590. private _invertYPreMultiplyAlphaSampler;
  44591. private _pipelines;
  44592. private _compiledShaders;
  44593. private _deferredReleaseTextures;
  44594. private _commandEncoderForCreation;
  44595. static ComputeNumMipmapLevels(width: number, height: number): number;
  44596. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  44597. private _getPipeline;
  44598. private static _GetTextureTypeFromFormat;
  44599. private static _GetBlockInformationFromFormat;
  44600. private static _IsHardwareTexture;
  44601. private static _IsInternalTexture;
  44602. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  44603. static IsImageBitmap(imageBitmap: ImageBitmap | {
  44604. width: number;
  44605. height: number;
  44606. }): imageBitmap is ImageBitmap;
  44607. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  44608. width: number;
  44609. height: number;
  44610. }): imageBitmap is ImageBitmap[];
  44611. setCommandEncoder(encoder: GPUCommandEncoder): void;
  44612. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  44613. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  44614. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44615. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  44616. createTexture(imageBitmap: ImageBitmap | {
  44617. width: number;
  44618. height: number;
  44619. layers: number;
  44620. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44621. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  44622. width: number;
  44623. height: number;
  44624. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44625. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  44626. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44627. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  44628. createMSAATexture(texture: InternalTexture, samples: number): void;
  44629. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44630. 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;
  44631. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  44632. releaseTexture(texture: InternalTexture | GPUTexture): void;
  44633. destroyDeferredTextures(): void;
  44634. }
  44635. }
  44636. declare module BABYLON {
  44637. /** @hidden */
  44638. export class WebGPURenderPassWrapper {
  44639. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  44640. renderPass: Nullable<GPURenderPassEncoder>;
  44641. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44642. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44643. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  44644. depthTextureFormat: GPUTextureFormat | undefined;
  44645. constructor();
  44646. reset(fullReset?: boolean): void;
  44647. }
  44648. }
  44649. declare module BABYLON {
  44650. /** @hidden */
  44651. export class WebGPUCacheSampler {
  44652. private _samplers;
  44653. private _device;
  44654. constructor(device: GPUDevice);
  44655. private static _GetSamplerHashCode;
  44656. private static _GetSamplerFilterDescriptor;
  44657. private static _GetWrappingMode;
  44658. private static _GetSamplerWrappingDescriptor;
  44659. private static _GetSamplerDescriptor;
  44660. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  44661. }
  44662. }
  44663. declare module BABYLON {
  44664. /** @hidden */
  44665. export class WebGPUShaderManager {
  44666. private _shaders;
  44667. private _device;
  44668. constructor(device: GPUDevice);
  44669. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  44670. }
  44671. }
  44672. declare module BABYLON {
  44673. /** @hidden */
  44674. export var clearQuadVertexShader: {
  44675. name: string;
  44676. shader: string;
  44677. };
  44678. }
  44679. declare module BABYLON {
  44680. /** @hidden */
  44681. export var clearQuadPixelShader: {
  44682. name: string;
  44683. shader: string;
  44684. };
  44685. }
  44686. declare module BABYLON {
  44687. /**
  44688. * Options to load the associated Glslang library
  44689. */
  44690. export interface GlslangOptions {
  44691. /**
  44692. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  44693. */
  44694. glslang?: any;
  44695. /**
  44696. * Defines the URL of the glslang JS File.
  44697. */
  44698. jsPath?: string;
  44699. /**
  44700. * Defines the URL of the glslang WASM File.
  44701. */
  44702. wasmPath?: string;
  44703. }
  44704. /**
  44705. * Options to create the WebGPU engine
  44706. */
  44707. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  44708. /**
  44709. * If delta time between frames should be constant
  44710. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44711. */
  44712. deterministicLockstep?: boolean;
  44713. /**
  44714. * Maximum about of steps between frames (Default: 4)
  44715. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44716. */
  44717. lockstepMaxSteps?: number;
  44718. /**
  44719. * Defines the seconds between each deterministic lock step
  44720. */
  44721. timeStep?: number;
  44722. /**
  44723. * Defines that engine should ignore modifying touch action attribute and style
  44724. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  44725. */
  44726. doNotHandleTouchAction?: boolean;
  44727. /**
  44728. * Defines if webaudio should be initialized as well
  44729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  44730. */
  44731. audioEngine?: boolean;
  44732. /**
  44733. * Defines the category of adapter to use.
  44734. * Is it the discrete or integrated device.
  44735. */
  44736. powerPreference?: GPUPowerPreference;
  44737. /**
  44738. * Defines the device descriptor used to create a device.
  44739. */
  44740. deviceDescriptor?: GPUDeviceDescriptor;
  44741. /**
  44742. * Defines the requested Swap Chain Format.
  44743. */
  44744. swapChainFormat?: GPUTextureFormat;
  44745. /**
  44746. * Defines wether MSAA is enabled on the canvas.
  44747. */
  44748. antialiasing?: boolean;
  44749. /**
  44750. * Defines wether the stencil buffer should be enabled.
  44751. */
  44752. stencil?: boolean;
  44753. /**
  44754. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  44755. */
  44756. enableGPUDebugMarkers?: boolean;
  44757. }
  44758. /**
  44759. * The web GPU engine class provides support for WebGPU version of babylon.js.
  44760. */
  44761. export class WebGPUEngine extends Engine {
  44762. private static readonly _glslangDefaultOptions;
  44763. private readonly _uploadEncoderDescriptor;
  44764. private readonly _renderEncoderDescriptor;
  44765. private readonly _renderTargetEncoderDescriptor;
  44766. private readonly _clearDepthValue;
  44767. private readonly _clearReverseDepthValue;
  44768. private readonly _clearStencilValue;
  44769. private readonly _defaultSampleCount;
  44770. private _canvas;
  44771. private _options;
  44772. private _glslang;
  44773. private _adapter;
  44774. private _adapterSupportedExtensions;
  44775. private _device;
  44776. private _deviceEnabledExtensions;
  44777. private _context;
  44778. private _swapChain;
  44779. private _swapChainTexture;
  44780. private _mainPassSampleCount;
  44781. private _textureHelper;
  44782. private _bufferManager;
  44783. private _shaderManager;
  44784. private _cacheSampler;
  44785. private _emptyVertexBuffer;
  44786. private _lastCachedWrapU;
  44787. private _lastCachedWrapV;
  44788. private _lastCachedWrapR;
  44789. private _mrtAttachments;
  44790. private _counters;
  44791. private _mainTexture;
  44792. private _depthTexture;
  44793. private _mainTextureExtends;
  44794. private _depthTextureFormat;
  44795. private _colorFormat;
  44796. private _uploadEncoder;
  44797. private _renderEncoder;
  44798. private _renderTargetEncoder;
  44799. private _commandBuffers;
  44800. private _currentRenderPass;
  44801. private _mainRenderPassWrapper;
  44802. private _rttRenderPassWrapper;
  44803. private _pendingDebugCommands;
  44804. private _currentVertexBuffers;
  44805. private _currentIndexBuffer;
  44806. private __colorWrite;
  44807. private _uniformsBuffers;
  44808. private _forceEnableEffect;
  44809. /** @hidden */
  44810. dbgShowShaderCode: boolean;
  44811. /** @hidden */
  44812. dbgSanityChecks: boolean;
  44813. /** @hidden */
  44814. dbgGenerateLogs: boolean;
  44815. /** @hidden */
  44816. dbgVerboseLogsForFirstFrames: boolean;
  44817. /** @hidden */
  44818. dbgVerboseLogsNumFrames: number;
  44819. /** @hidden */
  44820. dbgShowWarningsNotImplemented: boolean;
  44821. /**
  44822. * Gets a boolean indicating that the engine supports uniform buffers
  44823. */
  44824. get supportsUniformBuffers(): boolean;
  44825. /** Gets the supported extensions by the WebGPU adapter */
  44826. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  44827. /** Gets the currently enabled extensions on the WebGPU device */
  44828. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  44829. /**
  44830. * Returns the name of the engine
  44831. */
  44832. get name(): string;
  44833. /**
  44834. * Returns a string describing the current engine
  44835. */
  44836. get description(): string;
  44837. /**
  44838. * Returns the version of the engine
  44839. */
  44840. get version(): number;
  44841. /**
  44842. * Create a new instance of the gpu engine.
  44843. * @param canvas Defines the canvas to use to display the result
  44844. * @param options Defines the options passed to the engine to create the GPU context dependencies
  44845. */
  44846. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  44847. /**
  44848. * Initializes the WebGPU context and dependencies.
  44849. * @param glslangOptions Defines the GLSLang compiler options if necessary
  44850. * @returns a promise notifying the readiness of the engine.
  44851. */
  44852. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  44853. private _initGlslang;
  44854. private _initializeLimits;
  44855. private _initializeContextAndSwapChain;
  44856. private _initializeMainAttachments;
  44857. /**
  44858. * Force a specific size of the canvas
  44859. * @param width defines the new canvas' width
  44860. * @param height defines the new canvas' height
  44861. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44862. * @returns true if the size was changed
  44863. */
  44864. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  44865. /**
  44866. * Gets a shader processor implementation fitting with the current engine type.
  44867. * @returns The shader processor implementation.
  44868. */
  44869. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  44870. /** @hidden */
  44871. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  44872. /**
  44873. * Force the entire cache to be cleared
  44874. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  44875. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44876. */
  44877. wipeCaches(bruteForce?: boolean): void;
  44878. /**
  44879. * Enable or disable color writing
  44880. * @param enable defines the state to set
  44881. */
  44882. setColorWrite(enable: boolean): void;
  44883. /**
  44884. * Gets a boolean indicating if color writing is enabled
  44885. * @returns the current color writing state
  44886. */
  44887. getColorWrite(): boolean;
  44888. private _viewportsCurrent;
  44889. private _resetCurrentViewport;
  44890. private _applyViewport;
  44891. /** @hidden */
  44892. _viewport(x: number, y: number, width: number, height: number): void;
  44893. private _scissorsCurrent;
  44894. protected _scissorCached: {
  44895. x: number;
  44896. y: number;
  44897. z: number;
  44898. w: number;
  44899. };
  44900. private _resetCurrentScissor;
  44901. private _applyScissor;
  44902. private _scissorIsActive;
  44903. enableScissor(x: number, y: number, width: number, height: number): void;
  44904. disableScissor(): void;
  44905. /**
  44906. * Clear the current render buffer or the current render target (if any is set up)
  44907. * @param color defines the color to use
  44908. * @param backBuffer defines if the back buffer must be cleared
  44909. * @param depth defines if the depth buffer must be cleared
  44910. * @param stencil defines if the stencil buffer must be cleared
  44911. */
  44912. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44913. /**
  44914. * Creates a vertex buffer
  44915. * @param data the data for the vertex buffer
  44916. * @returns the new buffer
  44917. */
  44918. createVertexBuffer(data: DataArray): DataBuffer;
  44919. /**
  44920. * Creates a vertex buffer
  44921. * @param data the data for the dynamic vertex buffer
  44922. * @returns the new buffer
  44923. */
  44924. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44925. /**
  44926. * Updates a vertex buffer.
  44927. * @param vertexBuffer the vertex buffer to update
  44928. * @param data the data used to update the vertex buffer
  44929. * @param byteOffset the byte offset of the data
  44930. * @param byteLength the byte length of the data
  44931. */
  44932. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44933. /**
  44934. * Creates a new index buffer
  44935. * @param indices defines the content of the index buffer
  44936. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  44937. * @returns a new buffer
  44938. */
  44939. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  44940. /**
  44941. * Update an index buffer
  44942. * @param indexBuffer defines the target index buffer
  44943. * @param indices defines the data to update
  44944. * @param offset defines the offset in the target index buffer where update should start
  44945. */
  44946. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44947. /** @hidden */
  44948. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  44949. /** @hidden */
  44950. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  44951. /**
  44952. * Bind a list of vertex buffers with the engine
  44953. * @param vertexBuffers defines the list of vertex buffers to bind
  44954. * @param indexBuffer defines the index buffer to bind
  44955. * @param effect defines the effect associated with the vertex buffers
  44956. */
  44957. bindBuffers(vertexBuffers: {
  44958. [key: string]: Nullable<VertexBuffer>;
  44959. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  44960. /** @hidden */
  44961. _releaseBuffer(buffer: DataBuffer): boolean;
  44962. createUniformBuffer(elements: FloatArray): DataBuffer;
  44963. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  44964. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  44965. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  44966. /**
  44967. * Create a new effect (used to store vertex/fragment shaders)
  44968. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  44969. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  44970. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  44971. * @param samplers defines an array of string used to represent textures
  44972. * @param defines defines the string containing the defines to use to compile the shaders
  44973. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  44974. * @param onCompiled defines a function to call when the effect creation is successful
  44975. * @param onError defines a function to call when the effect creation has failed
  44976. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  44977. * @returns the new Effect
  44978. */
  44979. 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;
  44980. private _compileRawShaderToSpirV;
  44981. private _compileShaderToSpirV;
  44982. private _createPipelineStageDescriptor;
  44983. private _compileRawPipelineStageDescriptor;
  44984. private _compilePipelineStageDescriptor;
  44985. /** @hidden */
  44986. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44987. /** @hidden */
  44988. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  44989. /**
  44990. * Creates a new pipeline context
  44991. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  44992. * @returns the new pipeline
  44993. */
  44994. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  44995. /** @hidden */
  44996. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  44997. /**
  44998. * Gets the list of active attributes for a given WebGPU program
  44999. * @param pipelineContext defines the pipeline context to use
  45000. * @param attributesNames defines the list of attribute names to get
  45001. * @returns an array of indices indicating the offset of each attribute
  45002. */
  45003. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45004. /**
  45005. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45006. * @param effect defines the effect to activate
  45007. */
  45008. enableEffect(effect: Nullable<Effect>): void;
  45009. /** @hidden */
  45010. _releaseEffect(effect: Effect): void;
  45011. /**
  45012. * 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
  45013. */
  45014. releaseEffects(): void;
  45015. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45016. /**
  45017. * Gets a boolean indicating that only power of 2 textures are supported
  45018. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45019. */
  45020. get needPOTTextures(): boolean;
  45021. /** @hidden */
  45022. _createHardwareTexture(): HardwareTextureWrapper;
  45023. /** @hidden */
  45024. _releaseTexture(texture: InternalTexture): void;
  45025. /** @hidden */
  45026. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45027. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45028. /**
  45029. * Usually called from Texture.ts.
  45030. * Passed information to create a hardware texture
  45031. * @param url defines a value which contains one of the following:
  45032. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45033. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45034. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45035. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45036. * @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)
  45037. * @param scene needed for loading to the correct scene
  45038. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45039. * @param onLoad optional callback to be called upon successful completion
  45040. * @param onError optional callback to be called upon failure
  45041. * @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
  45042. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45043. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45044. * @param forcedExtension defines the extension to use to pick the right loader
  45045. * @param mimeType defines an optional mime type
  45046. * @param loaderOptions options to be passed to the loader
  45047. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45048. */
  45049. 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;
  45050. /** @hidden */
  45051. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45052. /**
  45053. * Creates a cube texture
  45054. * @param rootUrl defines the url where the files to load is located
  45055. * @param scene defines the current scene
  45056. * @param files defines the list of files to load (1 per face)
  45057. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45058. * @param onLoad defines an optional callback raised when the texture is loaded
  45059. * @param onError defines an optional callback raised if there is an issue to load the texture
  45060. * @param format defines the format of the data
  45061. * @param forcedExtension defines the extension to use to pick the right loader
  45062. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45063. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45064. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45065. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45066. * @param loaderOptions options to be passed to the loader
  45067. * @returns the cube texture as an InternalTexture
  45068. */
  45069. 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;
  45070. /**
  45071. * Creates a raw texture
  45072. * @param data defines the data to store in the texture
  45073. * @param width defines the width of the texture
  45074. * @param height defines the height of the texture
  45075. * @param format defines the format of the data
  45076. * @param generateMipMaps defines if the engine should generate the mip levels
  45077. * @param invertY defines if data must be stored with Y axis inverted
  45078. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45079. * @param compression defines the compression used (null by default)
  45080. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45081. * @returns the raw texture inside an InternalTexture
  45082. */
  45083. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45084. /**
  45085. * Creates a new raw cube texture
  45086. * @param data defines the array of data to use to create each face
  45087. * @param size defines the size of the textures
  45088. * @param format defines the format of the data
  45089. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45090. * @param generateMipMaps defines if the engine should generate the mip levels
  45091. * @param invertY defines if data must be stored with Y axis inverted
  45092. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45093. * @param compression defines the compression used (null by default)
  45094. * @returns the cube texture as an InternalTexture
  45095. */
  45096. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45097. /**
  45098. * Creates a new raw cube texture from a specified url
  45099. * @param url defines the url where the data is located
  45100. * @param scene defines the current scene
  45101. * @param size defines the size of the textures
  45102. * @param format defines the format of the data
  45103. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45104. * @param noMipmap defines if the engine should avoid generating the mip levels
  45105. * @param callback defines a callback used to extract texture data from loaded data
  45106. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45107. * @param onLoad defines a callback called when texture is loaded
  45108. * @param onError defines a callback called if there is an error
  45109. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45110. * @param invertY defines if data must be stored with Y axis inverted
  45111. * @returns the cube texture as an InternalTexture
  45112. */
  45113. 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;
  45114. /**
  45115. * Creates a new raw 2D array texture
  45116. * @param data defines the data used to create the texture
  45117. * @param width defines the width of the texture
  45118. * @param height defines the height of the texture
  45119. * @param depth defines the number of layers of the texture
  45120. * @param format defines the format of the texture
  45121. * @param generateMipMaps defines if the engine must generate mip levels
  45122. * @param invertY defines if data must be stored with Y axis inverted
  45123. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45124. * @param compression defines the compressed used (can be null)
  45125. * @param textureType defines the compressed used (can be null)
  45126. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45127. */
  45128. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45129. /**
  45130. * Creates a new raw 3D texture
  45131. * @param data defines the data used to create the texture
  45132. * @param width defines the width of the texture
  45133. * @param height defines the height of the texture
  45134. * @param depth defines the depth of the texture
  45135. * @param format defines the format of the texture
  45136. * @param generateMipMaps defines if the engine must generate mip levels
  45137. * @param invertY defines if data must be stored with Y axis inverted
  45138. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45139. * @param compression defines the compressed used (can be null)
  45140. * @param textureType defines the compressed used (can be null)
  45141. * @returns a new raw 3D texture (stored in an InternalTexture)
  45142. */
  45143. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45144. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45145. /**
  45146. * Update the sampling mode of a given texture
  45147. * @param samplingMode defines the required sampling mode
  45148. * @param texture defines the texture to update
  45149. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45150. */
  45151. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45152. /**
  45153. * Update the sampling mode of a given texture
  45154. * @param texture defines the texture to update
  45155. * @param wrapU defines the texture wrap mode of the u coordinates
  45156. * @param wrapV defines the texture wrap mode of the v coordinates
  45157. * @param wrapR defines the texture wrap mode of the r coordinates
  45158. */
  45159. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45160. /**
  45161. * Update the dimensions of a texture
  45162. * @param texture texture to update
  45163. * @param width new width of the texture
  45164. * @param height new height of the texture
  45165. * @param depth new depth of the texture
  45166. */
  45167. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45168. private _setInternalTexture;
  45169. /**
  45170. * Sets a texture to the according uniform.
  45171. * @param channel The texture channel
  45172. * @param unused unused parameter
  45173. * @param texture The texture to apply
  45174. * @param name The name of the uniform in the effect
  45175. */
  45176. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45177. /**
  45178. * Sets an array of texture to the WebGPU context
  45179. * @param channel defines the channel where the texture array must be set
  45180. * @param unused unused parameter
  45181. * @param textures defines the array of textures to bind
  45182. * @param name name of the channel
  45183. */
  45184. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45185. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45186. /** @hidden */
  45187. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45188. /** @hidden */
  45189. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45190. private _generateMipmaps;
  45191. /**
  45192. * Update the content of a texture
  45193. * @param texture defines the texture to update
  45194. * @param canvas defines the source containing the data
  45195. * @param invertY defines if data must be stored with Y axis inverted
  45196. * @param premulAlpha defines if alpha is stored as premultiplied
  45197. * @param format defines the format of the data
  45198. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45199. */
  45200. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45201. /**
  45202. * Update a portion of an internal texture
  45203. * @param texture defines the texture to update
  45204. * @param imageData defines the data to store into the texture
  45205. * @param xOffset defines the x coordinates of the update rectangle
  45206. * @param yOffset defines the y coordinates of the update rectangle
  45207. * @param width defines the width of the update rectangle
  45208. * @param height defines the height of the update rectangle
  45209. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45210. * @param lod defines the lod level to update (0 by default)
  45211. */
  45212. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45213. /**
  45214. * Update a video texture
  45215. * @param texture defines the texture to update
  45216. * @param video defines the video element to use
  45217. * @param invertY defines if data must be stored with Y axis inverted
  45218. */
  45219. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45220. /** @hidden */
  45221. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45222. /** @hidden */
  45223. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45224. /** @hidden */
  45225. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45226. /** @hidden */
  45227. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45228. /**
  45229. * Update a raw texture
  45230. * @param texture defines the texture to update
  45231. * @param bufferView defines the data to store in the texture
  45232. * @param format defines the format of the data
  45233. * @param invertY defines if data must be stored with Y axis inverted
  45234. * @param compression defines the compression used (null by default)
  45235. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45236. */
  45237. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45238. /**
  45239. * Update a raw cube texture
  45240. * @param texture defines the texture to udpdate
  45241. * @param bufferView defines the data to store
  45242. * @param format defines the data format
  45243. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45244. * @param invertY defines if data must be stored with Y axis inverted
  45245. * @param compression defines the compression used (null by default)
  45246. * @param level defines which level of the texture to update
  45247. */
  45248. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45249. /**
  45250. * Update a raw 2D array texture
  45251. * @param texture defines the texture to update
  45252. * @param bufferView defines the data to store
  45253. * @param format defines the data format
  45254. * @param invertY defines if data must be stored with Y axis inverted
  45255. * @param compression defines the used compression (can be null)
  45256. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45257. */
  45258. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45259. /**
  45260. * Update a raw 3D texture
  45261. * @param texture defines the texture to update
  45262. * @param bufferView defines the data to store
  45263. * @param format defines the data format
  45264. * @param invertY defines if data must be stored with Y axis inverted
  45265. * @param compression defines the used compression (can be null)
  45266. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45267. */
  45268. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45269. /**
  45270. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45271. * @param x defines the x coordinate of the rectangle where pixels must be read
  45272. * @param y defines the y coordinate of the rectangle where pixels must be read
  45273. * @param width defines the width of the rectangle where pixels must be read
  45274. * @param height defines the height of the rectangle where pixels must be read
  45275. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45276. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45277. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45278. */
  45279. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45280. /** @hidden */
  45281. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45282. /**
  45283. * Creates a new render target texture
  45284. * @param size defines the size of the texture
  45285. * @param options defines the options used to create the texture
  45286. * @returns a new render target texture stored in an InternalTexture
  45287. */
  45288. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45289. /**
  45290. * Create a multi render target texture
  45291. * @param size defines the size of the texture
  45292. * @param options defines the creation options
  45293. * @returns the cube texture as an InternalTexture
  45294. */
  45295. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45296. /**
  45297. * Creates a new render target cube texture
  45298. * @param size defines the size of the texture
  45299. * @param options defines the options used to create the texture
  45300. * @returns a new render target cube texture stored in an InternalTexture
  45301. */
  45302. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45303. /** @hidden */
  45304. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45305. width: number;
  45306. height: number;
  45307. layers?: number;
  45308. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45309. /** @hidden */
  45310. _createDepthStencilTexture(size: number | {
  45311. width: number;
  45312. height: number;
  45313. layers?: number;
  45314. }, options: DepthTextureCreationOptions): InternalTexture;
  45315. /** @hidden */
  45316. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45317. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45318. /**
  45319. * Update the sample count for a given multiple render target texture
  45320. * @param textures defines the textures to update
  45321. * @param samples defines the sample count to set
  45322. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45323. */
  45324. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45325. /**
  45326. * Begin a new frame
  45327. */
  45328. beginFrame(): void;
  45329. /**
  45330. * End the current frame
  45331. */
  45332. endFrame(): void;
  45333. /**
  45334. * Force a WebGPU flush (ie. a flush of all waiting commands)
  45335. */
  45336. flushFramebuffer(): void;
  45337. private _startRenderTargetRenderPass;
  45338. private _endRenderTargetRenderPass;
  45339. private _getCurrentRenderPass;
  45340. private _currentRenderPassIsMRT;
  45341. private _startMainRenderPass;
  45342. private _endMainRenderPass;
  45343. /**
  45344. * Restores the WebGPU state to only draw on the main color attachment
  45345. */
  45346. restoreSingleAttachment(): void;
  45347. /**
  45348. * Creates a layout object to draw/clear on specific textures in a MRT
  45349. * @param textureStatus textureStatus[i] indicates if the i-th is active
  45350. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  45351. */
  45352. buildTextureLayout(textureStatus: boolean[]): number[];
  45353. /**
  45354. * Select a subsets of attachments to draw to.
  45355. * @param attachments index of attachments
  45356. */
  45357. bindAttachments(attachments: number[]): void;
  45358. /**
  45359. * Binds the frame buffer to the specified texture.
  45360. * @param texture The texture to render to or null for the default canvas
  45361. * @param faceIndex The face of the texture to render to in case of cube texture
  45362. * @param requiredWidth The width of the target to render to
  45363. * @param requiredHeight The height of the target to render to
  45364. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45365. * @param lodLevel defines the lod level to bind to the frame buffer
  45366. * @param layer defines the 2d array index to bind to frame buffer to
  45367. */
  45368. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  45369. /**
  45370. * Unbind the current render target texture from the WebGPU context
  45371. * @param texture defines the render target texture to unbind
  45372. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45373. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45374. */
  45375. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45376. /**
  45377. * Unbind a list of render target textures from the WebGPU context
  45378. * @param textures defines the render target textures to unbind
  45379. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45380. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45381. */
  45382. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45383. /**
  45384. * Unbind the current render target and bind the default framebuffer
  45385. */
  45386. restoreDefaultFramebuffer(): void;
  45387. setZOffset(value: number): void;
  45388. private _setColorFormat;
  45389. private _setDepthTextureFormat;
  45390. setDepthBuffer(enable: boolean): void;
  45391. setDepthWrite(enable: boolean): void;
  45392. setStencilBuffer(enable: boolean): void;
  45393. setStencilMask(mask: number): void;
  45394. setStencilFunction(stencilFunc: number): void;
  45395. setStencilFunctionReference(reference: number): void;
  45396. setStencilFunctionMask(mask: number): void;
  45397. setStencilOperationFail(operation: number): void;
  45398. setStencilOperationDepthFail(operation: number): void;
  45399. setStencilOperationPass(operation: number): void;
  45400. setDitheringState(value: boolean): void;
  45401. setRasterizerState(value: boolean): void;
  45402. setDepthFunction(depthFunc: number): void;
  45403. setDepthFunctionToGreater(): void;
  45404. setDepthFunctionToGreaterOrEqual(): void;
  45405. setDepthFunctionToLess(): void;
  45406. setDepthFunctionToLessOrEqual(): void;
  45407. private _indexFormatInRenderPass;
  45408. private _getTopology;
  45409. private _getOpFunction;
  45410. private _getDepthStencilStateDescriptor;
  45411. /**
  45412. * Set various states to the context
  45413. * @param culling defines backface culling state
  45414. * @param zOffset defines the value to apply to zOffset (0 by default)
  45415. * @param force defines if states must be applied even if cache is up to date
  45416. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45417. */
  45418. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45419. private _getFrontFace;
  45420. private _getCullMode;
  45421. private _getRasterizationStateDescriptor;
  45422. private _getWriteMask;
  45423. /**
  45424. * Sets the current alpha mode
  45425. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45426. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45427. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45428. */
  45429. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45430. private _getAphaBlendOperation;
  45431. private _getAphaBlendFactor;
  45432. private _getAphaBlendState;
  45433. private _getColorBlendState;
  45434. private _getColorStateDescriptors;
  45435. private _getStages;
  45436. private _getVertexInputDescriptorFormat;
  45437. private _getVertexInputDescriptor;
  45438. private _getPipelineLayout;
  45439. private _getRenderPipeline;
  45440. private _getVertexInputsToRender;
  45441. private _getBindGroupsToRender;
  45442. private _bindVertexInputs;
  45443. private _setRenderBindGroups;
  45444. private _setRenderPipeline;
  45445. /**
  45446. * Draw a list of indexed primitives
  45447. * @param fillMode defines the primitive to use
  45448. * @param indexStart defines the starting index
  45449. * @param indexCount defines the number of index to draw
  45450. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45451. */
  45452. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45453. /**
  45454. * Draw a list of unindexed primitives
  45455. * @param fillMode defines the primitive to use
  45456. * @param verticesStart defines the index of first vertex to draw
  45457. * @param verticesCount defines the count of vertices to draw
  45458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45459. */
  45460. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45461. private _bundleEncoder;
  45462. /**
  45463. * Start recording all the gpu calls into a bundle.
  45464. */
  45465. startRecordBundle(): void;
  45466. /**
  45467. * Stops recording the bundle.
  45468. * @returns the recorded bundle
  45469. */
  45470. stopRecordBundle(): GPURenderBundle;
  45471. /**
  45472. * Execute the previously recorded bundle.
  45473. * @param bundles defines the bundle to replay
  45474. */
  45475. executeBundles(bundles: GPURenderBundle[]): void;
  45476. /**
  45477. * Dispose and release all associated resources
  45478. */
  45479. dispose(): void;
  45480. /**
  45481. * Gets the current render width
  45482. * @param useScreen defines if screen size must be used (or the current render target if any)
  45483. * @returns a number defining the current render width
  45484. */
  45485. getRenderWidth(useScreen?: boolean): number;
  45486. /**
  45487. * Gets the current render height
  45488. * @param useScreen defines if screen size must be used (or the current render target if any)
  45489. * @returns a number defining the current render height
  45490. */
  45491. getRenderHeight(useScreen?: boolean): number;
  45492. /**
  45493. * Gets the HTML canvas attached with the current WebGPU context
  45494. * @returns a HTML canvas
  45495. */
  45496. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  45497. /** @hidden */
  45498. _debugPushGroup(groupName: string, targetObject?: number): void;
  45499. /** @hidden */
  45500. _debugPopGroup(targetObject?: number): void;
  45501. /** @hidden */
  45502. _debugInsertMarker(text: string, targetObject?: number): void;
  45503. private _debugFlushPendingCommands;
  45504. /**
  45505. * Get the current error code of the WebGPU context
  45506. * @returns the error code
  45507. */
  45508. getError(): number;
  45509. /** @hidden */
  45510. bindSamplers(effect: Effect): void;
  45511. /** @hidden */
  45512. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  45513. /** @hidden */
  45514. _releaseFramebufferObjects(texture: InternalTexture): void;
  45515. /** @hidden */
  45516. applyStates(): void;
  45517. /**
  45518. * Gets a boolean indicating if all created effects are ready
  45519. * @returns always true - No parallel shader compilation
  45520. */
  45521. areAllEffectsReady(): boolean;
  45522. /** @hidden */
  45523. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45524. /** @hidden */
  45525. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45526. /** @hidden */
  45527. _getUnpackAlignement(): number;
  45528. /** @hidden */
  45529. _unpackFlipY(value: boolean): void;
  45530. /** @hidden */
  45531. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  45532. min: number;
  45533. mag: number;
  45534. };
  45535. /** @hidden */
  45536. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45537. /** @hidden */
  45538. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45539. /** @hidden */
  45540. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45541. /** @hidden */
  45542. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45543. /** @hidden */
  45544. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45545. /** @hidden */
  45546. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45547. /** @hidden */
  45548. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  45549. /** @hidden */
  45550. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  45551. /** @hidden */
  45552. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  45553. /** @hidden */
  45554. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  45555. /** @hidden */
  45556. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  45557. /** @hidden */
  45558. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45559. /** @hidden */
  45560. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45561. /** @hidden */
  45562. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  45563. /** @hidden */
  45564. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  45565. /** @hidden */
  45566. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  45567. /** @hidden */
  45568. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  45569. }
  45570. }
  45571. declare module BABYLON {
  45572. /**
  45573. * Define an interface for all classes that will hold resources
  45574. */
  45575. export interface IDisposable {
  45576. /**
  45577. * Releases all held resources
  45578. */
  45579. dispose(): void;
  45580. }
  45581. /** Interface defining initialization parameters for Scene class */
  45582. export interface SceneOptions {
  45583. /**
  45584. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  45585. * It will improve performance when the number of geometries becomes important.
  45586. */
  45587. useGeometryUniqueIdsMap?: boolean;
  45588. /**
  45589. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  45590. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45591. */
  45592. useMaterialMeshMap?: boolean;
  45593. /**
  45594. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  45595. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45596. */
  45597. useClonedMeshMap?: boolean;
  45598. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  45599. virtual?: boolean;
  45600. }
  45601. /**
  45602. * Represents a scene to be rendered by the engine.
  45603. * @see https://doc.babylonjs.com/features/scene
  45604. */
  45605. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  45606. /** The fog is deactivated */
  45607. static readonly FOGMODE_NONE: number;
  45608. /** The fog density is following an exponential function */
  45609. static readonly FOGMODE_EXP: number;
  45610. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  45611. static readonly FOGMODE_EXP2: number;
  45612. /** The fog density is following a linear function. */
  45613. static readonly FOGMODE_LINEAR: number;
  45614. /**
  45615. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  45616. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45617. */
  45618. static MinDeltaTime: number;
  45619. /**
  45620. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  45621. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45622. */
  45623. static MaxDeltaTime: number;
  45624. /**
  45625. * Factory used to create the default material.
  45626. * @param name The name of the material to create
  45627. * @param scene The scene to create the material for
  45628. * @returns The default material
  45629. */
  45630. static DefaultMaterialFactory(scene: Scene): Material;
  45631. /**
  45632. * Factory used to create the a collision coordinator.
  45633. * @returns The collision coordinator
  45634. */
  45635. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  45636. /** @hidden */
  45637. _inputManager: InputManager;
  45638. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  45639. cameraToUseForPointers: Nullable<Camera>;
  45640. /** @hidden */
  45641. readonly _isScene: boolean;
  45642. /** @hidden */
  45643. _blockEntityCollection: boolean;
  45644. /**
  45645. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  45646. */
  45647. autoClear: boolean;
  45648. /**
  45649. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  45650. */
  45651. autoClearDepthAndStencil: boolean;
  45652. /**
  45653. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  45654. */
  45655. clearColor: Color4;
  45656. /**
  45657. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  45658. */
  45659. ambientColor: Color3;
  45660. /**
  45661. * This is use to store the default BRDF lookup for PBR materials in your scene.
  45662. * It should only be one of the following (if not the default embedded one):
  45663. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45664. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  45665. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45666. * The material properties need to be setup according to the type of texture in use.
  45667. */
  45668. environmentBRDFTexture: BaseTexture;
  45669. /**
  45670. * Texture used in all pbr material as the reflection texture.
  45671. * As in the majority of the scene they are the same (exception for multi room and so on),
  45672. * this is easier to reference from here than from all the materials.
  45673. */
  45674. get environmentTexture(): Nullable<BaseTexture>;
  45675. /**
  45676. * Texture used in all pbr material as the reflection texture.
  45677. * As in the majority of the scene they are the same (exception for multi room and so on),
  45678. * this is easier to set here than in all the materials.
  45679. */
  45680. set environmentTexture(value: Nullable<BaseTexture>);
  45681. /** @hidden */
  45682. protected _environmentIntensity: number;
  45683. /**
  45684. * Intensity of the environment in all pbr material.
  45685. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45686. * As in the majority of the scene they are the same (exception for multi room and so on),
  45687. * this is easier to reference from here than from all the materials.
  45688. */
  45689. get environmentIntensity(): number;
  45690. /**
  45691. * Intensity of the environment in all pbr material.
  45692. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45693. * As in the majority of the scene they are the same (exception for multi room and so on),
  45694. * this is easier to set here than in all the materials.
  45695. */
  45696. set environmentIntensity(value: number);
  45697. /** @hidden */
  45698. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45699. /**
  45700. * Default image processing configuration used either in the rendering
  45701. * Forward main pass or through the imageProcessingPostProcess if present.
  45702. * As in the majority of the scene they are the same (exception for multi camera),
  45703. * this is easier to reference from here than from all the materials and post process.
  45704. *
  45705. * No setter as we it is a shared configuration, you can set the values instead.
  45706. */
  45707. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45708. private _forceWireframe;
  45709. /**
  45710. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  45711. */
  45712. set forceWireframe(value: boolean);
  45713. get forceWireframe(): boolean;
  45714. private _skipFrustumClipping;
  45715. /**
  45716. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  45717. */
  45718. set skipFrustumClipping(value: boolean);
  45719. get skipFrustumClipping(): boolean;
  45720. private _forcePointsCloud;
  45721. /**
  45722. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  45723. */
  45724. set forcePointsCloud(value: boolean);
  45725. get forcePointsCloud(): boolean;
  45726. /**
  45727. * Gets or sets the active clipplane 1
  45728. */
  45729. clipPlane: Nullable<Plane>;
  45730. /**
  45731. * Gets or sets the active clipplane 2
  45732. */
  45733. clipPlane2: Nullable<Plane>;
  45734. /**
  45735. * Gets or sets the active clipplane 3
  45736. */
  45737. clipPlane3: Nullable<Plane>;
  45738. /**
  45739. * Gets or sets the active clipplane 4
  45740. */
  45741. clipPlane4: Nullable<Plane>;
  45742. /**
  45743. * Gets or sets the active clipplane 5
  45744. */
  45745. clipPlane5: Nullable<Plane>;
  45746. /**
  45747. * Gets or sets the active clipplane 6
  45748. */
  45749. clipPlane6: Nullable<Plane>;
  45750. /**
  45751. * Gets or sets a boolean indicating if animations are enabled
  45752. */
  45753. animationsEnabled: boolean;
  45754. private _animationPropertiesOverride;
  45755. /**
  45756. * Gets or sets the animation properties override
  45757. */
  45758. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  45759. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  45760. /**
  45761. * Gets or sets a boolean indicating if a constant deltatime has to be used
  45762. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  45763. */
  45764. useConstantAnimationDeltaTime: boolean;
  45765. /**
  45766. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  45767. * Please note that it requires to run a ray cast through the scene on every frame
  45768. */
  45769. constantlyUpdateMeshUnderPointer: boolean;
  45770. /**
  45771. * Defines the HTML cursor to use when hovering over interactive elements
  45772. */
  45773. hoverCursor: string;
  45774. /**
  45775. * Defines the HTML default cursor to use (empty by default)
  45776. */
  45777. defaultCursor: string;
  45778. /**
  45779. * Defines whether cursors are handled by the scene.
  45780. */
  45781. doNotHandleCursors: boolean;
  45782. /**
  45783. * This is used to call preventDefault() on pointer down
  45784. * in order to block unwanted artifacts like system double clicks
  45785. */
  45786. preventDefaultOnPointerDown: boolean;
  45787. /**
  45788. * This is used to call preventDefault() on pointer up
  45789. * in order to block unwanted artifacts like system double clicks
  45790. */
  45791. preventDefaultOnPointerUp: boolean;
  45792. /**
  45793. * Gets or sets user defined metadata
  45794. */
  45795. metadata: any;
  45796. /**
  45797. * For internal use only. Please do not use.
  45798. */
  45799. reservedDataStore: any;
  45800. /**
  45801. * Gets the name of the plugin used to load this scene (null by default)
  45802. */
  45803. loadingPluginName: string;
  45804. /**
  45805. * Use this array to add regular expressions used to disable offline support for specific urls
  45806. */
  45807. disableOfflineSupportExceptionRules: RegExp[];
  45808. /**
  45809. * An event triggered when the scene is disposed.
  45810. */
  45811. onDisposeObservable: Observable<Scene>;
  45812. private _onDisposeObserver;
  45813. /** Sets a function to be executed when this scene is disposed. */
  45814. set onDispose(callback: () => void);
  45815. /**
  45816. * An event triggered before rendering the scene (right after animations and physics)
  45817. */
  45818. onBeforeRenderObservable: Observable<Scene>;
  45819. private _onBeforeRenderObserver;
  45820. /** Sets a function to be executed before rendering this scene */
  45821. set beforeRender(callback: Nullable<() => void>);
  45822. /**
  45823. * An event triggered after rendering the scene
  45824. */
  45825. onAfterRenderObservable: Observable<Scene>;
  45826. /**
  45827. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  45828. */
  45829. onAfterRenderCameraObservable: Observable<Camera>;
  45830. private _onAfterRenderObserver;
  45831. /** Sets a function to be executed after rendering this scene */
  45832. set afterRender(callback: Nullable<() => void>);
  45833. /**
  45834. * An event triggered before animating the scene
  45835. */
  45836. onBeforeAnimationsObservable: Observable<Scene>;
  45837. /**
  45838. * An event triggered after animations processing
  45839. */
  45840. onAfterAnimationsObservable: Observable<Scene>;
  45841. /**
  45842. * An event triggered before draw calls are ready to be sent
  45843. */
  45844. onBeforeDrawPhaseObservable: Observable<Scene>;
  45845. /**
  45846. * An event triggered after draw calls have been sent
  45847. */
  45848. onAfterDrawPhaseObservable: Observable<Scene>;
  45849. /**
  45850. * An event triggered when the scene is ready
  45851. */
  45852. onReadyObservable: Observable<Scene>;
  45853. /**
  45854. * An event triggered before rendering a camera
  45855. */
  45856. onBeforeCameraRenderObservable: Observable<Camera>;
  45857. private _onBeforeCameraRenderObserver;
  45858. /** Sets a function to be executed before rendering a camera*/
  45859. set beforeCameraRender(callback: () => void);
  45860. /**
  45861. * An event triggered after rendering a camera
  45862. */
  45863. onAfterCameraRenderObservable: Observable<Camera>;
  45864. private _onAfterCameraRenderObserver;
  45865. /** Sets a function to be executed after rendering a camera*/
  45866. set afterCameraRender(callback: () => void);
  45867. /**
  45868. * An event triggered when active meshes evaluation is about to start
  45869. */
  45870. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  45871. /**
  45872. * An event triggered when active meshes evaluation is done
  45873. */
  45874. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  45875. /**
  45876. * An event triggered when particles rendering is about to start
  45877. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  45878. */
  45879. onBeforeParticlesRenderingObservable: Observable<Scene>;
  45880. /**
  45881. * An event triggered when particles rendering is done
  45882. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  45883. */
  45884. onAfterParticlesRenderingObservable: Observable<Scene>;
  45885. /**
  45886. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  45887. */
  45888. onDataLoadedObservable: Observable<Scene>;
  45889. /**
  45890. * An event triggered when a camera is created
  45891. */
  45892. onNewCameraAddedObservable: Observable<Camera>;
  45893. /**
  45894. * An event triggered when a camera is removed
  45895. */
  45896. onCameraRemovedObservable: Observable<Camera>;
  45897. /**
  45898. * An event triggered when a light is created
  45899. */
  45900. onNewLightAddedObservable: Observable<Light>;
  45901. /**
  45902. * An event triggered when a light is removed
  45903. */
  45904. onLightRemovedObservable: Observable<Light>;
  45905. /**
  45906. * An event triggered when a geometry is created
  45907. */
  45908. onNewGeometryAddedObservable: Observable<Geometry>;
  45909. /**
  45910. * An event triggered when a geometry is removed
  45911. */
  45912. onGeometryRemovedObservable: Observable<Geometry>;
  45913. /**
  45914. * An event triggered when a transform node is created
  45915. */
  45916. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  45917. /**
  45918. * An event triggered when a transform node is removed
  45919. */
  45920. onTransformNodeRemovedObservable: Observable<TransformNode>;
  45921. /**
  45922. * An event triggered when a mesh is created
  45923. */
  45924. onNewMeshAddedObservable: Observable<AbstractMesh>;
  45925. /**
  45926. * An event triggered when a mesh is removed
  45927. */
  45928. onMeshRemovedObservable: Observable<AbstractMesh>;
  45929. /**
  45930. * An event triggered when a skeleton is created
  45931. */
  45932. onNewSkeletonAddedObservable: Observable<Skeleton>;
  45933. /**
  45934. * An event triggered when a skeleton is removed
  45935. */
  45936. onSkeletonRemovedObservable: Observable<Skeleton>;
  45937. /**
  45938. * An event triggered when a material is created
  45939. */
  45940. onNewMaterialAddedObservable: Observable<Material>;
  45941. /**
  45942. * An event triggered when a multi material is created
  45943. */
  45944. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  45945. /**
  45946. * An event triggered when a material is removed
  45947. */
  45948. onMaterialRemovedObservable: Observable<Material>;
  45949. /**
  45950. * An event triggered when a multi material is removed
  45951. */
  45952. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  45953. /**
  45954. * An event triggered when a texture is created
  45955. */
  45956. onNewTextureAddedObservable: Observable<BaseTexture>;
  45957. /**
  45958. * An event triggered when a texture is removed
  45959. */
  45960. onTextureRemovedObservable: Observable<BaseTexture>;
  45961. /**
  45962. * An event triggered when render targets are about to be rendered
  45963. * Can happen multiple times per frame.
  45964. */
  45965. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  45966. /**
  45967. * An event triggered when render targets were rendered.
  45968. * Can happen multiple times per frame.
  45969. */
  45970. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  45971. /**
  45972. * An event triggered before calculating deterministic simulation step
  45973. */
  45974. onBeforeStepObservable: Observable<Scene>;
  45975. /**
  45976. * An event triggered after calculating deterministic simulation step
  45977. */
  45978. onAfterStepObservable: Observable<Scene>;
  45979. /**
  45980. * An event triggered when the activeCamera property is updated
  45981. */
  45982. onActiveCameraChanged: Observable<Scene>;
  45983. /**
  45984. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  45985. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  45986. * 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)
  45987. */
  45988. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  45989. /**
  45990. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  45991. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  45992. * 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)
  45993. */
  45994. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  45995. /**
  45996. * This Observable will when a mesh has been imported into the scene.
  45997. */
  45998. onMeshImportedObservable: Observable<AbstractMesh>;
  45999. /**
  46000. * This Observable will when an animation file has been imported into the scene.
  46001. */
  46002. onAnimationFileImportedObservable: Observable<Scene>;
  46003. /**
  46004. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46005. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46006. */
  46007. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46008. /** @hidden */
  46009. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46010. /**
  46011. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46012. */
  46013. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46014. /**
  46015. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46016. */
  46017. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46018. /**
  46019. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46020. */
  46021. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46022. /** Callback called when a pointer move is detected */
  46023. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46024. /** Callback called when a pointer down is detected */
  46025. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46026. /** Callback called when a pointer up is detected */
  46027. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46028. /** Callback called when a pointer pick is detected */
  46029. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46030. /**
  46031. * 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).
  46032. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46033. */
  46034. onPrePointerObservable: Observable<PointerInfoPre>;
  46035. /**
  46036. * Observable event triggered each time an input event is received from the rendering canvas
  46037. */
  46038. onPointerObservable: Observable<PointerInfo>;
  46039. /**
  46040. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46041. */
  46042. get unTranslatedPointer(): Vector2;
  46043. /**
  46044. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46045. */
  46046. static get DragMovementThreshold(): number;
  46047. static set DragMovementThreshold(value: number);
  46048. /**
  46049. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46050. */
  46051. static get LongPressDelay(): number;
  46052. static set LongPressDelay(value: number);
  46053. /**
  46054. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46055. */
  46056. static get DoubleClickDelay(): number;
  46057. static set DoubleClickDelay(value: number);
  46058. /** If you need to check double click without raising a single click at first click, enable this flag */
  46059. static get ExclusiveDoubleClickMode(): boolean;
  46060. static set ExclusiveDoubleClickMode(value: boolean);
  46061. /** @hidden */
  46062. _mirroredCameraPosition: Nullable<Vector3>;
  46063. /**
  46064. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46065. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46066. */
  46067. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46068. /**
  46069. * Observable event triggered each time an keyboard event is received from the hosting window
  46070. */
  46071. onKeyboardObservable: Observable<KeyboardInfo>;
  46072. private _useRightHandedSystem;
  46073. /**
  46074. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46075. */
  46076. set useRightHandedSystem(value: boolean);
  46077. get useRightHandedSystem(): boolean;
  46078. private _timeAccumulator;
  46079. private _currentStepId;
  46080. private _currentInternalStep;
  46081. /**
  46082. * Sets the step Id used by deterministic lock step
  46083. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46084. * @param newStepId defines the step Id
  46085. */
  46086. setStepId(newStepId: number): void;
  46087. /**
  46088. * Gets the step Id used by deterministic lock step
  46089. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46090. * @returns the step Id
  46091. */
  46092. getStepId(): number;
  46093. /**
  46094. * Gets the internal step used by deterministic lock step
  46095. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46096. * @returns the internal step
  46097. */
  46098. getInternalStep(): number;
  46099. private _fogEnabled;
  46100. /**
  46101. * Gets or sets a boolean indicating if fog is enabled on this scene
  46102. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46103. * (Default is true)
  46104. */
  46105. set fogEnabled(value: boolean);
  46106. get fogEnabled(): boolean;
  46107. private _fogMode;
  46108. /**
  46109. * Gets or sets the fog mode to use
  46110. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46111. * | mode | value |
  46112. * | --- | --- |
  46113. * | FOGMODE_NONE | 0 |
  46114. * | FOGMODE_EXP | 1 |
  46115. * | FOGMODE_EXP2 | 2 |
  46116. * | FOGMODE_LINEAR | 3 |
  46117. */
  46118. set fogMode(value: number);
  46119. get fogMode(): number;
  46120. /**
  46121. * Gets or sets the fog color to use
  46122. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46123. * (Default is Color3(0.2, 0.2, 0.3))
  46124. */
  46125. fogColor: Color3;
  46126. /**
  46127. * Gets or sets the fog density to use
  46128. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46129. * (Default is 0.1)
  46130. */
  46131. fogDensity: number;
  46132. /**
  46133. * Gets or sets the fog start distance to use
  46134. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46135. * (Default is 0)
  46136. */
  46137. fogStart: number;
  46138. /**
  46139. * Gets or sets the fog end distance to use
  46140. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46141. * (Default is 1000)
  46142. */
  46143. fogEnd: number;
  46144. /**
  46145. * Flag indicating that the frame buffer binding is handled by another component
  46146. */
  46147. prePass: boolean;
  46148. private _shadowsEnabled;
  46149. /**
  46150. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46151. */
  46152. set shadowsEnabled(value: boolean);
  46153. get shadowsEnabled(): boolean;
  46154. private _lightsEnabled;
  46155. /**
  46156. * Gets or sets a boolean indicating if lights are enabled on this scene
  46157. */
  46158. set lightsEnabled(value: boolean);
  46159. get lightsEnabled(): boolean;
  46160. /** All of the active cameras added to this scene. */
  46161. activeCameras: Nullable<Camera[]>;
  46162. /** @hidden */
  46163. _activeCamera: Nullable<Camera>;
  46164. /** Gets or sets the current active camera */
  46165. get activeCamera(): Nullable<Camera>;
  46166. set activeCamera(value: Nullable<Camera>);
  46167. private _defaultMaterial;
  46168. /** The default material used on meshes when no material is affected */
  46169. get defaultMaterial(): Material;
  46170. /** The default material used on meshes when no material is affected */
  46171. set defaultMaterial(value: Material);
  46172. private _texturesEnabled;
  46173. /**
  46174. * Gets or sets a boolean indicating if textures are enabled on this scene
  46175. */
  46176. set texturesEnabled(value: boolean);
  46177. get texturesEnabled(): boolean;
  46178. /**
  46179. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46180. */
  46181. physicsEnabled: boolean;
  46182. /**
  46183. * Gets or sets a boolean indicating if particles are enabled on this scene
  46184. */
  46185. particlesEnabled: boolean;
  46186. /**
  46187. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46188. */
  46189. spritesEnabled: boolean;
  46190. private _skeletonsEnabled;
  46191. /**
  46192. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46193. */
  46194. set skeletonsEnabled(value: boolean);
  46195. get skeletonsEnabled(): boolean;
  46196. /**
  46197. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46198. */
  46199. lensFlaresEnabled: boolean;
  46200. /**
  46201. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46202. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46203. */
  46204. collisionsEnabled: boolean;
  46205. private _collisionCoordinator;
  46206. /** @hidden */
  46207. get collisionCoordinator(): ICollisionCoordinator;
  46208. /**
  46209. * Defines the gravity applied to this scene (used only for collisions)
  46210. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46211. */
  46212. gravity: Vector3;
  46213. /**
  46214. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46215. */
  46216. postProcessesEnabled: boolean;
  46217. /**
  46218. * Gets the current postprocess manager
  46219. */
  46220. postProcessManager: PostProcessManager;
  46221. /**
  46222. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46223. */
  46224. renderTargetsEnabled: boolean;
  46225. /**
  46226. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46227. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46228. */
  46229. dumpNextRenderTargets: boolean;
  46230. /**
  46231. * The list of user defined render targets added to the scene
  46232. */
  46233. customRenderTargets: RenderTargetTexture[];
  46234. /**
  46235. * Defines if texture loading must be delayed
  46236. * If true, textures will only be loaded when they need to be rendered
  46237. */
  46238. useDelayedTextureLoading: boolean;
  46239. /**
  46240. * Gets the list of meshes imported to the scene through SceneLoader
  46241. */
  46242. importedMeshesFiles: String[];
  46243. /**
  46244. * Gets or sets a boolean indicating if probes are enabled on this scene
  46245. */
  46246. probesEnabled: boolean;
  46247. /**
  46248. * Gets or sets the current offline provider to use to store scene data
  46249. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46250. */
  46251. offlineProvider: IOfflineProvider;
  46252. /**
  46253. * Gets or sets the action manager associated with the scene
  46254. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46255. */
  46256. actionManager: AbstractActionManager;
  46257. private _meshesForIntersections;
  46258. /**
  46259. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46260. */
  46261. proceduralTexturesEnabled: boolean;
  46262. private _engine;
  46263. private _totalVertices;
  46264. /** @hidden */
  46265. _activeIndices: PerfCounter;
  46266. /** @hidden */
  46267. _activeParticles: PerfCounter;
  46268. /** @hidden */
  46269. _activeBones: PerfCounter;
  46270. private _animationRatio;
  46271. /** @hidden */
  46272. _animationTimeLast: number;
  46273. /** @hidden */
  46274. _animationTime: number;
  46275. /**
  46276. * Gets or sets a general scale for animation speed
  46277. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46278. */
  46279. animationTimeScale: number;
  46280. /** @hidden */
  46281. _cachedMaterial: Nullable<Material>;
  46282. /** @hidden */
  46283. _cachedEffect: Nullable<Effect>;
  46284. /** @hidden */
  46285. _cachedVisibility: Nullable<number>;
  46286. private _renderId;
  46287. private _frameId;
  46288. private _executeWhenReadyTimeoutId;
  46289. private _intermediateRendering;
  46290. private _viewUpdateFlag;
  46291. private _projectionUpdateFlag;
  46292. /** @hidden */
  46293. _toBeDisposed: Nullable<IDisposable>[];
  46294. private _activeRequests;
  46295. /** @hidden */
  46296. _pendingData: any[];
  46297. private _isDisposed;
  46298. /**
  46299. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46300. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46301. */
  46302. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46303. private _activeMeshes;
  46304. private _processedMaterials;
  46305. private _renderTargets;
  46306. /** @hidden */
  46307. _activeParticleSystems: SmartArray<IParticleSystem>;
  46308. private _activeSkeletons;
  46309. private _softwareSkinnedMeshes;
  46310. private _renderingManager;
  46311. /** @hidden */
  46312. _activeAnimatables: Animatable[];
  46313. private _transformMatrix;
  46314. private _sceneUbo;
  46315. /** @hidden */
  46316. _viewMatrix: Matrix;
  46317. /** @hidden */
  46318. _projectionMatrix: Matrix;
  46319. /** @hidden */
  46320. _forcedViewPosition: Nullable<Vector3>;
  46321. /** @hidden */
  46322. _frustumPlanes: Plane[];
  46323. /**
  46324. * Gets the list of frustum planes (built from the active camera)
  46325. */
  46326. get frustumPlanes(): Plane[];
  46327. /**
  46328. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46329. * This is useful if there are more lights that the maximum simulteanous authorized
  46330. */
  46331. requireLightSorting: boolean;
  46332. /** @hidden */
  46333. readonly useMaterialMeshMap: boolean;
  46334. /** @hidden */
  46335. readonly useClonedMeshMap: boolean;
  46336. private _externalData;
  46337. private _uid;
  46338. /**
  46339. * @hidden
  46340. * Backing store of defined scene components.
  46341. */
  46342. _components: ISceneComponent[];
  46343. /**
  46344. * @hidden
  46345. * Backing store of defined scene components.
  46346. */
  46347. _serializableComponents: ISceneSerializableComponent[];
  46348. /**
  46349. * List of components to register on the next registration step.
  46350. */
  46351. private _transientComponents;
  46352. /**
  46353. * Registers the transient components if needed.
  46354. */
  46355. private _registerTransientComponents;
  46356. /**
  46357. * @hidden
  46358. * Add a component to the scene.
  46359. * Note that the ccomponent could be registered on th next frame if this is called after
  46360. * the register component stage.
  46361. * @param component Defines the component to add to the scene
  46362. */
  46363. _addComponent(component: ISceneComponent): void;
  46364. /**
  46365. * @hidden
  46366. * Gets a component from the scene.
  46367. * @param name defines the name of the component to retrieve
  46368. * @returns the component or null if not present
  46369. */
  46370. _getComponent(name: string): Nullable<ISceneComponent>;
  46371. /**
  46372. * @hidden
  46373. * Defines the actions happening before camera updates.
  46374. */
  46375. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  46376. /**
  46377. * @hidden
  46378. * Defines the actions happening before clear the canvas.
  46379. */
  46380. _beforeClearStage: Stage<SimpleStageAction>;
  46381. /**
  46382. * @hidden
  46383. * Defines the actions when collecting render targets for the frame.
  46384. */
  46385. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46386. /**
  46387. * @hidden
  46388. * Defines the actions happening for one camera in the frame.
  46389. */
  46390. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46391. /**
  46392. * @hidden
  46393. * Defines the actions happening during the per mesh ready checks.
  46394. */
  46395. _isReadyForMeshStage: Stage<MeshStageAction>;
  46396. /**
  46397. * @hidden
  46398. * Defines the actions happening before evaluate active mesh checks.
  46399. */
  46400. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  46401. /**
  46402. * @hidden
  46403. * Defines the actions happening during the evaluate sub mesh checks.
  46404. */
  46405. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  46406. /**
  46407. * @hidden
  46408. * Defines the actions happening during the active mesh stage.
  46409. */
  46410. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  46411. /**
  46412. * @hidden
  46413. * Defines the actions happening during the per camera render target step.
  46414. */
  46415. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  46416. /**
  46417. * @hidden
  46418. * Defines the actions happening just before the active camera is drawing.
  46419. */
  46420. _beforeCameraDrawStage: Stage<CameraStageAction>;
  46421. /**
  46422. * @hidden
  46423. * Defines the actions happening just before a render target is drawing.
  46424. */
  46425. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46426. /**
  46427. * @hidden
  46428. * Defines the actions happening just before a rendering group is drawing.
  46429. */
  46430. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46431. /**
  46432. * @hidden
  46433. * Defines the actions happening just before a mesh is drawing.
  46434. */
  46435. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46436. /**
  46437. * @hidden
  46438. * Defines the actions happening just after a mesh has been drawn.
  46439. */
  46440. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46441. /**
  46442. * @hidden
  46443. * Defines the actions happening just after a rendering group has been drawn.
  46444. */
  46445. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46446. /**
  46447. * @hidden
  46448. * Defines the actions happening just after the active camera has been drawn.
  46449. */
  46450. _afterCameraDrawStage: Stage<CameraStageAction>;
  46451. /**
  46452. * @hidden
  46453. * Defines the actions happening just after a render target has been drawn.
  46454. */
  46455. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46456. /**
  46457. * @hidden
  46458. * Defines the actions happening just after rendering all cameras and computing intersections.
  46459. */
  46460. _afterRenderStage: Stage<SimpleStageAction>;
  46461. /**
  46462. * @hidden
  46463. * Defines the actions happening when a pointer move event happens.
  46464. */
  46465. _pointerMoveStage: Stage<PointerMoveStageAction>;
  46466. /**
  46467. * @hidden
  46468. * Defines the actions happening when a pointer down event happens.
  46469. */
  46470. _pointerDownStage: Stage<PointerUpDownStageAction>;
  46471. /**
  46472. * @hidden
  46473. * Defines the actions happening when a pointer up event happens.
  46474. */
  46475. _pointerUpStage: Stage<PointerUpDownStageAction>;
  46476. /**
  46477. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  46478. */
  46479. private geometriesByUniqueId;
  46480. private _renderBundles;
  46481. /**
  46482. * Creates a new Scene
  46483. * @param engine defines the engine to use to render this scene
  46484. * @param options defines the scene options
  46485. */
  46486. constructor(engine: Engine, options?: SceneOptions);
  46487. /**
  46488. * Gets a string identifying the name of the class
  46489. * @returns "Scene" string
  46490. */
  46491. getClassName(): string;
  46492. private _defaultMeshCandidates;
  46493. /**
  46494. * @hidden
  46495. */
  46496. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46497. private _defaultSubMeshCandidates;
  46498. /**
  46499. * @hidden
  46500. */
  46501. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46502. /**
  46503. * Sets the default candidate providers for the scene.
  46504. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  46505. * and getCollidingSubMeshCandidates to their default function
  46506. */
  46507. setDefaultCandidateProviders(): void;
  46508. /**
  46509. * Gets the mesh that is currently under the pointer
  46510. */
  46511. get meshUnderPointer(): Nullable<AbstractMesh>;
  46512. /**
  46513. * Gets or sets the current on-screen X position of the pointer
  46514. */
  46515. get pointerX(): number;
  46516. set pointerX(value: number);
  46517. /**
  46518. * Gets or sets the current on-screen Y position of the pointer
  46519. */
  46520. get pointerY(): number;
  46521. set pointerY(value: number);
  46522. /**
  46523. * Gets the cached material (ie. the latest rendered one)
  46524. * @returns the cached material
  46525. */
  46526. getCachedMaterial(): Nullable<Material>;
  46527. /**
  46528. * Gets the cached effect (ie. the latest rendered one)
  46529. * @returns the cached effect
  46530. */
  46531. getCachedEffect(): Nullable<Effect>;
  46532. /**
  46533. * Gets the cached visibility state (ie. the latest rendered one)
  46534. * @returns the cached visibility state
  46535. */
  46536. getCachedVisibility(): Nullable<number>;
  46537. /**
  46538. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  46539. * @param material defines the current material
  46540. * @param effect defines the current effect
  46541. * @param visibility defines the current visibility state
  46542. * @returns true if one parameter is not cached
  46543. */
  46544. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  46545. /**
  46546. * Gets the engine associated with the scene
  46547. * @returns an Engine
  46548. */
  46549. getEngine(): Engine;
  46550. /**
  46551. * Gets the total number of vertices rendered per frame
  46552. * @returns the total number of vertices rendered per frame
  46553. */
  46554. getTotalVertices(): number;
  46555. /**
  46556. * Gets the performance counter for total vertices
  46557. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46558. */
  46559. get totalVerticesPerfCounter(): PerfCounter;
  46560. /**
  46561. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  46562. * @returns the total number of active indices rendered per frame
  46563. */
  46564. getActiveIndices(): number;
  46565. /**
  46566. * Gets the performance counter for active indices
  46567. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46568. */
  46569. get totalActiveIndicesPerfCounter(): PerfCounter;
  46570. /**
  46571. * Gets the total number of active particles rendered per frame
  46572. * @returns the total number of active particles rendered per frame
  46573. */
  46574. getActiveParticles(): number;
  46575. /**
  46576. * Gets the performance counter for active particles
  46577. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46578. */
  46579. get activeParticlesPerfCounter(): PerfCounter;
  46580. /**
  46581. * Gets the total number of active bones rendered per frame
  46582. * @returns the total number of active bones rendered per frame
  46583. */
  46584. getActiveBones(): number;
  46585. /**
  46586. * Gets the performance counter for active bones
  46587. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46588. */
  46589. get activeBonesPerfCounter(): PerfCounter;
  46590. /**
  46591. * Gets the array of active meshes
  46592. * @returns an array of AbstractMesh
  46593. */
  46594. getActiveMeshes(): SmartArray<AbstractMesh>;
  46595. /**
  46596. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  46597. * @returns a number
  46598. */
  46599. getAnimationRatio(): number;
  46600. /**
  46601. * Gets an unique Id for the current render phase
  46602. * @returns a number
  46603. */
  46604. getRenderId(): number;
  46605. /**
  46606. * Gets an unique Id for the current frame
  46607. * @returns a number
  46608. */
  46609. getFrameId(): number;
  46610. /** Call this function if you want to manually increment the render Id*/
  46611. incrementRenderId(): void;
  46612. private _createUbo;
  46613. /**
  46614. * Use this method to simulate a pointer move on a mesh
  46615. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46616. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46617. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46618. * @returns the current scene
  46619. */
  46620. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46621. /**
  46622. * Use this method to simulate a pointer down on a mesh
  46623. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46624. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46625. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46626. * @returns the current scene
  46627. */
  46628. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46629. /**
  46630. * Use this method to simulate a pointer up on a mesh
  46631. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46632. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46633. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46634. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  46635. * @returns the current scene
  46636. */
  46637. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  46638. /**
  46639. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  46640. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  46641. * @returns true if the pointer was captured
  46642. */
  46643. isPointerCaptured(pointerId?: number): boolean;
  46644. /**
  46645. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  46646. * @param attachUp defines if you want to attach events to pointerup
  46647. * @param attachDown defines if you want to attach events to pointerdown
  46648. * @param attachMove defines if you want to attach events to pointermove
  46649. */
  46650. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  46651. /** Detaches all event handlers*/
  46652. detachControl(): void;
  46653. /**
  46654. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  46655. * Delay loaded resources are not taking in account
  46656. * @return true if all required resources are ready
  46657. */
  46658. isReady(): boolean;
  46659. /** Resets all cached information relative to material (including effect and visibility) */
  46660. resetCachedMaterial(): void;
  46661. /**
  46662. * Registers a function to be called before every frame render
  46663. * @param func defines the function to register
  46664. */
  46665. registerBeforeRender(func: () => void): void;
  46666. /**
  46667. * Unregisters a function called before every frame render
  46668. * @param func defines the function to unregister
  46669. */
  46670. unregisterBeforeRender(func: () => void): void;
  46671. /**
  46672. * Registers a function to be called after every frame render
  46673. * @param func defines the function to register
  46674. */
  46675. registerAfterRender(func: () => void): void;
  46676. /**
  46677. * Unregisters a function called after every frame render
  46678. * @param func defines the function to unregister
  46679. */
  46680. unregisterAfterRender(func: () => void): void;
  46681. private _executeOnceBeforeRender;
  46682. /**
  46683. * The provided function will run before render once and will be disposed afterwards.
  46684. * A timeout delay can be provided so that the function will be executed in N ms.
  46685. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  46686. * @param func The function to be executed.
  46687. * @param timeout optional delay in ms
  46688. */
  46689. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  46690. /** @hidden */
  46691. _addPendingData(data: any): void;
  46692. /** @hidden */
  46693. _removePendingData(data: any): void;
  46694. /**
  46695. * Returns the number of items waiting to be loaded
  46696. * @returns the number of items waiting to be loaded
  46697. */
  46698. getWaitingItemsCount(): number;
  46699. /**
  46700. * Returns a boolean indicating if the scene is still loading data
  46701. */
  46702. get isLoading(): boolean;
  46703. /**
  46704. * Registers a function to be executed when the scene is ready
  46705. * @param {Function} func - the function to be executed
  46706. */
  46707. executeWhenReady(func: () => void): void;
  46708. /**
  46709. * Returns a promise that resolves when the scene is ready
  46710. * @returns A promise that resolves when the scene is ready
  46711. */
  46712. whenReadyAsync(): Promise<void>;
  46713. /** @hidden */
  46714. _checkIsReady(): void;
  46715. /**
  46716. * Gets all animatable attached to the scene
  46717. */
  46718. get animatables(): Animatable[];
  46719. /**
  46720. * Resets the last animation time frame.
  46721. * Useful to override when animations start running when loading a scene for the first time.
  46722. */
  46723. resetLastAnimationTimeFrame(): void;
  46724. /**
  46725. * Gets the current view matrix
  46726. * @returns a Matrix
  46727. */
  46728. getViewMatrix(): Matrix;
  46729. /**
  46730. * Gets the current projection matrix
  46731. * @returns a Matrix
  46732. */
  46733. getProjectionMatrix(): Matrix;
  46734. /**
  46735. * Gets the current transform matrix
  46736. * @returns a Matrix made of View * Projection
  46737. */
  46738. getTransformMatrix(): Matrix;
  46739. /**
  46740. * Sets the current transform matrix
  46741. * @param viewL defines the View matrix to use
  46742. * @param projectionL defines the Projection matrix to use
  46743. * @param viewR defines the right View matrix to use (if provided)
  46744. * @param projectionR defines the right Projection matrix to use (if provided)
  46745. */
  46746. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  46747. /**
  46748. * Gets the uniform buffer used to store scene data
  46749. * @returns a UniformBuffer
  46750. */
  46751. getSceneUniformBuffer(): UniformBuffer;
  46752. /**
  46753. * Gets an unique (relatively to the current scene) Id
  46754. * @returns an unique number for the scene
  46755. */
  46756. getUniqueId(): number;
  46757. /**
  46758. * Add a mesh to the list of scene's meshes
  46759. * @param newMesh defines the mesh to add
  46760. * @param recursive if all child meshes should also be added to the scene
  46761. */
  46762. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  46763. /**
  46764. * Remove a mesh for the list of scene's meshes
  46765. * @param toRemove defines the mesh to remove
  46766. * @param recursive if all child meshes should also be removed from the scene
  46767. * @returns the index where the mesh was in the mesh list
  46768. */
  46769. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  46770. /**
  46771. * Add a transform node to the list of scene's transform nodes
  46772. * @param newTransformNode defines the transform node to add
  46773. */
  46774. addTransformNode(newTransformNode: TransformNode): void;
  46775. /**
  46776. * Remove a transform node for the list of scene's transform nodes
  46777. * @param toRemove defines the transform node to remove
  46778. * @returns the index where the transform node was in the transform node list
  46779. */
  46780. removeTransformNode(toRemove: TransformNode): number;
  46781. /**
  46782. * Remove a skeleton for the list of scene's skeletons
  46783. * @param toRemove defines the skeleton to remove
  46784. * @returns the index where the skeleton was in the skeleton list
  46785. */
  46786. removeSkeleton(toRemove: Skeleton): number;
  46787. /**
  46788. * Remove a morph target for the list of scene's morph targets
  46789. * @param toRemove defines the morph target to remove
  46790. * @returns the index where the morph target was in the morph target list
  46791. */
  46792. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  46793. /**
  46794. * Remove a light for the list of scene's lights
  46795. * @param toRemove defines the light to remove
  46796. * @returns the index where the light was in the light list
  46797. */
  46798. removeLight(toRemove: Light): number;
  46799. /**
  46800. * Remove a camera for the list of scene's cameras
  46801. * @param toRemove defines the camera to remove
  46802. * @returns the index where the camera was in the camera list
  46803. */
  46804. removeCamera(toRemove: Camera): number;
  46805. /**
  46806. * Remove a particle system for the list of scene's particle systems
  46807. * @param toRemove defines the particle system to remove
  46808. * @returns the index where the particle system was in the particle system list
  46809. */
  46810. removeParticleSystem(toRemove: IParticleSystem): number;
  46811. /**
  46812. * Remove a animation for the list of scene's animations
  46813. * @param toRemove defines the animation to remove
  46814. * @returns the index where the animation was in the animation list
  46815. */
  46816. removeAnimation(toRemove: Animation): number;
  46817. /**
  46818. * Will stop the animation of the given target
  46819. * @param target - the target
  46820. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  46821. * @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)
  46822. */
  46823. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  46824. /**
  46825. * Removes the given animation group from this scene.
  46826. * @param toRemove The animation group to remove
  46827. * @returns The index of the removed animation group
  46828. */
  46829. removeAnimationGroup(toRemove: AnimationGroup): number;
  46830. /**
  46831. * Removes the given multi-material from this scene.
  46832. * @param toRemove The multi-material to remove
  46833. * @returns The index of the removed multi-material
  46834. */
  46835. removeMultiMaterial(toRemove: MultiMaterial): number;
  46836. /**
  46837. * Removes the given material from this scene.
  46838. * @param toRemove The material to remove
  46839. * @returns The index of the removed material
  46840. */
  46841. removeMaterial(toRemove: Material): number;
  46842. /**
  46843. * Removes the given action manager from this scene.
  46844. * @param toRemove The action manager to remove
  46845. * @returns The index of the removed action manager
  46846. */
  46847. removeActionManager(toRemove: AbstractActionManager): number;
  46848. /**
  46849. * Removes the given texture from this scene.
  46850. * @param toRemove The texture to remove
  46851. * @returns The index of the removed texture
  46852. */
  46853. removeTexture(toRemove: BaseTexture): number;
  46854. /**
  46855. * Adds the given light to this scene
  46856. * @param newLight The light to add
  46857. */
  46858. addLight(newLight: Light): void;
  46859. /**
  46860. * Sorts the list list based on light priorities
  46861. */
  46862. sortLightsByPriority(): void;
  46863. /**
  46864. * Adds the given camera to this scene
  46865. * @param newCamera The camera to add
  46866. */
  46867. addCamera(newCamera: Camera): void;
  46868. /**
  46869. * Adds the given skeleton to this scene
  46870. * @param newSkeleton The skeleton to add
  46871. */
  46872. addSkeleton(newSkeleton: Skeleton): void;
  46873. /**
  46874. * Adds the given particle system to this scene
  46875. * @param newParticleSystem The particle system to add
  46876. */
  46877. addParticleSystem(newParticleSystem: IParticleSystem): void;
  46878. /**
  46879. * Adds the given animation to this scene
  46880. * @param newAnimation The animation to add
  46881. */
  46882. addAnimation(newAnimation: Animation): void;
  46883. /**
  46884. * Adds the given animation group to this scene.
  46885. * @param newAnimationGroup The animation group to add
  46886. */
  46887. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  46888. /**
  46889. * Adds the given multi-material to this scene
  46890. * @param newMultiMaterial The multi-material to add
  46891. */
  46892. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  46893. /**
  46894. * Adds the given material to this scene
  46895. * @param newMaterial The material to add
  46896. */
  46897. addMaterial(newMaterial: Material): void;
  46898. /**
  46899. * Adds the given morph target to this scene
  46900. * @param newMorphTargetManager The morph target to add
  46901. */
  46902. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  46903. /**
  46904. * Adds the given geometry to this scene
  46905. * @param newGeometry The geometry to add
  46906. */
  46907. addGeometry(newGeometry: Geometry): void;
  46908. /**
  46909. * Adds the given action manager to this scene
  46910. * @param newActionManager The action manager to add
  46911. */
  46912. addActionManager(newActionManager: AbstractActionManager): void;
  46913. /**
  46914. * Adds the given texture to this scene.
  46915. * @param newTexture The texture to add
  46916. */
  46917. addTexture(newTexture: BaseTexture): void;
  46918. /**
  46919. * Switch active camera
  46920. * @param newCamera defines the new active camera
  46921. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  46922. */
  46923. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  46924. /**
  46925. * sets the active camera of the scene using its ID
  46926. * @param id defines the camera's ID
  46927. * @return the new active camera or null if none found.
  46928. */
  46929. setActiveCameraByID(id: string): Nullable<Camera>;
  46930. /**
  46931. * sets the active camera of the scene using its name
  46932. * @param name defines the camera's name
  46933. * @returns the new active camera or null if none found.
  46934. */
  46935. setActiveCameraByName(name: string): Nullable<Camera>;
  46936. /**
  46937. * get an animation group using its name
  46938. * @param name defines the material's name
  46939. * @return the animation group or null if none found.
  46940. */
  46941. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  46942. /**
  46943. * Get a material using its unique id
  46944. * @param uniqueId defines the material's unique id
  46945. * @return the material or null if none found.
  46946. */
  46947. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  46948. /**
  46949. * get a material using its id
  46950. * @param id defines the material's ID
  46951. * @return the material or null if none found.
  46952. */
  46953. getMaterialByID(id: string): Nullable<Material>;
  46954. /**
  46955. * Gets a the last added material using a given id
  46956. * @param id defines the material's ID
  46957. * @return the last material with the given id or null if none found.
  46958. */
  46959. getLastMaterialByID(id: string): Nullable<Material>;
  46960. /**
  46961. * Gets a material using its name
  46962. * @param name defines the material's name
  46963. * @return the material or null if none found.
  46964. */
  46965. getMaterialByName(name: string): Nullable<Material>;
  46966. /**
  46967. * Get a texture using its unique id
  46968. * @param uniqueId defines the texture's unique id
  46969. * @return the texture or null if none found.
  46970. */
  46971. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  46972. /**
  46973. * Gets a camera using its id
  46974. * @param id defines the id to look for
  46975. * @returns the camera or null if not found
  46976. */
  46977. getCameraByID(id: string): Nullable<Camera>;
  46978. /**
  46979. * Gets a camera using its unique id
  46980. * @param uniqueId defines the unique id to look for
  46981. * @returns the camera or null if not found
  46982. */
  46983. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  46984. /**
  46985. * Gets a camera using its name
  46986. * @param name defines the camera's name
  46987. * @return the camera or null if none found.
  46988. */
  46989. getCameraByName(name: string): Nullable<Camera>;
  46990. /**
  46991. * Gets a bone using its id
  46992. * @param id defines the bone's id
  46993. * @return the bone or null if not found
  46994. */
  46995. getBoneByID(id: string): Nullable<Bone>;
  46996. /**
  46997. * Gets a bone using its id
  46998. * @param name defines the bone's name
  46999. * @return the bone or null if not found
  47000. */
  47001. getBoneByName(name: string): Nullable<Bone>;
  47002. /**
  47003. * Gets a light node using its name
  47004. * @param name defines the the light's name
  47005. * @return the light or null if none found.
  47006. */
  47007. getLightByName(name: string): Nullable<Light>;
  47008. /**
  47009. * Gets a light node using its id
  47010. * @param id defines the light's id
  47011. * @return the light or null if none found.
  47012. */
  47013. getLightByID(id: string): Nullable<Light>;
  47014. /**
  47015. * Gets a light node using its scene-generated unique ID
  47016. * @param uniqueId defines the light's unique id
  47017. * @return the light or null if none found.
  47018. */
  47019. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47020. /**
  47021. * Gets a particle system by id
  47022. * @param id defines the particle system id
  47023. * @return the corresponding system or null if none found
  47024. */
  47025. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47026. /**
  47027. * Gets a geometry using its ID
  47028. * @param id defines the geometry's id
  47029. * @return the geometry or null if none found.
  47030. */
  47031. getGeometryByID(id: string): Nullable<Geometry>;
  47032. private _getGeometryByUniqueID;
  47033. /**
  47034. * Add a new geometry to this scene
  47035. * @param geometry defines the geometry to be added to the scene.
  47036. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47037. * @return a boolean defining if the geometry was added or not
  47038. */
  47039. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47040. /**
  47041. * Removes an existing geometry
  47042. * @param geometry defines the geometry to be removed from the scene
  47043. * @return a boolean defining if the geometry was removed or not
  47044. */
  47045. removeGeometry(geometry: Geometry): boolean;
  47046. /**
  47047. * Gets the list of geometries attached to the scene
  47048. * @returns an array of Geometry
  47049. */
  47050. getGeometries(): Geometry[];
  47051. /**
  47052. * Gets the first added mesh found of a given ID
  47053. * @param id defines the id to search for
  47054. * @return the mesh found or null if not found at all
  47055. */
  47056. getMeshByID(id: string): Nullable<AbstractMesh>;
  47057. /**
  47058. * Gets a list of meshes using their id
  47059. * @param id defines the id to search for
  47060. * @returns a list of meshes
  47061. */
  47062. getMeshesByID(id: string): Array<AbstractMesh>;
  47063. /**
  47064. * Gets the first added transform node found of a given ID
  47065. * @param id defines the id to search for
  47066. * @return the found transform node or null if not found at all.
  47067. */
  47068. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47069. /**
  47070. * Gets a transform node with its auto-generated unique id
  47071. * @param uniqueId efines the unique id to search for
  47072. * @return the found transform node or null if not found at all.
  47073. */
  47074. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47075. /**
  47076. * Gets a list of transform nodes using their id
  47077. * @param id defines the id to search for
  47078. * @returns a list of transform nodes
  47079. */
  47080. getTransformNodesByID(id: string): Array<TransformNode>;
  47081. /**
  47082. * Gets a mesh with its auto-generated unique id
  47083. * @param uniqueId defines the unique id to search for
  47084. * @return the found mesh or null if not found at all.
  47085. */
  47086. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47087. /**
  47088. * Gets a the last added mesh using a given id
  47089. * @param id defines the id to search for
  47090. * @return the found mesh or null if not found at all.
  47091. */
  47092. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47093. /**
  47094. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47095. * @param id defines the id to search for
  47096. * @return the found node or null if not found at all
  47097. */
  47098. getLastEntryByID(id: string): Nullable<Node>;
  47099. /**
  47100. * Gets a node (Mesh, Camera, Light) using a given id
  47101. * @param id defines the id to search for
  47102. * @return the found node or null if not found at all
  47103. */
  47104. getNodeByID(id: string): Nullable<Node>;
  47105. /**
  47106. * Gets a node (Mesh, Camera, Light) using a given name
  47107. * @param name defines the name to search for
  47108. * @return the found node or null if not found at all.
  47109. */
  47110. getNodeByName(name: string): Nullable<Node>;
  47111. /**
  47112. * Gets a mesh using a given name
  47113. * @param name defines the name to search for
  47114. * @return the found mesh or null if not found at all.
  47115. */
  47116. getMeshByName(name: string): Nullable<AbstractMesh>;
  47117. /**
  47118. * Gets a transform node using a given name
  47119. * @param name defines the name to search for
  47120. * @return the found transform node or null if not found at all.
  47121. */
  47122. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47123. /**
  47124. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47125. * @param id defines the id to search for
  47126. * @return the found skeleton or null if not found at all.
  47127. */
  47128. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47129. /**
  47130. * Gets a skeleton using a given auto generated unique id
  47131. * @param uniqueId defines the unique id to search for
  47132. * @return the found skeleton or null if not found at all.
  47133. */
  47134. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47135. /**
  47136. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47137. * @param id defines the id to search for
  47138. * @return the found skeleton or null if not found at all.
  47139. */
  47140. getSkeletonById(id: string): Nullable<Skeleton>;
  47141. /**
  47142. * Gets a skeleton using a given name
  47143. * @param name defines the name to search for
  47144. * @return the found skeleton or null if not found at all.
  47145. */
  47146. getSkeletonByName(name: string): Nullable<Skeleton>;
  47147. /**
  47148. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47149. * @param id defines the id to search for
  47150. * @return the found morph target manager or null if not found at all.
  47151. */
  47152. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47153. /**
  47154. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47155. * @param id defines the id to search for
  47156. * @return the found morph target or null if not found at all.
  47157. */
  47158. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47159. /**
  47160. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47161. * @param name defines the name to search for
  47162. * @return the found morph target or null if not found at all.
  47163. */
  47164. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47165. /**
  47166. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47167. * @param name defines the name to search for
  47168. * @return the found post process or null if not found at all.
  47169. */
  47170. getPostProcessByName(name: string): Nullable<PostProcess>;
  47171. /**
  47172. * Gets a boolean indicating if the given mesh is active
  47173. * @param mesh defines the mesh to look for
  47174. * @returns true if the mesh is in the active list
  47175. */
  47176. isActiveMesh(mesh: AbstractMesh): boolean;
  47177. /**
  47178. * Return a unique id as a string which can serve as an identifier for the scene
  47179. */
  47180. get uid(): string;
  47181. /**
  47182. * Add an externaly attached data from its key.
  47183. * This method call will fail and return false, if such key already exists.
  47184. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47185. * @param key the unique key that identifies the data
  47186. * @param data the data object to associate to the key for this Engine instance
  47187. * @return true if no such key were already present and the data was added successfully, false otherwise
  47188. */
  47189. addExternalData<T>(key: string, data: T): boolean;
  47190. /**
  47191. * Get an externaly attached data from its key
  47192. * @param key the unique key that identifies the data
  47193. * @return the associated data, if present (can be null), or undefined if not present
  47194. */
  47195. getExternalData<T>(key: string): Nullable<T>;
  47196. /**
  47197. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47198. * @param key the unique key that identifies the data
  47199. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47200. * @return the associated data, can be null if the factory returned null.
  47201. */
  47202. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47203. /**
  47204. * Remove an externaly attached data from the Engine instance
  47205. * @param key the unique key that identifies the data
  47206. * @return true if the data was successfully removed, false if it doesn't exist
  47207. */
  47208. removeExternalData(key: string): boolean;
  47209. private _evaluateSubMesh;
  47210. /**
  47211. * Clear the processed materials smart array preventing retention point in material dispose.
  47212. */
  47213. freeProcessedMaterials(): void;
  47214. private _preventFreeActiveMeshesAndRenderingGroups;
  47215. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47216. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47217. * when disposing several meshes in a row or a hierarchy of meshes.
  47218. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47219. */
  47220. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47221. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47222. /**
  47223. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47224. */
  47225. freeActiveMeshes(): void;
  47226. /**
  47227. * Clear the info related to rendering groups preventing retention points during dispose.
  47228. */
  47229. freeRenderingGroups(): void;
  47230. /** @hidden */
  47231. _isInIntermediateRendering(): boolean;
  47232. /**
  47233. * Lambda returning the list of potentially active meshes.
  47234. */
  47235. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47236. /**
  47237. * Lambda returning the list of potentially active sub meshes.
  47238. */
  47239. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47240. /**
  47241. * Lambda returning the list of potentially intersecting sub meshes.
  47242. */
  47243. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47244. /**
  47245. * Lambda returning the list of potentially colliding sub meshes.
  47246. */
  47247. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47248. /** @hidden */
  47249. _activeMeshesFrozen: boolean;
  47250. private _skipEvaluateActiveMeshesCompletely;
  47251. /**
  47252. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47253. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47254. * @param onSuccess optional success callback
  47255. * @param onError optional error callback
  47256. * @returns the current scene
  47257. */
  47258. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47259. /**
  47260. * Use this function to restart evaluating active meshes on every frame
  47261. * @returns the current scene
  47262. */
  47263. unfreezeActiveMeshes(): Scene;
  47264. private _evaluateActiveMeshes;
  47265. private _activeMesh;
  47266. /**
  47267. * Update the transform matrix to update from the current active camera
  47268. * @param force defines a boolean used to force the update even if cache is up to date
  47269. */
  47270. updateTransformMatrix(force?: boolean): void;
  47271. private _bindFrameBuffer;
  47272. /** @hidden */
  47273. _allowPostProcessClearColor: boolean;
  47274. /** @hidden */
  47275. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47276. private _processSubCameras;
  47277. private _checkIntersections;
  47278. /** @hidden */
  47279. _advancePhysicsEngineStep(step: number): void;
  47280. /**
  47281. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47282. */
  47283. getDeterministicFrameTime: () => number;
  47284. /** @hidden */
  47285. _animate(): void;
  47286. /** Execute all animations (for a frame) */
  47287. animate(): void;
  47288. /**
  47289. * Render the scene
  47290. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47291. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47292. */
  47293. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47294. /**
  47295. * Freeze all materials
  47296. * A frozen material will not be updatable but should be faster to render
  47297. */
  47298. freezeMaterials(): void;
  47299. /**
  47300. * Unfreeze all materials
  47301. * A frozen material will not be updatable but should be faster to render
  47302. */
  47303. unfreezeMaterials(): void;
  47304. /**
  47305. * Releases all held ressources
  47306. */
  47307. dispose(): void;
  47308. /**
  47309. * Gets if the scene is already disposed
  47310. */
  47311. get isDisposed(): boolean;
  47312. /**
  47313. * Call this function to reduce memory footprint of the scene.
  47314. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47315. */
  47316. clearCachedVertexData(): void;
  47317. /**
  47318. * This function will remove the local cached buffer data from texture.
  47319. * It will save memory but will prevent the texture from being rebuilt
  47320. */
  47321. cleanCachedTextureBuffer(): void;
  47322. /**
  47323. * Get the world extend vectors with an optional filter
  47324. *
  47325. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47326. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47327. */
  47328. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47329. min: Vector3;
  47330. max: Vector3;
  47331. };
  47332. /**
  47333. * Creates a ray that can be used to pick in the scene
  47334. * @param x defines the x coordinate of the origin (on-screen)
  47335. * @param y defines the y coordinate of the origin (on-screen)
  47336. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47337. * @param camera defines the camera to use for the picking
  47338. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47339. * @returns a Ray
  47340. */
  47341. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47342. /**
  47343. * Creates a ray that can be used to pick in the scene
  47344. * @param x defines the x coordinate of the origin (on-screen)
  47345. * @param y defines the y coordinate of the origin (on-screen)
  47346. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47347. * @param result defines the ray where to store the picking ray
  47348. * @param camera defines the camera to use for the picking
  47349. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47350. * @returns the current scene
  47351. */
  47352. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  47353. /**
  47354. * Creates a ray that can be used to pick in the scene
  47355. * @param x defines the x coordinate of the origin (on-screen)
  47356. * @param y defines the y coordinate of the origin (on-screen)
  47357. * @param camera defines the camera to use for the picking
  47358. * @returns a Ray
  47359. */
  47360. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  47361. /**
  47362. * Creates a ray that can be used to pick in the scene
  47363. * @param x defines the x coordinate of the origin (on-screen)
  47364. * @param y defines the y coordinate of the origin (on-screen)
  47365. * @param result defines the ray where to store the picking ray
  47366. * @param camera defines the camera to use for the picking
  47367. * @returns the current scene
  47368. */
  47369. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  47370. /** Launch a ray to try to pick a mesh in the scene
  47371. * @param x position on screen
  47372. * @param y position on screen
  47373. * @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
  47374. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47375. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47376. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47377. * @returns a PickingInfo
  47378. */
  47379. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47380. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  47381. * @param x position on screen
  47382. * @param y position on screen
  47383. * @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
  47384. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47385. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47386. * @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)
  47387. */
  47388. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  47389. /** Use the given ray to pick a mesh in the scene
  47390. * @param ray The ray to use to pick meshes
  47391. * @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
  47392. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47393. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47394. * @returns a PickingInfo
  47395. */
  47396. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47397. /**
  47398. * Launch a ray to try to pick a mesh in the scene
  47399. * @param x X position on screen
  47400. * @param y Y position on screen
  47401. * @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
  47402. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47403. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47404. * @returns an array of PickingInfo
  47405. */
  47406. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47407. /**
  47408. * Launch a ray to try to pick a mesh in the scene
  47409. * @param ray Ray to use
  47410. * @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
  47411. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47412. * @returns an array of PickingInfo
  47413. */
  47414. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47415. /**
  47416. * Force the value of meshUnderPointer
  47417. * @param mesh defines the mesh to use
  47418. * @param pointerId optional pointer id when using more than one pointer
  47419. */
  47420. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  47421. /**
  47422. * Gets the mesh under the pointer
  47423. * @returns a Mesh or null if no mesh is under the pointer
  47424. */
  47425. getPointerOverMesh(): Nullable<AbstractMesh>;
  47426. /** @hidden */
  47427. _rebuildGeometries(): void;
  47428. /** @hidden */
  47429. _rebuildTextures(): void;
  47430. private _getByTags;
  47431. /**
  47432. * Get a list of meshes by tags
  47433. * @param tagsQuery defines the tags query to use
  47434. * @param forEach defines a predicate used to filter results
  47435. * @returns an array of Mesh
  47436. */
  47437. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  47438. /**
  47439. * Get a list of cameras by tags
  47440. * @param tagsQuery defines the tags query to use
  47441. * @param forEach defines a predicate used to filter results
  47442. * @returns an array of Camera
  47443. */
  47444. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  47445. /**
  47446. * Get a list of lights by tags
  47447. * @param tagsQuery defines the tags query to use
  47448. * @param forEach defines a predicate used to filter results
  47449. * @returns an array of Light
  47450. */
  47451. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  47452. /**
  47453. * Get a list of materials by tags
  47454. * @param tagsQuery defines the tags query to use
  47455. * @param forEach defines a predicate used to filter results
  47456. * @returns an array of Material
  47457. */
  47458. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  47459. /**
  47460. * Get a list of transform nodes by tags
  47461. * @param tagsQuery defines the tags query to use
  47462. * @param forEach defines a predicate used to filter results
  47463. * @returns an array of TransformNode
  47464. */
  47465. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  47466. /**
  47467. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47468. * This allowed control for front to back rendering or reversly depending of the special needs.
  47469. *
  47470. * @param renderingGroupId The rendering group id corresponding to its index
  47471. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47472. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47473. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47474. */
  47475. 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;
  47476. /**
  47477. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47478. *
  47479. * @param renderingGroupId The rendering group id corresponding to its index
  47480. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47481. * @param depth Automatically clears depth between groups if true and autoClear is true.
  47482. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  47483. */
  47484. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  47485. /**
  47486. * Gets the current auto clear configuration for one rendering group of the rendering
  47487. * manager.
  47488. * @param index the rendering group index to get the information for
  47489. * @returns The auto clear setup for the requested rendering group
  47490. */
  47491. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  47492. private _blockMaterialDirtyMechanism;
  47493. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  47494. get blockMaterialDirtyMechanism(): boolean;
  47495. set blockMaterialDirtyMechanism(value: boolean);
  47496. /**
  47497. * Will flag all materials as dirty to trigger new shader compilation
  47498. * @param flag defines the flag used to specify which material part must be marked as dirty
  47499. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  47500. */
  47501. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  47502. /** @hidden */
  47503. _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;
  47504. /** @hidden */
  47505. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47506. /** @hidden */
  47507. _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;
  47508. /** @hidden */
  47509. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  47510. /** @hidden */
  47511. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  47512. /** @hidden */
  47513. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47514. }
  47515. }
  47516. declare module BABYLON {
  47517. /**
  47518. * Set of assets to keep when moving a scene into an asset container.
  47519. */
  47520. export class KeepAssets extends AbstractScene {
  47521. }
  47522. /**
  47523. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  47524. */
  47525. export class InstantiatedEntries {
  47526. /**
  47527. * List of new root nodes (eg. nodes with no parent)
  47528. */
  47529. rootNodes: TransformNode[];
  47530. /**
  47531. * List of new skeletons
  47532. */
  47533. skeletons: Skeleton[];
  47534. /**
  47535. * List of new animation groups
  47536. */
  47537. animationGroups: AnimationGroup[];
  47538. }
  47539. /**
  47540. * Container with a set of assets that can be added or removed from a scene.
  47541. */
  47542. export class AssetContainer extends AbstractScene {
  47543. private _wasAddedToScene;
  47544. /**
  47545. * The scene the AssetContainer belongs to.
  47546. */
  47547. scene: Scene;
  47548. /**
  47549. * Instantiates an AssetContainer.
  47550. * @param scene The scene the AssetContainer belongs to.
  47551. */
  47552. constructor(scene: Scene);
  47553. /**
  47554. * Instantiate or clone all meshes and add the new ones to the scene.
  47555. * Skeletons and animation groups will all be cloned
  47556. * @param nameFunction defines an optional function used to get new names for clones
  47557. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  47558. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  47559. */
  47560. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  47561. /**
  47562. * Adds all the assets from the container to the scene.
  47563. */
  47564. addAllToScene(): void;
  47565. /**
  47566. * Removes all the assets in the container from the scene
  47567. */
  47568. removeAllFromScene(): void;
  47569. /**
  47570. * Disposes all the assets in the container
  47571. */
  47572. dispose(): void;
  47573. private _moveAssets;
  47574. /**
  47575. * Removes all the assets contained in the scene and adds them to the container.
  47576. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  47577. */
  47578. moveAllFromScene(keepAssets?: KeepAssets): void;
  47579. /**
  47580. * 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.
  47581. * @returns the root mesh
  47582. */
  47583. createRootMesh(): Mesh;
  47584. /**
  47585. * Merge animations (direct and animation groups) from this asset container into a scene
  47586. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47587. * @param animatables set of animatables to retarget to a node from the scene
  47588. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  47589. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  47590. */
  47591. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  47592. }
  47593. }
  47594. declare module BABYLON {
  47595. /**
  47596. * Defines how the parser contract is defined.
  47597. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  47598. */
  47599. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  47600. /**
  47601. * Defines how the individual parser contract is defined.
  47602. * These parser can parse an individual asset
  47603. */
  47604. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  47605. /**
  47606. * Base class of the scene acting as a container for the different elements composing a scene.
  47607. * This class is dynamically extended by the different components of the scene increasing
  47608. * flexibility and reducing coupling
  47609. */
  47610. export abstract class AbstractScene {
  47611. /**
  47612. * Stores the list of available parsers in the application.
  47613. */
  47614. private static _BabylonFileParsers;
  47615. /**
  47616. * Stores the list of available individual parsers in the application.
  47617. */
  47618. private static _IndividualBabylonFileParsers;
  47619. /**
  47620. * Adds a parser in the list of available ones
  47621. * @param name Defines the name of the parser
  47622. * @param parser Defines the parser to add
  47623. */
  47624. static AddParser(name: string, parser: BabylonFileParser): void;
  47625. /**
  47626. * Gets a general parser from the list of avaialble ones
  47627. * @param name Defines the name of the parser
  47628. * @returns the requested parser or null
  47629. */
  47630. static GetParser(name: string): Nullable<BabylonFileParser>;
  47631. /**
  47632. * Adds n individual parser in the list of available ones
  47633. * @param name Defines the name of the parser
  47634. * @param parser Defines the parser to add
  47635. */
  47636. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47637. /**
  47638. * Gets an individual parser from the list of avaialble ones
  47639. * @param name Defines the name of the parser
  47640. * @returns the requested parser or null
  47641. */
  47642. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  47643. /**
  47644. * Parser json data and populate both a scene and its associated container object
  47645. * @param jsonData Defines the data to parse
  47646. * @param scene Defines the scene to parse the data for
  47647. * @param container Defines the container attached to the parsing sequence
  47648. * @param rootUrl Defines the root url of the data
  47649. */
  47650. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  47651. /**
  47652. * Gets the list of root nodes (ie. nodes with no parent)
  47653. */
  47654. rootNodes: Node[];
  47655. /** All of the cameras added to this scene
  47656. * @see https://doc.babylonjs.com/babylon101/cameras
  47657. */
  47658. cameras: Camera[];
  47659. /**
  47660. * All of the lights added to this scene
  47661. * @see https://doc.babylonjs.com/babylon101/lights
  47662. */
  47663. lights: Light[];
  47664. /**
  47665. * All of the (abstract) meshes added to this scene
  47666. */
  47667. meshes: AbstractMesh[];
  47668. /**
  47669. * The list of skeletons added to the scene
  47670. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  47671. */
  47672. skeletons: Skeleton[];
  47673. /**
  47674. * All of the particle systems added to this scene
  47675. * @see https://doc.babylonjs.com/babylon101/particles
  47676. */
  47677. particleSystems: IParticleSystem[];
  47678. /**
  47679. * Gets a list of Animations associated with the scene
  47680. */
  47681. animations: Animation[];
  47682. /**
  47683. * All of the animation groups added to this scene
  47684. * @see https://doc.babylonjs.com/how_to/group
  47685. */
  47686. animationGroups: AnimationGroup[];
  47687. /**
  47688. * All of the multi-materials added to this scene
  47689. * @see https://doc.babylonjs.com/how_to/multi_materials
  47690. */
  47691. multiMaterials: MultiMaterial[];
  47692. /**
  47693. * All of the materials added to this scene
  47694. * In the context of a Scene, it is not supposed to be modified manually.
  47695. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  47696. * Note also that the order of the Material within the array is not significant and might change.
  47697. * @see https://doc.babylonjs.com/babylon101/materials
  47698. */
  47699. materials: Material[];
  47700. /**
  47701. * The list of morph target managers added to the scene
  47702. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  47703. */
  47704. morphTargetManagers: MorphTargetManager[];
  47705. /**
  47706. * The list of geometries used in the scene.
  47707. */
  47708. geometries: Geometry[];
  47709. /**
  47710. * All of the tranform nodes added to this scene
  47711. * In the context of a Scene, it is not supposed to be modified manually.
  47712. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  47713. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  47714. * @see https://doc.babylonjs.com/how_to/transformnode
  47715. */
  47716. transformNodes: TransformNode[];
  47717. /**
  47718. * ActionManagers available on the scene.
  47719. */
  47720. actionManagers: AbstractActionManager[];
  47721. /**
  47722. * Textures to keep.
  47723. */
  47724. textures: BaseTexture[];
  47725. /** @hidden */
  47726. protected _environmentTexture: Nullable<BaseTexture>;
  47727. /**
  47728. * Texture used in all pbr material as the reflection texture.
  47729. * As in the majority of the scene they are the same (exception for multi room and so on),
  47730. * this is easier to reference from here than from all the materials.
  47731. */
  47732. get environmentTexture(): Nullable<BaseTexture>;
  47733. set environmentTexture(value: Nullable<BaseTexture>);
  47734. /**
  47735. * The list of postprocesses added to the scene
  47736. */
  47737. postProcesses: PostProcess[];
  47738. /**
  47739. * @returns all meshes, lights, cameras, transformNodes and bones
  47740. */
  47741. getNodes(): Array<Node>;
  47742. }
  47743. }
  47744. declare module BABYLON {
  47745. /**
  47746. * Interface used to define options for Sound class
  47747. */
  47748. export interface ISoundOptions {
  47749. /**
  47750. * Does the sound autoplay once loaded.
  47751. */
  47752. autoplay?: boolean;
  47753. /**
  47754. * Does the sound loop after it finishes playing once.
  47755. */
  47756. loop?: boolean;
  47757. /**
  47758. * Sound's volume
  47759. */
  47760. volume?: number;
  47761. /**
  47762. * Is it a spatial sound?
  47763. */
  47764. spatialSound?: boolean;
  47765. /**
  47766. * Maximum distance to hear that sound
  47767. */
  47768. maxDistance?: number;
  47769. /**
  47770. * Uses user defined attenuation function
  47771. */
  47772. useCustomAttenuation?: boolean;
  47773. /**
  47774. * Define the roll off factor of spatial sounds.
  47775. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47776. */
  47777. rolloffFactor?: number;
  47778. /**
  47779. * Define the reference distance the sound should be heard perfectly.
  47780. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47781. */
  47782. refDistance?: number;
  47783. /**
  47784. * Define the distance attenuation model the sound will follow.
  47785. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47786. */
  47787. distanceModel?: string;
  47788. /**
  47789. * Defines the playback speed (1 by default)
  47790. */
  47791. playbackRate?: number;
  47792. /**
  47793. * Defines if the sound is from a streaming source
  47794. */
  47795. streaming?: boolean;
  47796. /**
  47797. * Defines an optional length (in seconds) inside the sound file
  47798. */
  47799. length?: number;
  47800. /**
  47801. * Defines an optional offset (in seconds) inside the sound file
  47802. */
  47803. offset?: number;
  47804. /**
  47805. * If true, URLs will not be required to state the audio file codec to use.
  47806. */
  47807. skipCodecCheck?: boolean;
  47808. }
  47809. }
  47810. declare module BABYLON {
  47811. /**
  47812. * Defines a sound that can be played in the application.
  47813. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  47814. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47815. */
  47816. export class Sound {
  47817. /**
  47818. * The name of the sound in the scene.
  47819. */
  47820. name: string;
  47821. /**
  47822. * Does the sound autoplay once loaded.
  47823. */
  47824. autoplay: boolean;
  47825. private _loop;
  47826. /**
  47827. * Does the sound loop after it finishes playing once.
  47828. */
  47829. get loop(): boolean;
  47830. set loop(value: boolean);
  47831. /**
  47832. * Does the sound use a custom attenuation curve to simulate the falloff
  47833. * happening when the source gets further away from the camera.
  47834. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  47835. */
  47836. useCustomAttenuation: boolean;
  47837. /**
  47838. * The sound track id this sound belongs to.
  47839. */
  47840. soundTrackId: number;
  47841. /**
  47842. * Is this sound currently played.
  47843. */
  47844. isPlaying: boolean;
  47845. /**
  47846. * Is this sound currently paused.
  47847. */
  47848. isPaused: boolean;
  47849. /**
  47850. * Does this sound enables spatial sound.
  47851. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47852. */
  47853. spatialSound: boolean;
  47854. /**
  47855. * Define the reference distance the sound should be heard perfectly.
  47856. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47857. */
  47858. refDistance: number;
  47859. /**
  47860. * Define the roll off factor of spatial sounds.
  47861. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47862. */
  47863. rolloffFactor: number;
  47864. /**
  47865. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  47866. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47867. */
  47868. maxDistance: number;
  47869. /**
  47870. * Define the distance attenuation model the sound will follow.
  47871. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47872. */
  47873. distanceModel: string;
  47874. /**
  47875. * @hidden
  47876. * Back Compat
  47877. **/
  47878. onended: () => any;
  47879. /**
  47880. * Gets or sets an object used to store user defined information for the sound.
  47881. */
  47882. metadata: any;
  47883. /**
  47884. * Observable event when the current playing sound finishes.
  47885. */
  47886. onEndedObservable: Observable<Sound>;
  47887. /**
  47888. * Gets the current time for the sound.
  47889. */
  47890. get currentTime(): number;
  47891. private _panningModel;
  47892. private _playbackRate;
  47893. private _streaming;
  47894. private _startTime;
  47895. private _startOffset;
  47896. private _position;
  47897. /** @hidden */
  47898. _positionInEmitterSpace: boolean;
  47899. private _localDirection;
  47900. private _volume;
  47901. private _isReadyToPlay;
  47902. private _isDirectional;
  47903. private _readyToPlayCallback;
  47904. private _audioBuffer;
  47905. private _soundSource;
  47906. private _streamingSource;
  47907. private _soundPanner;
  47908. private _soundGain;
  47909. private _inputAudioNode;
  47910. private _outputAudioNode;
  47911. private _coneInnerAngle;
  47912. private _coneOuterAngle;
  47913. private _coneOuterGain;
  47914. private _scene;
  47915. private _connectedTransformNode;
  47916. private _customAttenuationFunction;
  47917. private _registerFunc;
  47918. private _isOutputConnected;
  47919. private _htmlAudioElement;
  47920. private _urlType;
  47921. private _length?;
  47922. private _offset?;
  47923. /** @hidden */
  47924. static _SceneComponentInitialization: (scene: Scene) => void;
  47925. /**
  47926. * Create a sound and attach it to a scene
  47927. * @param name Name of your sound
  47928. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  47929. * @param scene defines the scene the sound belongs to
  47930. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  47931. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  47932. */
  47933. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  47934. /**
  47935. * Release the sound and its associated resources
  47936. */
  47937. dispose(): void;
  47938. /**
  47939. * Gets if the sounds is ready to be played or not.
  47940. * @returns true if ready, otherwise false
  47941. */
  47942. isReady(): boolean;
  47943. /**
  47944. * Get the current class name.
  47945. * @returns current class name
  47946. */
  47947. getClassName(): string;
  47948. private _soundLoaded;
  47949. /**
  47950. * Sets the data of the sound from an audiobuffer
  47951. * @param audioBuffer The audioBuffer containing the data
  47952. */
  47953. setAudioBuffer(audioBuffer: AudioBuffer): void;
  47954. /**
  47955. * Updates the current sounds options such as maxdistance, loop...
  47956. * @param options A JSON object containing values named as the object properties
  47957. */
  47958. updateOptions(options: ISoundOptions): void;
  47959. private _createSpatialParameters;
  47960. private _updateSpatialParameters;
  47961. /**
  47962. * Switch the panning model to HRTF:
  47963. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  47964. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47965. */
  47966. switchPanningModelToHRTF(): void;
  47967. /**
  47968. * Switch the panning model to Equal Power:
  47969. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  47970. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47971. */
  47972. switchPanningModelToEqualPower(): void;
  47973. private _switchPanningModel;
  47974. /**
  47975. * Connect this sound to a sound track audio node like gain...
  47976. * @param soundTrackAudioNode the sound track audio node to connect to
  47977. */
  47978. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  47979. /**
  47980. * Transform this sound into a directional source
  47981. * @param coneInnerAngle Size of the inner cone in degree
  47982. * @param coneOuterAngle Size of the outer cone in degree
  47983. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  47984. */
  47985. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  47986. /**
  47987. * Gets or sets the inner angle for the directional cone.
  47988. */
  47989. get directionalConeInnerAngle(): number;
  47990. /**
  47991. * Gets or sets the inner angle for the directional cone.
  47992. */
  47993. set directionalConeInnerAngle(value: number);
  47994. /**
  47995. * Gets or sets the outer angle for the directional cone.
  47996. */
  47997. get directionalConeOuterAngle(): number;
  47998. /**
  47999. * Gets or sets the outer angle for the directional cone.
  48000. */
  48001. set directionalConeOuterAngle(value: number);
  48002. /**
  48003. * Sets the position of the emitter if spatial sound is enabled
  48004. * @param newPosition Defines the new posisiton
  48005. */
  48006. setPosition(newPosition: Vector3): void;
  48007. /**
  48008. * Sets the local direction of the emitter if spatial sound is enabled
  48009. * @param newLocalDirection Defines the new local direction
  48010. */
  48011. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48012. private _updateDirection;
  48013. /** @hidden */
  48014. updateDistanceFromListener(): void;
  48015. /**
  48016. * Sets a new custom attenuation function for the sound.
  48017. * @param callback Defines the function used for the attenuation
  48018. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48019. */
  48020. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48021. /**
  48022. * Play the sound
  48023. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48024. * @param offset (optional) Start the sound at a specific time in seconds
  48025. * @param length (optional) Sound duration (in seconds)
  48026. */
  48027. play(time?: number, offset?: number, length?: number): void;
  48028. private _onended;
  48029. /**
  48030. * Stop the sound
  48031. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48032. */
  48033. stop(time?: number): void;
  48034. /**
  48035. * Put the sound in pause
  48036. */
  48037. pause(): void;
  48038. /**
  48039. * Sets a dedicated volume for this sounds
  48040. * @param newVolume Define the new volume of the sound
  48041. * @param time Define time for gradual change to new volume
  48042. */
  48043. setVolume(newVolume: number, time?: number): void;
  48044. /**
  48045. * Set the sound play back rate
  48046. * @param newPlaybackRate Define the playback rate the sound should be played at
  48047. */
  48048. setPlaybackRate(newPlaybackRate: number): void;
  48049. /**
  48050. * Gets the volume of the sound.
  48051. * @returns the volume of the sound
  48052. */
  48053. getVolume(): number;
  48054. /**
  48055. * Attach the sound to a dedicated mesh
  48056. * @param transformNode The transform node to connect the sound with
  48057. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48058. */
  48059. attachToMesh(transformNode: TransformNode): void;
  48060. /**
  48061. * Detach the sound from the previously attached mesh
  48062. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48063. */
  48064. detachFromMesh(): void;
  48065. private _onRegisterAfterWorldMatrixUpdate;
  48066. /**
  48067. * Clone the current sound in the scene.
  48068. * @returns the new sound clone
  48069. */
  48070. clone(): Nullable<Sound>;
  48071. /**
  48072. * Gets the current underlying audio buffer containing the data
  48073. * @returns the audio buffer
  48074. */
  48075. getAudioBuffer(): Nullable<AudioBuffer>;
  48076. /**
  48077. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48078. * @returns the source node
  48079. */
  48080. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48081. /**
  48082. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48083. * @returns the gain node
  48084. */
  48085. getSoundGain(): Nullable<GainNode>;
  48086. /**
  48087. * Serializes the Sound in a JSON representation
  48088. * @returns the JSON representation of the sound
  48089. */
  48090. serialize(): any;
  48091. /**
  48092. * Parse a JSON representation of a sound to innstantiate in a given scene
  48093. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48094. * @param scene Define the scene the new parsed sound should be created in
  48095. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48096. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  48097. * @returns the newly parsed sound
  48098. */
  48099. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48100. }
  48101. }
  48102. declare module BABYLON {
  48103. /**
  48104. * This defines an action helpful to play a defined sound on a triggered action.
  48105. */
  48106. export class PlaySoundAction extends Action {
  48107. private _sound;
  48108. /**
  48109. * Instantiate the action
  48110. * @param triggerOptions defines the trigger options
  48111. * @param sound defines the sound to play
  48112. * @param condition defines the trigger related conditions
  48113. */
  48114. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48115. /** @hidden */
  48116. _prepare(): void;
  48117. /**
  48118. * Execute the action and play the sound.
  48119. */
  48120. execute(): void;
  48121. /**
  48122. * Serializes the actions and its related information.
  48123. * @param parent defines the object to serialize in
  48124. * @returns the serialized object
  48125. */
  48126. serialize(parent: any): any;
  48127. }
  48128. /**
  48129. * This defines an action helpful to stop a defined sound on a triggered action.
  48130. */
  48131. export class StopSoundAction extends Action {
  48132. private _sound;
  48133. /**
  48134. * Instantiate the action
  48135. * @param triggerOptions defines the trigger options
  48136. * @param sound defines the sound to stop
  48137. * @param condition defines the trigger related conditions
  48138. */
  48139. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48140. /** @hidden */
  48141. _prepare(): void;
  48142. /**
  48143. * Execute the action and stop the sound.
  48144. */
  48145. execute(): void;
  48146. /**
  48147. * Serializes the actions and its related information.
  48148. * @param parent defines the object to serialize in
  48149. * @returns the serialized object
  48150. */
  48151. serialize(parent: any): any;
  48152. }
  48153. }
  48154. declare module BABYLON {
  48155. /**
  48156. * This defines an action responsible to change the value of a property
  48157. * by interpolating between its current value and the newly set one once triggered.
  48158. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48159. */
  48160. export class InterpolateValueAction extends Action {
  48161. /**
  48162. * Defines the path of the property where the value should be interpolated
  48163. */
  48164. propertyPath: string;
  48165. /**
  48166. * Defines the target value at the end of the interpolation.
  48167. */
  48168. value: any;
  48169. /**
  48170. * Defines the time it will take for the property to interpolate to the value.
  48171. */
  48172. duration: number;
  48173. /**
  48174. * Defines if the other scene animations should be stopped when the action has been triggered
  48175. */
  48176. stopOtherAnimations?: boolean;
  48177. /**
  48178. * Defines a callback raised once the interpolation animation has been done.
  48179. */
  48180. onInterpolationDone?: () => void;
  48181. /**
  48182. * Observable triggered once the interpolation animation has been done.
  48183. */
  48184. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48185. private _target;
  48186. private _effectiveTarget;
  48187. private _property;
  48188. /**
  48189. * Instantiate the action
  48190. * @param triggerOptions defines the trigger options
  48191. * @param target defines the object containing the value to interpolate
  48192. * @param propertyPath defines the path to the property in the target object
  48193. * @param value defines the target value at the end of the interpolation
  48194. * @param duration deines the time it will take for the property to interpolate to the value.
  48195. * @param condition defines the trigger related conditions
  48196. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48197. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48198. */
  48199. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48200. /** @hidden */
  48201. _prepare(): void;
  48202. /**
  48203. * Execute the action starts the value interpolation.
  48204. */
  48205. execute(): void;
  48206. /**
  48207. * Serializes the actions and its related information.
  48208. * @param parent defines the object to serialize in
  48209. * @returns the serialized object
  48210. */
  48211. serialize(parent: any): any;
  48212. }
  48213. }
  48214. declare module BABYLON {
  48215. /**
  48216. * This represents the default audio engine used in babylon.
  48217. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48218. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48219. */
  48220. export class AudioEngine implements IAudioEngine {
  48221. private _audioContext;
  48222. private _audioContextInitialized;
  48223. private _muteButton;
  48224. private _hostElement;
  48225. /**
  48226. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48227. */
  48228. canUseWebAudio: boolean;
  48229. /**
  48230. * The master gain node defines the global audio volume of your audio engine.
  48231. */
  48232. masterGain: GainNode;
  48233. /**
  48234. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48235. * @ignoreNaming
  48236. */
  48237. WarnedWebAudioUnsupported: boolean;
  48238. /**
  48239. * Gets whether or not mp3 are supported by your browser.
  48240. */
  48241. isMP3supported: boolean;
  48242. /**
  48243. * Gets whether or not ogg are supported by your browser.
  48244. */
  48245. isOGGsupported: boolean;
  48246. /**
  48247. * Gets whether audio has been unlocked on the device.
  48248. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48249. * a user interaction has happened.
  48250. */
  48251. unlocked: boolean;
  48252. /**
  48253. * Defines if the audio engine relies on a custom unlocked button.
  48254. * In this case, the embedded button will not be displayed.
  48255. */
  48256. useCustomUnlockedButton: boolean;
  48257. /**
  48258. * Event raised when audio has been unlocked on the browser.
  48259. */
  48260. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48261. /**
  48262. * Event raised when audio has been locked on the browser.
  48263. */
  48264. onAudioLockedObservable: Observable<IAudioEngine>;
  48265. /**
  48266. * Gets the current AudioContext if available.
  48267. */
  48268. get audioContext(): Nullable<AudioContext>;
  48269. private _connectedAnalyser;
  48270. /**
  48271. * Instantiates a new audio engine.
  48272. *
  48273. * There should be only one per page as some browsers restrict the number
  48274. * of audio contexts you can create.
  48275. * @param hostElement defines the host element where to display the mute icon if necessary
  48276. */
  48277. constructor(hostElement?: Nullable<HTMLElement>);
  48278. /**
  48279. * Flags the audio engine in Locked state.
  48280. * This happens due to new browser policies preventing audio to autoplay.
  48281. */
  48282. lock(): void;
  48283. /**
  48284. * Unlocks the audio engine once a user action has been done on the dom.
  48285. * This is helpful to resume play once browser policies have been satisfied.
  48286. */
  48287. unlock(): void;
  48288. private _resumeAudioContext;
  48289. private _initializeAudioContext;
  48290. private _tryToRun;
  48291. private _triggerRunningState;
  48292. private _triggerSuspendedState;
  48293. private _displayMuteButton;
  48294. private _moveButtonToTopLeft;
  48295. private _onResize;
  48296. private _hideMuteButton;
  48297. /**
  48298. * Destroy and release the resources associated with the audio ccontext.
  48299. */
  48300. dispose(): void;
  48301. /**
  48302. * Gets the global volume sets on the master gain.
  48303. * @returns the global volume if set or -1 otherwise
  48304. */
  48305. getGlobalVolume(): number;
  48306. /**
  48307. * Sets the global volume of your experience (sets on the master gain).
  48308. * @param newVolume Defines the new global volume of the application
  48309. */
  48310. setGlobalVolume(newVolume: number): void;
  48311. /**
  48312. * Connect the audio engine to an audio analyser allowing some amazing
  48313. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48314. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48315. * @param analyser The analyser to connect to the engine
  48316. */
  48317. connectToAnalyser(analyser: Analyser): void;
  48318. }
  48319. }
  48320. declare module BABYLON {
  48321. /**
  48322. * Options allowed during the creation of a sound track.
  48323. */
  48324. export interface ISoundTrackOptions {
  48325. /**
  48326. * The volume the sound track should take during creation
  48327. */
  48328. volume?: number;
  48329. /**
  48330. * Define if the sound track is the main sound track of the scene
  48331. */
  48332. mainTrack?: boolean;
  48333. }
  48334. /**
  48335. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  48336. * It will be also used in a future release to apply effects on a specific track.
  48337. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48338. */
  48339. export class SoundTrack {
  48340. /**
  48341. * The unique identifier of the sound track in the scene.
  48342. */
  48343. id: number;
  48344. /**
  48345. * The list of sounds included in the sound track.
  48346. */
  48347. soundCollection: Array<Sound>;
  48348. private _outputAudioNode;
  48349. private _scene;
  48350. private _connectedAnalyser;
  48351. private _options;
  48352. private _isInitialized;
  48353. /**
  48354. * Creates a new sound track.
  48355. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48356. * @param scene Define the scene the sound track belongs to
  48357. * @param options
  48358. */
  48359. constructor(scene: Scene, options?: ISoundTrackOptions);
  48360. private _initializeSoundTrackAudioGraph;
  48361. /**
  48362. * Release the sound track and its associated resources
  48363. */
  48364. dispose(): void;
  48365. /**
  48366. * Adds a sound to this sound track
  48367. * @param sound define the cound to add
  48368. * @ignoreNaming
  48369. */
  48370. addSound(sound: Sound): void;
  48371. /**
  48372. * Removes a sound to this sound track
  48373. * @param sound define the cound to remove
  48374. * @ignoreNaming
  48375. */
  48376. removeSound(sound: Sound): void;
  48377. /**
  48378. * Set a global volume for the full sound track.
  48379. * @param newVolume Define the new volume of the sound track
  48380. */
  48381. setVolume(newVolume: number): void;
  48382. /**
  48383. * Switch the panning model to HRTF:
  48384. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48385. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48386. */
  48387. switchPanningModelToHRTF(): void;
  48388. /**
  48389. * Switch the panning model to Equal Power:
  48390. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48391. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48392. */
  48393. switchPanningModelToEqualPower(): void;
  48394. /**
  48395. * Connect the sound track to an audio analyser allowing some amazing
  48396. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48397. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48398. * @param analyser The analyser to connect to the engine
  48399. */
  48400. connectToAnalyser(analyser: Analyser): void;
  48401. }
  48402. }
  48403. declare module BABYLON {
  48404. interface AbstractScene {
  48405. /**
  48406. * The list of sounds used in the scene.
  48407. */
  48408. sounds: Nullable<Array<Sound>>;
  48409. }
  48410. interface Scene {
  48411. /**
  48412. * @hidden
  48413. * Backing field
  48414. */
  48415. _mainSoundTrack: SoundTrack;
  48416. /**
  48417. * The main sound track played by the scene.
  48418. * It cotains your primary collection of sounds.
  48419. */
  48420. mainSoundTrack: SoundTrack;
  48421. /**
  48422. * The list of sound tracks added to the scene
  48423. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48424. */
  48425. soundTracks: Nullable<Array<SoundTrack>>;
  48426. /**
  48427. * Gets a sound using a given name
  48428. * @param name defines the name to search for
  48429. * @return the found sound or null if not found at all.
  48430. */
  48431. getSoundByName(name: string): Nullable<Sound>;
  48432. /**
  48433. * Gets or sets if audio support is enabled
  48434. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48435. */
  48436. audioEnabled: boolean;
  48437. /**
  48438. * Gets or sets if audio will be output to headphones
  48439. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48440. */
  48441. headphone: boolean;
  48442. /**
  48443. * Gets or sets custom audio listener position provider
  48444. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48445. */
  48446. audioListenerPositionProvider: Nullable<() => Vector3>;
  48447. /**
  48448. * Gets or sets a refresh rate when using 3D audio positioning
  48449. */
  48450. audioPositioningRefreshRate: number;
  48451. }
  48452. /**
  48453. * Defines the sound scene component responsible to manage any sounds
  48454. * in a given scene.
  48455. */
  48456. export class AudioSceneComponent implements ISceneSerializableComponent {
  48457. private static _CameraDirectionLH;
  48458. private static _CameraDirectionRH;
  48459. /**
  48460. * The component name helpfull to identify the component in the list of scene components.
  48461. */
  48462. readonly name: string;
  48463. /**
  48464. * The scene the component belongs to.
  48465. */
  48466. scene: Scene;
  48467. private _audioEnabled;
  48468. /**
  48469. * Gets whether audio is enabled or not.
  48470. * Please use related enable/disable method to switch state.
  48471. */
  48472. get audioEnabled(): boolean;
  48473. private _headphone;
  48474. /**
  48475. * Gets whether audio is outputing to headphone or not.
  48476. * Please use the according Switch methods to change output.
  48477. */
  48478. get headphone(): boolean;
  48479. /**
  48480. * Gets or sets a refresh rate when using 3D audio positioning
  48481. */
  48482. audioPositioningRefreshRate: number;
  48483. private _audioListenerPositionProvider;
  48484. /**
  48485. * Gets the current audio listener position provider
  48486. */
  48487. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  48488. /**
  48489. * Sets a custom listener position for all sounds in the scene
  48490. * By default, this is the position of the first active camera
  48491. */
  48492. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  48493. /**
  48494. * Creates a new instance of the component for the given scene
  48495. * @param scene Defines the scene to register the component in
  48496. */
  48497. constructor(scene: Scene);
  48498. /**
  48499. * Registers the component in a given scene
  48500. */
  48501. register(): void;
  48502. /**
  48503. * Rebuilds the elements related to this component in case of
  48504. * context lost for instance.
  48505. */
  48506. rebuild(): void;
  48507. /**
  48508. * Serializes the component data to the specified json object
  48509. * @param serializationObject The object to serialize to
  48510. */
  48511. serialize(serializationObject: any): void;
  48512. /**
  48513. * Adds all the elements from the container to the scene
  48514. * @param container the container holding the elements
  48515. */
  48516. addFromContainer(container: AbstractScene): void;
  48517. /**
  48518. * Removes all the elements in the container from the scene
  48519. * @param container contains the elements to remove
  48520. * @param dispose if the removed element should be disposed (default: false)
  48521. */
  48522. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48523. /**
  48524. * Disposes the component and the associated ressources.
  48525. */
  48526. dispose(): void;
  48527. /**
  48528. * Disables audio in the associated scene.
  48529. */
  48530. disableAudio(): void;
  48531. /**
  48532. * Enables audio in the associated scene.
  48533. */
  48534. enableAudio(): void;
  48535. /**
  48536. * Switch audio to headphone output.
  48537. */
  48538. switchAudioModeForHeadphones(): void;
  48539. /**
  48540. * Switch audio to normal speakers.
  48541. */
  48542. switchAudioModeForNormalSpeakers(): void;
  48543. private _cachedCameraDirection;
  48544. private _cachedCameraPosition;
  48545. private _lastCheck;
  48546. private _afterRender;
  48547. }
  48548. }
  48549. declare module BABYLON {
  48550. /**
  48551. * Wraps one or more Sound objects and selects one with random weight for playback.
  48552. */
  48553. export class WeightedSound {
  48554. /** When true a Sound will be selected and played when the current playing Sound completes. */
  48555. loop: boolean;
  48556. private _coneInnerAngle;
  48557. private _coneOuterAngle;
  48558. private _volume;
  48559. /** A Sound is currently playing. */
  48560. isPlaying: boolean;
  48561. /** A Sound is currently paused. */
  48562. isPaused: boolean;
  48563. private _sounds;
  48564. private _weights;
  48565. private _currentIndex?;
  48566. /**
  48567. * Creates a new WeightedSound from the list of sounds given.
  48568. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  48569. * @param sounds Array of Sounds that will be selected from.
  48570. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  48571. */
  48572. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  48573. /**
  48574. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  48575. */
  48576. get directionalConeInnerAngle(): number;
  48577. /**
  48578. * The size of cone in degress for a directional sound in which there will be no attenuation.
  48579. */
  48580. set directionalConeInnerAngle(value: number);
  48581. /**
  48582. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48583. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48584. */
  48585. get directionalConeOuterAngle(): number;
  48586. /**
  48587. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48588. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48589. */
  48590. set directionalConeOuterAngle(value: number);
  48591. /**
  48592. * Playback volume.
  48593. */
  48594. get volume(): number;
  48595. /**
  48596. * Playback volume.
  48597. */
  48598. set volume(value: number);
  48599. private _onended;
  48600. /**
  48601. * Suspend playback
  48602. */
  48603. pause(): void;
  48604. /**
  48605. * Stop playback
  48606. */
  48607. stop(): void;
  48608. /**
  48609. * Start playback.
  48610. * @param startOffset Position the clip head at a specific time in seconds.
  48611. */
  48612. play(startOffset?: number): void;
  48613. }
  48614. }
  48615. declare module BABYLON {
  48616. /**
  48617. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  48618. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48619. */
  48620. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  48621. /**
  48622. * Gets the name of the behavior.
  48623. */
  48624. get name(): string;
  48625. /**
  48626. * The easing function used by animations
  48627. */
  48628. static EasingFunction: BackEase;
  48629. /**
  48630. * The easing mode used by animations
  48631. */
  48632. static EasingMode: number;
  48633. /**
  48634. * The duration of the animation, in milliseconds
  48635. */
  48636. transitionDuration: number;
  48637. /**
  48638. * Length of the distance animated by the transition when lower radius is reached
  48639. */
  48640. lowerRadiusTransitionRange: number;
  48641. /**
  48642. * Length of the distance animated by the transition when upper radius is reached
  48643. */
  48644. upperRadiusTransitionRange: number;
  48645. private _autoTransitionRange;
  48646. /**
  48647. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48648. */
  48649. get autoTransitionRange(): boolean;
  48650. /**
  48651. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48652. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  48653. */
  48654. set autoTransitionRange(value: boolean);
  48655. private _attachedCamera;
  48656. private _onAfterCheckInputsObserver;
  48657. private _onMeshTargetChangedObserver;
  48658. /**
  48659. * Initializes the behavior.
  48660. */
  48661. init(): void;
  48662. /**
  48663. * Attaches the behavior to its arc rotate camera.
  48664. * @param camera Defines the camera to attach the behavior to
  48665. */
  48666. attach(camera: ArcRotateCamera): void;
  48667. /**
  48668. * Detaches the behavior from its current arc rotate camera.
  48669. */
  48670. detach(): void;
  48671. private _radiusIsAnimating;
  48672. private _radiusBounceTransition;
  48673. private _animatables;
  48674. private _cachedWheelPrecision;
  48675. /**
  48676. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  48677. * @param radiusLimit The limit to check against.
  48678. * @return Bool to indicate if at limit.
  48679. */
  48680. private _isRadiusAtLimit;
  48681. /**
  48682. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  48683. * @param radiusDelta The delta by which to animate to. Can be negative.
  48684. */
  48685. private _applyBoundRadiusAnimation;
  48686. /**
  48687. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  48688. */
  48689. protected _clearAnimationLocks(): void;
  48690. /**
  48691. * Stops and removes all animations that have been applied to the camera
  48692. */
  48693. stopAllAnimations(): void;
  48694. }
  48695. }
  48696. declare module BABYLON {
  48697. /**
  48698. * 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.
  48699. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48700. */
  48701. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  48702. /**
  48703. * Gets the name of the behavior.
  48704. */
  48705. get name(): string;
  48706. private _mode;
  48707. private _radiusScale;
  48708. private _positionScale;
  48709. private _defaultElevation;
  48710. private _elevationReturnTime;
  48711. private _elevationReturnWaitTime;
  48712. private _zoomStopsAnimation;
  48713. private _framingTime;
  48714. /**
  48715. * The easing function used by animations
  48716. */
  48717. static EasingFunction: ExponentialEase;
  48718. /**
  48719. * The easing mode used by animations
  48720. */
  48721. static EasingMode: number;
  48722. /**
  48723. * Sets the current mode used by the behavior
  48724. */
  48725. set mode(mode: number);
  48726. /**
  48727. * Gets current mode used by the behavior.
  48728. */
  48729. get mode(): number;
  48730. /**
  48731. * Sets the scale applied to the radius (1 by default)
  48732. */
  48733. set radiusScale(radius: number);
  48734. /**
  48735. * Gets the scale applied to the radius
  48736. */
  48737. get radiusScale(): number;
  48738. /**
  48739. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48740. */
  48741. set positionScale(scale: number);
  48742. /**
  48743. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48744. */
  48745. get positionScale(): number;
  48746. /**
  48747. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48748. * behaviour is triggered, in radians.
  48749. */
  48750. set defaultElevation(elevation: number);
  48751. /**
  48752. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48753. * behaviour is triggered, in radians.
  48754. */
  48755. get defaultElevation(): number;
  48756. /**
  48757. * Sets the time (in milliseconds) taken to return to the default beta position.
  48758. * Negative value indicates camera should not return to default.
  48759. */
  48760. set elevationReturnTime(speed: number);
  48761. /**
  48762. * Gets the time (in milliseconds) taken to return to the default beta position.
  48763. * Negative value indicates camera should not return to default.
  48764. */
  48765. get elevationReturnTime(): number;
  48766. /**
  48767. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48768. */
  48769. set elevationReturnWaitTime(time: number);
  48770. /**
  48771. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48772. */
  48773. get elevationReturnWaitTime(): number;
  48774. /**
  48775. * Sets the flag that indicates if user zooming should stop animation.
  48776. */
  48777. set zoomStopsAnimation(flag: boolean);
  48778. /**
  48779. * Gets the flag that indicates if user zooming should stop animation.
  48780. */
  48781. get zoomStopsAnimation(): boolean;
  48782. /**
  48783. * Sets the transition time when framing the mesh, in milliseconds
  48784. */
  48785. set framingTime(time: number);
  48786. /**
  48787. * Gets the transition time when framing the mesh, in milliseconds
  48788. */
  48789. get framingTime(): number;
  48790. /**
  48791. * Define if the behavior should automatically change the configured
  48792. * camera limits and sensibilities.
  48793. */
  48794. autoCorrectCameraLimitsAndSensibility: boolean;
  48795. private _onPrePointerObservableObserver;
  48796. private _onAfterCheckInputsObserver;
  48797. private _onMeshTargetChangedObserver;
  48798. private _attachedCamera;
  48799. private _isPointerDown;
  48800. private _lastInteractionTime;
  48801. /**
  48802. * Initializes the behavior.
  48803. */
  48804. init(): void;
  48805. /**
  48806. * Attaches the behavior to its arc rotate camera.
  48807. * @param camera Defines the camera to attach the behavior to
  48808. */
  48809. attach(camera: ArcRotateCamera): void;
  48810. /**
  48811. * Detaches the behavior from its current arc rotate camera.
  48812. */
  48813. detach(): void;
  48814. private _animatables;
  48815. private _betaIsAnimating;
  48816. private _betaTransition;
  48817. private _radiusTransition;
  48818. private _vectorTransition;
  48819. /**
  48820. * Targets the given mesh and updates zoom level accordingly.
  48821. * @param mesh The mesh to target.
  48822. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48823. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48824. */
  48825. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48826. /**
  48827. * Targets the given mesh with its children and updates zoom level accordingly.
  48828. * @param mesh The mesh to target.
  48829. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48830. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48831. */
  48832. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48833. /**
  48834. * Targets the given meshes with their children and updates zoom level accordingly.
  48835. * @param meshes The mesh to target.
  48836. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48837. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48838. */
  48839. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48840. /**
  48841. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  48842. * @param minimumWorld Determines the smaller position of the bounding box extend
  48843. * @param maximumWorld Determines the bigger position of the bounding box extend
  48844. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48845. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48846. */
  48847. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48848. /**
  48849. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  48850. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  48851. * frustum width.
  48852. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  48853. * to fully enclose the mesh in the viewing frustum.
  48854. */
  48855. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  48856. /**
  48857. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  48858. * is automatically returned to its default position (expected to be above ground plane).
  48859. */
  48860. private _maintainCameraAboveGround;
  48861. /**
  48862. * Returns the frustum slope based on the canvas ratio and camera FOV
  48863. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  48864. */
  48865. private _getFrustumSlope;
  48866. /**
  48867. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  48868. */
  48869. private _clearAnimationLocks;
  48870. /**
  48871. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48872. */
  48873. private _applyUserInteraction;
  48874. /**
  48875. * Stops and removes all animations that have been applied to the camera
  48876. */
  48877. stopAllAnimations(): void;
  48878. /**
  48879. * Gets a value indicating if the user is moving the camera
  48880. */
  48881. get isUserIsMoving(): boolean;
  48882. /**
  48883. * The camera can move all the way towards the mesh.
  48884. */
  48885. static IgnoreBoundsSizeMode: number;
  48886. /**
  48887. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  48888. */
  48889. static FitFrustumSidesMode: number;
  48890. }
  48891. }
  48892. declare module BABYLON {
  48893. /**
  48894. * Base class for Camera Pointer Inputs.
  48895. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  48896. * for example usage.
  48897. */
  48898. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  48899. /**
  48900. * Defines the camera the input is attached to.
  48901. */
  48902. abstract camera: Camera;
  48903. /**
  48904. * Whether keyboard modifier keys are pressed at time of last mouse event.
  48905. */
  48906. protected _altKey: boolean;
  48907. protected _ctrlKey: boolean;
  48908. protected _metaKey: boolean;
  48909. protected _shiftKey: boolean;
  48910. /**
  48911. * Which mouse buttons were pressed at time of last mouse event.
  48912. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  48913. */
  48914. protected _buttonsPressed: number;
  48915. /**
  48916. * Defines the buttons associated with the input to handle camera move.
  48917. */
  48918. buttons: number[];
  48919. /**
  48920. * Attach the input controls to a specific dom element to get the input from.
  48921. * @param element Defines the element the controls should be listened from
  48922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48923. */
  48924. attachControl(noPreventDefault?: boolean): void;
  48925. /**
  48926. * Detach the current controls from the specified dom element.
  48927. */
  48928. detachControl(): void;
  48929. /**
  48930. * Gets the class name of the current input.
  48931. * @returns the class name
  48932. */
  48933. getClassName(): string;
  48934. /**
  48935. * Get the friendly name associated with the input class.
  48936. * @returns the input friendly name
  48937. */
  48938. getSimpleName(): string;
  48939. /**
  48940. * Called on pointer POINTERDOUBLETAP event.
  48941. * Override this method to provide functionality on POINTERDOUBLETAP event.
  48942. */
  48943. protected onDoubleTap(type: string): void;
  48944. /**
  48945. * Called on pointer POINTERMOVE event if only a single touch is active.
  48946. * Override this method to provide functionality.
  48947. */
  48948. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48949. /**
  48950. * Called on pointer POINTERMOVE event if multiple touches are active.
  48951. * Override this method to provide functionality.
  48952. */
  48953. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48954. /**
  48955. * Called on JS contextmenu event.
  48956. * Override this method to provide functionality.
  48957. */
  48958. protected onContextMenu(evt: PointerEvent): void;
  48959. /**
  48960. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  48961. * press.
  48962. * Override this method to provide functionality.
  48963. */
  48964. protected onButtonDown(evt: PointerEvent): void;
  48965. /**
  48966. * Called each time a new POINTERUP event occurs. Ie, for each button
  48967. * release.
  48968. * Override this method to provide functionality.
  48969. */
  48970. protected onButtonUp(evt: PointerEvent): void;
  48971. /**
  48972. * Called when window becomes inactive.
  48973. * Override this method to provide functionality.
  48974. */
  48975. protected onLostFocus(): void;
  48976. private _pointerInput;
  48977. private _observer;
  48978. private _onLostFocus;
  48979. private pointA;
  48980. private pointB;
  48981. }
  48982. }
  48983. declare module BABYLON {
  48984. /**
  48985. * Manage the pointers inputs to control an arc rotate camera.
  48986. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48987. */
  48988. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  48989. /**
  48990. * Defines the camera the input is attached to.
  48991. */
  48992. camera: ArcRotateCamera;
  48993. /**
  48994. * Gets the class name of the current input.
  48995. * @returns the class name
  48996. */
  48997. getClassName(): string;
  48998. /**
  48999. * Defines the buttons associated with the input to handle camera move.
  49000. */
  49001. buttons: number[];
  49002. /**
  49003. * Defines the pointer angular sensibility along the X axis or how fast is
  49004. * the camera rotating.
  49005. */
  49006. angularSensibilityX: number;
  49007. /**
  49008. * Defines the pointer angular sensibility along the Y axis or how fast is
  49009. * the camera rotating.
  49010. */
  49011. angularSensibilityY: number;
  49012. /**
  49013. * Defines the pointer pinch precision or how fast is the camera zooming.
  49014. */
  49015. pinchPrecision: number;
  49016. /**
  49017. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49018. * from 0.
  49019. * It defines the percentage of current camera.radius to use as delta when
  49020. * pinch zoom is used.
  49021. */
  49022. pinchDeltaPercentage: number;
  49023. /**
  49024. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49025. * that any object in the plane at the camera's target point will scale
  49026. * perfectly with finger motion.
  49027. * Overrides pinchDeltaPercentage and pinchPrecision.
  49028. */
  49029. useNaturalPinchZoom: boolean;
  49030. /**
  49031. * Defines the pointer panning sensibility or how fast is the camera moving.
  49032. */
  49033. panningSensibility: number;
  49034. /**
  49035. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49036. */
  49037. multiTouchPanning: boolean;
  49038. /**
  49039. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49040. * zoom (pinch) through multitouch.
  49041. */
  49042. multiTouchPanAndZoom: boolean;
  49043. /**
  49044. * Revers pinch action direction.
  49045. */
  49046. pinchInwards: boolean;
  49047. private _isPanClick;
  49048. private _twoFingerActivityCount;
  49049. private _isPinching;
  49050. /**
  49051. * Called on pointer POINTERMOVE event if only a single touch is active.
  49052. */
  49053. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49054. /**
  49055. * Called on pointer POINTERDOUBLETAP event.
  49056. */
  49057. protected onDoubleTap(type: string): void;
  49058. /**
  49059. * Called on pointer POINTERMOVE event if multiple touches are active.
  49060. */
  49061. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49062. /**
  49063. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49064. * press.
  49065. */
  49066. protected onButtonDown(evt: PointerEvent): void;
  49067. /**
  49068. * Called each time a new POINTERUP event occurs. Ie, for each button
  49069. * release.
  49070. */
  49071. protected onButtonUp(evt: PointerEvent): void;
  49072. /**
  49073. * Called when window becomes inactive.
  49074. */
  49075. protected onLostFocus(): void;
  49076. }
  49077. }
  49078. declare module BABYLON {
  49079. /**
  49080. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49081. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49082. */
  49083. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49084. /**
  49085. * Defines the camera the input is attached to.
  49086. */
  49087. camera: ArcRotateCamera;
  49088. /**
  49089. * Defines the list of key codes associated with the up action (increase alpha)
  49090. */
  49091. keysUp: number[];
  49092. /**
  49093. * Defines the list of key codes associated with the down action (decrease alpha)
  49094. */
  49095. keysDown: number[];
  49096. /**
  49097. * Defines the list of key codes associated with the left action (increase beta)
  49098. */
  49099. keysLeft: number[];
  49100. /**
  49101. * Defines the list of key codes associated with the right action (decrease beta)
  49102. */
  49103. keysRight: number[];
  49104. /**
  49105. * Defines the list of key codes associated with the reset action.
  49106. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49107. */
  49108. keysReset: number[];
  49109. /**
  49110. * Defines the panning sensibility of the inputs.
  49111. * (How fast is the camera panning)
  49112. */
  49113. panningSensibility: number;
  49114. /**
  49115. * Defines the zooming sensibility of the inputs.
  49116. * (How fast is the camera zooming)
  49117. */
  49118. zoomingSensibility: number;
  49119. /**
  49120. * Defines whether maintaining the alt key down switch the movement mode from
  49121. * orientation to zoom.
  49122. */
  49123. useAltToZoom: boolean;
  49124. /**
  49125. * Rotation speed of the camera
  49126. */
  49127. angularSpeed: number;
  49128. private _keys;
  49129. private _ctrlPressed;
  49130. private _altPressed;
  49131. private _onCanvasBlurObserver;
  49132. private _onKeyboardObserver;
  49133. private _engine;
  49134. private _scene;
  49135. /**
  49136. * Attach the input controls to a specific dom element to get the input from.
  49137. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49138. */
  49139. attachControl(noPreventDefault?: boolean): void;
  49140. /**
  49141. * Detach the current controls from the specified dom element.
  49142. */
  49143. detachControl(): void;
  49144. /**
  49145. * Update the current camera state depending on the inputs that have been used this frame.
  49146. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49147. */
  49148. checkInputs(): void;
  49149. /**
  49150. * Gets the class name of the current intput.
  49151. * @returns the class name
  49152. */
  49153. getClassName(): string;
  49154. /**
  49155. * Get the friendly name associated with the input class.
  49156. * @returns the input friendly name
  49157. */
  49158. getSimpleName(): string;
  49159. }
  49160. }
  49161. declare module BABYLON {
  49162. /**
  49163. * Manage the mouse wheel inputs to control an arc rotate camera.
  49164. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49165. */
  49166. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49167. /**
  49168. * Defines the camera the input is attached to.
  49169. */
  49170. camera: ArcRotateCamera;
  49171. /**
  49172. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49173. */
  49174. wheelPrecision: number;
  49175. /**
  49176. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49177. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49178. */
  49179. wheelDeltaPercentage: number;
  49180. private _wheel;
  49181. private _observer;
  49182. private computeDeltaFromMouseWheelLegacyEvent;
  49183. /**
  49184. * Attach the input controls to a specific dom element to get the input from.
  49185. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49186. */
  49187. attachControl(noPreventDefault?: boolean): void;
  49188. /**
  49189. * Detach the current controls from the specified dom element.
  49190. */
  49191. detachControl(): void;
  49192. /**
  49193. * Gets the class name of the current intput.
  49194. * @returns the class name
  49195. */
  49196. getClassName(): string;
  49197. /**
  49198. * Get the friendly name associated with the input class.
  49199. * @returns the input friendly name
  49200. */
  49201. getSimpleName(): string;
  49202. }
  49203. }
  49204. declare module BABYLON {
  49205. /**
  49206. * Default Inputs manager for the ArcRotateCamera.
  49207. * It groups all the default supported inputs for ease of use.
  49208. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49209. */
  49210. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49211. /**
  49212. * Instantiates a new ArcRotateCameraInputsManager.
  49213. * @param camera Defines the camera the inputs belong to
  49214. */
  49215. constructor(camera: ArcRotateCamera);
  49216. /**
  49217. * Add mouse wheel input support to the input manager.
  49218. * @returns the current input manager
  49219. */
  49220. addMouseWheel(): ArcRotateCameraInputsManager;
  49221. /**
  49222. * Add pointers input support to the input manager.
  49223. * @returns the current input manager
  49224. */
  49225. addPointers(): ArcRotateCameraInputsManager;
  49226. /**
  49227. * Add keyboard input support to the input manager.
  49228. * @returns the current input manager
  49229. */
  49230. addKeyboard(): ArcRotateCameraInputsManager;
  49231. }
  49232. }
  49233. declare module BABYLON {
  49234. /**
  49235. * This represents an orbital type of camera.
  49236. *
  49237. * 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.
  49238. * 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.
  49239. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49240. */
  49241. export class ArcRotateCamera extends TargetCamera {
  49242. /**
  49243. * Defines the rotation angle of the camera along the longitudinal axis.
  49244. */
  49245. alpha: number;
  49246. /**
  49247. * Defines the rotation angle of the camera along the latitudinal axis.
  49248. */
  49249. beta: number;
  49250. /**
  49251. * Defines the radius of the camera from it s target point.
  49252. */
  49253. radius: number;
  49254. protected _target: Vector3;
  49255. protected _targetHost: Nullable<AbstractMesh>;
  49256. /**
  49257. * Defines the target point of the camera.
  49258. * The camera looks towards it form the radius distance.
  49259. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49260. */
  49261. get target(): Vector3;
  49262. set target(value: Vector3);
  49263. /**
  49264. * Define the current local position of the camera in the scene
  49265. */
  49266. get position(): Vector3;
  49267. set position(newPosition: Vector3);
  49268. protected _upToYMatrix: Matrix;
  49269. protected _YToUpMatrix: Matrix;
  49270. /**
  49271. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49272. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  49273. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  49274. */
  49275. set upVector(vec: Vector3);
  49276. get upVector(): Vector3;
  49277. /**
  49278. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  49279. */
  49280. setMatUp(): void;
  49281. /**
  49282. * Current inertia value on the longitudinal axis.
  49283. * The bigger this number the longer it will take for the camera to stop.
  49284. */
  49285. inertialAlphaOffset: number;
  49286. /**
  49287. * Current inertia value on the latitudinal axis.
  49288. * The bigger this number the longer it will take for the camera to stop.
  49289. */
  49290. inertialBetaOffset: number;
  49291. /**
  49292. * Current inertia value on the radius axis.
  49293. * The bigger this number the longer it will take for the camera to stop.
  49294. */
  49295. inertialRadiusOffset: number;
  49296. /**
  49297. * Minimum allowed angle on the longitudinal axis.
  49298. * This can help limiting how the Camera is able to move in the scene.
  49299. */
  49300. lowerAlphaLimit: Nullable<number>;
  49301. /**
  49302. * Maximum allowed angle on the longitudinal axis.
  49303. * This can help limiting how the Camera is able to move in the scene.
  49304. */
  49305. upperAlphaLimit: Nullable<number>;
  49306. /**
  49307. * Minimum allowed angle on the latitudinal axis.
  49308. * This can help limiting how the Camera is able to move in the scene.
  49309. */
  49310. lowerBetaLimit: number;
  49311. /**
  49312. * Maximum allowed angle on the latitudinal axis.
  49313. * This can help limiting how the Camera is able to move in the scene.
  49314. */
  49315. upperBetaLimit: number;
  49316. /**
  49317. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  49318. * This can help limiting how the Camera is able to move in the scene.
  49319. */
  49320. lowerRadiusLimit: Nullable<number>;
  49321. /**
  49322. * Maximum allowed distance of the camera to the target (The camera can not get further).
  49323. * This can help limiting how the Camera is able to move in the scene.
  49324. */
  49325. upperRadiusLimit: Nullable<number>;
  49326. /**
  49327. * Defines the current inertia value used during panning of the camera along the X axis.
  49328. */
  49329. inertialPanningX: number;
  49330. /**
  49331. * Defines the current inertia value used during panning of the camera along the Y axis.
  49332. */
  49333. inertialPanningY: number;
  49334. /**
  49335. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  49336. * Basically if your fingers moves away from more than this distance you will be considered
  49337. * in pinch mode.
  49338. */
  49339. pinchToPanMaxDistance: number;
  49340. /**
  49341. * Defines the maximum distance the camera can pan.
  49342. * This could help keeping the cammera always in your scene.
  49343. */
  49344. panningDistanceLimit: Nullable<number>;
  49345. /**
  49346. * Defines the target of the camera before paning.
  49347. */
  49348. panningOriginTarget: Vector3;
  49349. /**
  49350. * Defines the value of the inertia used during panning.
  49351. * 0 would mean stop inertia and one would mean no decelleration at all.
  49352. */
  49353. panningInertia: number;
  49354. /**
  49355. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  49356. */
  49357. get angularSensibilityX(): number;
  49358. set angularSensibilityX(value: number);
  49359. /**
  49360. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  49361. */
  49362. get angularSensibilityY(): number;
  49363. set angularSensibilityY(value: number);
  49364. /**
  49365. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  49366. */
  49367. get pinchPrecision(): number;
  49368. set pinchPrecision(value: number);
  49369. /**
  49370. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  49371. * It will be used instead of pinchDeltaPrecision if different from 0.
  49372. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49373. */
  49374. get pinchDeltaPercentage(): number;
  49375. set pinchDeltaPercentage(value: number);
  49376. /**
  49377. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  49378. * and pinch delta percentage.
  49379. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49380. * that any object in the plane at the camera's target point will scale
  49381. * perfectly with finger motion.
  49382. */
  49383. get useNaturalPinchZoom(): boolean;
  49384. set useNaturalPinchZoom(value: boolean);
  49385. /**
  49386. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  49387. */
  49388. get panningSensibility(): number;
  49389. set panningSensibility(value: number);
  49390. /**
  49391. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  49392. */
  49393. get keysUp(): number[];
  49394. set keysUp(value: number[]);
  49395. /**
  49396. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  49397. */
  49398. get keysDown(): number[];
  49399. set keysDown(value: number[]);
  49400. /**
  49401. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  49402. */
  49403. get keysLeft(): number[];
  49404. set keysLeft(value: number[]);
  49405. /**
  49406. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  49407. */
  49408. get keysRight(): number[];
  49409. set keysRight(value: number[]);
  49410. /**
  49411. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49412. */
  49413. get wheelPrecision(): number;
  49414. set wheelPrecision(value: number);
  49415. /**
  49416. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  49417. * It will be used instead of pinchDeltaPrecision if different from 0.
  49418. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49419. */
  49420. get wheelDeltaPercentage(): number;
  49421. set wheelDeltaPercentage(value: number);
  49422. /**
  49423. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  49424. */
  49425. zoomOnFactor: number;
  49426. /**
  49427. * Defines a screen offset for the camera position.
  49428. */
  49429. targetScreenOffset: Vector2;
  49430. /**
  49431. * Allows the camera to be completely reversed.
  49432. * If false the camera can not arrive upside down.
  49433. */
  49434. allowUpsideDown: boolean;
  49435. /**
  49436. * Define if double tap/click is used to restore the previously saved state of the camera.
  49437. */
  49438. useInputToRestoreState: boolean;
  49439. /** @hidden */
  49440. _viewMatrix: Matrix;
  49441. /** @hidden */
  49442. _useCtrlForPanning: boolean;
  49443. /** @hidden */
  49444. _panningMouseButton: number;
  49445. /**
  49446. * Defines the input associated to the camera.
  49447. */
  49448. inputs: ArcRotateCameraInputsManager;
  49449. /** @hidden */
  49450. _reset: () => void;
  49451. /**
  49452. * Defines the allowed panning axis.
  49453. */
  49454. panningAxis: Vector3;
  49455. protected _transformedDirection: Vector3;
  49456. private _bouncingBehavior;
  49457. /**
  49458. * Gets the bouncing behavior of the camera if it has been enabled.
  49459. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49460. */
  49461. get bouncingBehavior(): Nullable<BouncingBehavior>;
  49462. /**
  49463. * Defines if the bouncing behavior of the camera is enabled on the camera.
  49464. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49465. */
  49466. get useBouncingBehavior(): boolean;
  49467. set useBouncingBehavior(value: boolean);
  49468. private _framingBehavior;
  49469. /**
  49470. * Gets the framing behavior of the camera if it has been enabled.
  49471. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49472. */
  49473. get framingBehavior(): Nullable<FramingBehavior>;
  49474. /**
  49475. * Defines if the framing behavior of the camera is enabled on the camera.
  49476. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49477. */
  49478. get useFramingBehavior(): boolean;
  49479. set useFramingBehavior(value: boolean);
  49480. private _autoRotationBehavior;
  49481. /**
  49482. * Gets the auto rotation behavior of the camera if it has been enabled.
  49483. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49484. */
  49485. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  49486. /**
  49487. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  49488. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49489. */
  49490. get useAutoRotationBehavior(): boolean;
  49491. set useAutoRotationBehavior(value: boolean);
  49492. /**
  49493. * Observable triggered when the mesh target has been changed on the camera.
  49494. */
  49495. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  49496. /**
  49497. * Event raised when the camera is colliding with a mesh.
  49498. */
  49499. onCollide: (collidedMesh: AbstractMesh) => void;
  49500. /**
  49501. * Defines whether the camera should check collision with the objects oh the scene.
  49502. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  49503. */
  49504. checkCollisions: boolean;
  49505. /**
  49506. * Defines the collision radius of the camera.
  49507. * This simulates a sphere around the camera.
  49508. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49509. */
  49510. collisionRadius: Vector3;
  49511. protected _collider: Collider;
  49512. protected _previousPosition: Vector3;
  49513. protected _collisionVelocity: Vector3;
  49514. protected _newPosition: Vector3;
  49515. protected _previousAlpha: number;
  49516. protected _previousBeta: number;
  49517. protected _previousRadius: number;
  49518. protected _collisionTriggered: boolean;
  49519. protected _targetBoundingCenter: Nullable<Vector3>;
  49520. private _computationVector;
  49521. /**
  49522. * Instantiates a new ArcRotateCamera in a given scene
  49523. * @param name Defines the name of the camera
  49524. * @param alpha Defines the camera rotation along the logitudinal axis
  49525. * @param beta Defines the camera rotation along the latitudinal axis
  49526. * @param radius Defines the camera distance from its target
  49527. * @param target Defines the camera target
  49528. * @param scene Defines the scene the camera belongs to
  49529. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  49530. */
  49531. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49532. /** @hidden */
  49533. _initCache(): void;
  49534. /** @hidden */
  49535. _updateCache(ignoreParentClass?: boolean): void;
  49536. protected _getTargetPosition(): Vector3;
  49537. private _storedAlpha;
  49538. private _storedBeta;
  49539. private _storedRadius;
  49540. private _storedTarget;
  49541. private _storedTargetScreenOffset;
  49542. /**
  49543. * Stores the current state of the camera (alpha, beta, radius and target)
  49544. * @returns the camera itself
  49545. */
  49546. storeState(): Camera;
  49547. /**
  49548. * @hidden
  49549. * Restored camera state. You must call storeState() first
  49550. */
  49551. _restoreStateValues(): boolean;
  49552. /** @hidden */
  49553. _isSynchronizedViewMatrix(): boolean;
  49554. /**
  49555. * Attach the input controls to a specific dom element to get the input from.
  49556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49557. */
  49558. attachControl(noPreventDefault?: boolean): void;
  49559. /**
  49560. * Attach the input controls to a specific dom element to get the input from.
  49561. * @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
  49562. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49563. */
  49564. attachControl(ignored: any, noPreventDefault?: boolean): void;
  49565. /**
  49566. * Attached controls to the current camera.
  49567. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49568. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49569. */
  49570. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49571. /**
  49572. * Attached controls to the current camera.
  49573. * @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
  49574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49575. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49576. */
  49577. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49578. /**
  49579. * Attached controls to the current camera.
  49580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49581. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49582. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  49583. */
  49584. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  49585. /**
  49586. * Detach the current controls from the specified dom element.
  49587. */
  49588. detachControl(): void;
  49589. /**
  49590. * Detach the current controls from the specified dom element.
  49591. * @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
  49592. */
  49593. detachControl(ignored: any): void;
  49594. /** @hidden */
  49595. _checkInputs(): void;
  49596. protected _checkLimits(): void;
  49597. /**
  49598. * Rebuilds angles (alpha, beta) and radius from the give position and target
  49599. */
  49600. rebuildAnglesAndRadius(): void;
  49601. /**
  49602. * Use a position to define the current camera related information like alpha, beta and radius
  49603. * @param position Defines the position to set the camera at
  49604. */
  49605. setPosition(position: Vector3): void;
  49606. /**
  49607. * Defines the target the camera should look at.
  49608. * This will automatically adapt alpha beta and radius to fit within the new target.
  49609. * @param target Defines the new target as a Vector or a mesh
  49610. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  49611. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  49612. */
  49613. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  49614. /** @hidden */
  49615. _getViewMatrix(): Matrix;
  49616. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  49617. /**
  49618. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  49619. * @param meshes Defines the mesh to zoom on
  49620. * @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)
  49621. */
  49622. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  49623. /**
  49624. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  49625. * The target will be changed but the radius
  49626. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  49627. * @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)
  49628. */
  49629. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  49630. min: Vector3;
  49631. max: Vector3;
  49632. distance: number;
  49633. }, doNotUpdateMaxZ?: boolean): void;
  49634. /**
  49635. * @override
  49636. * Override Camera.createRigCamera
  49637. */
  49638. createRigCamera(name: string, cameraIndex: number): Camera;
  49639. /**
  49640. * @hidden
  49641. * @override
  49642. * Override Camera._updateRigCameras
  49643. */
  49644. _updateRigCameras(): void;
  49645. /**
  49646. * Destroy the camera and release the current resources hold by it.
  49647. */
  49648. dispose(): void;
  49649. /**
  49650. * Gets the current object class name.
  49651. * @return the class name
  49652. */
  49653. getClassName(): string;
  49654. }
  49655. }
  49656. declare module BABYLON {
  49657. /**
  49658. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  49659. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49660. */
  49661. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  49662. /**
  49663. * Gets the name of the behavior.
  49664. */
  49665. get name(): string;
  49666. private _zoomStopsAnimation;
  49667. private _idleRotationSpeed;
  49668. private _idleRotationWaitTime;
  49669. private _idleRotationSpinupTime;
  49670. /**
  49671. * Sets the flag that indicates if user zooming should stop animation.
  49672. */
  49673. set zoomStopsAnimation(flag: boolean);
  49674. /**
  49675. * Gets the flag that indicates if user zooming should stop animation.
  49676. */
  49677. get zoomStopsAnimation(): boolean;
  49678. /**
  49679. * Sets the default speed at which the camera rotates around the model.
  49680. */
  49681. set idleRotationSpeed(speed: number);
  49682. /**
  49683. * Gets the default speed at which the camera rotates around the model.
  49684. */
  49685. get idleRotationSpeed(): number;
  49686. /**
  49687. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  49688. */
  49689. set idleRotationWaitTime(time: number);
  49690. /**
  49691. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  49692. */
  49693. get idleRotationWaitTime(): number;
  49694. /**
  49695. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49696. */
  49697. set idleRotationSpinupTime(time: number);
  49698. /**
  49699. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49700. */
  49701. get idleRotationSpinupTime(): number;
  49702. /**
  49703. * Gets a value indicating if the camera is currently rotating because of this behavior
  49704. */
  49705. get rotationInProgress(): boolean;
  49706. private _onPrePointerObservableObserver;
  49707. private _onAfterCheckInputsObserver;
  49708. private _attachedCamera;
  49709. private _isPointerDown;
  49710. private _lastFrameTime;
  49711. private _lastInteractionTime;
  49712. private _cameraRotationSpeed;
  49713. /**
  49714. * Initializes the behavior.
  49715. */
  49716. init(): void;
  49717. /**
  49718. * Attaches the behavior to its arc rotate camera.
  49719. * @param camera Defines the camera to attach the behavior to
  49720. */
  49721. attach(camera: ArcRotateCamera): void;
  49722. /**
  49723. * Detaches the behavior from its current arc rotate camera.
  49724. */
  49725. detach(): void;
  49726. /**
  49727. * Returns true if user is scrolling.
  49728. * @return true if user is scrolling.
  49729. */
  49730. private _userIsZooming;
  49731. private _lastFrameRadius;
  49732. private _shouldAnimationStopForInteraction;
  49733. /**
  49734. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49735. */
  49736. private _applyUserInteraction;
  49737. private _userIsMoving;
  49738. }
  49739. }
  49740. declare module BABYLON {
  49741. /**
  49742. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  49743. */
  49744. export class AttachToBoxBehavior implements Behavior<Mesh> {
  49745. private ui;
  49746. /**
  49747. * The name of the behavior
  49748. */
  49749. name: string;
  49750. /**
  49751. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  49752. */
  49753. distanceAwayFromFace: number;
  49754. /**
  49755. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  49756. */
  49757. distanceAwayFromBottomOfFace: number;
  49758. private _faceVectors;
  49759. private _target;
  49760. private _scene;
  49761. private _onRenderObserver;
  49762. private _tmpMatrix;
  49763. private _tmpVector;
  49764. /**
  49765. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  49766. * @param ui The transform node that should be attched to the mesh
  49767. */
  49768. constructor(ui: TransformNode);
  49769. /**
  49770. * Initializes the behavior
  49771. */
  49772. init(): void;
  49773. private _closestFace;
  49774. private _zeroVector;
  49775. private _lookAtTmpMatrix;
  49776. private _lookAtToRef;
  49777. /**
  49778. * Attaches the AttachToBoxBehavior to the passed in mesh
  49779. * @param target The mesh that the specified node will be attached to
  49780. */
  49781. attach(target: Mesh): void;
  49782. /**
  49783. * Detaches the behavior from the mesh
  49784. */
  49785. detach(): void;
  49786. }
  49787. }
  49788. declare module BABYLON {
  49789. /**
  49790. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  49791. */
  49792. export class FadeInOutBehavior implements Behavior<Mesh> {
  49793. /**
  49794. * Time in milliseconds to delay before fading in (Default: 0)
  49795. */
  49796. delay: number;
  49797. /**
  49798. * Time in milliseconds for the mesh to fade in (Default: 300)
  49799. */
  49800. fadeInTime: number;
  49801. private _millisecondsPerFrame;
  49802. private _hovered;
  49803. private _hoverValue;
  49804. private _ownerNode;
  49805. /**
  49806. * Instatiates the FadeInOutBehavior
  49807. */
  49808. constructor();
  49809. /**
  49810. * The name of the behavior
  49811. */
  49812. get name(): string;
  49813. /**
  49814. * Initializes the behavior
  49815. */
  49816. init(): void;
  49817. /**
  49818. * Attaches the fade behavior on the passed in mesh
  49819. * @param ownerNode The mesh that will be faded in/out once attached
  49820. */
  49821. attach(ownerNode: Mesh): void;
  49822. /**
  49823. * Detaches the behavior from the mesh
  49824. */
  49825. detach(): void;
  49826. /**
  49827. * Triggers the mesh to begin fading in or out
  49828. * @param value if the object should fade in or out (true to fade in)
  49829. */
  49830. fadeIn(value: boolean): void;
  49831. private _update;
  49832. private _setAllVisibility;
  49833. }
  49834. }
  49835. declare module BABYLON {
  49836. /**
  49837. * Class containing a set of static utilities functions for managing Pivots
  49838. * @hidden
  49839. */
  49840. export class PivotTools {
  49841. private static _PivotCached;
  49842. private static _OldPivotPoint;
  49843. private static _PivotTranslation;
  49844. private static _PivotTmpVector;
  49845. private static _PivotPostMultiplyPivotMatrix;
  49846. /** @hidden */
  49847. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  49848. /** @hidden */
  49849. static _RestorePivotPoint(mesh: AbstractMesh): void;
  49850. }
  49851. }
  49852. declare module BABYLON {
  49853. /**
  49854. * Class containing static functions to help procedurally build meshes
  49855. */
  49856. export class PlaneBuilder {
  49857. /**
  49858. * Creates a plane mesh
  49859. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49860. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49861. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49863. * * 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
  49864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49865. * @param name defines the name of the mesh
  49866. * @param options defines the options used to create the mesh
  49867. * @param scene defines the hosting scene
  49868. * @returns the plane mesh
  49869. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49870. */
  49871. static CreatePlane(name: string, options: {
  49872. size?: number;
  49873. width?: number;
  49874. height?: number;
  49875. sideOrientation?: number;
  49876. frontUVs?: Vector4;
  49877. backUVs?: Vector4;
  49878. updatable?: boolean;
  49879. sourcePlane?: Plane;
  49880. }, scene?: Nullable<Scene>): Mesh;
  49881. }
  49882. }
  49883. declare module BABYLON {
  49884. /**
  49885. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  49886. */
  49887. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  49888. private static _AnyMouseID;
  49889. /**
  49890. * Abstract mesh the behavior is set on
  49891. */
  49892. attachedNode: AbstractMesh;
  49893. private _dragPlane;
  49894. private _scene;
  49895. private _pointerObserver;
  49896. private _beforeRenderObserver;
  49897. private static _planeScene;
  49898. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  49899. /**
  49900. * 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)
  49901. */
  49902. maxDragAngle: number;
  49903. /**
  49904. * @hidden
  49905. */
  49906. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  49907. /**
  49908. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  49909. */
  49910. currentDraggingPointerID: number;
  49911. /**
  49912. * The last position where the pointer hit the drag plane in world space
  49913. */
  49914. lastDragPosition: Vector3;
  49915. /**
  49916. * If the behavior is currently in a dragging state
  49917. */
  49918. dragging: boolean;
  49919. /**
  49920. * 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)
  49921. */
  49922. dragDeltaRatio: number;
  49923. /**
  49924. * If the drag plane orientation should be updated during the dragging (Default: true)
  49925. */
  49926. updateDragPlane: boolean;
  49927. private _debugMode;
  49928. private _moving;
  49929. /**
  49930. * Fires each time the attached mesh is dragged with the pointer
  49931. * * delta between last drag position and current drag position in world space
  49932. * * dragDistance along the drag axis
  49933. * * dragPlaneNormal normal of the current drag plane used during the drag
  49934. * * dragPlanePoint in world space where the drag intersects the drag plane
  49935. */
  49936. onDragObservable: Observable<{
  49937. delta: Vector3;
  49938. dragPlanePoint: Vector3;
  49939. dragPlaneNormal: Vector3;
  49940. dragDistance: number;
  49941. pointerId: number;
  49942. }>;
  49943. /**
  49944. * Fires each time a drag begins (eg. mouse down on mesh)
  49945. */
  49946. onDragStartObservable: Observable<{
  49947. dragPlanePoint: Vector3;
  49948. pointerId: number;
  49949. }>;
  49950. /**
  49951. * Fires each time a drag ends (eg. mouse release after drag)
  49952. */
  49953. onDragEndObservable: Observable<{
  49954. dragPlanePoint: Vector3;
  49955. pointerId: number;
  49956. }>;
  49957. /**
  49958. * If the attached mesh should be moved when dragged
  49959. */
  49960. moveAttached: boolean;
  49961. /**
  49962. * If the drag behavior will react to drag events (Default: true)
  49963. */
  49964. enabled: boolean;
  49965. /**
  49966. * If pointer events should start and release the drag (Default: true)
  49967. */
  49968. startAndReleaseDragOnPointerEvents: boolean;
  49969. /**
  49970. * If camera controls should be detached during the drag
  49971. */
  49972. detachCameraControls: boolean;
  49973. /**
  49974. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  49975. */
  49976. useObjectOrientationForDragging: boolean;
  49977. private _options;
  49978. /**
  49979. * Gets the options used by the behavior
  49980. */
  49981. get options(): {
  49982. dragAxis?: Vector3;
  49983. dragPlaneNormal?: Vector3;
  49984. };
  49985. /**
  49986. * Sets the options used by the behavior
  49987. */
  49988. set options(options: {
  49989. dragAxis?: Vector3;
  49990. dragPlaneNormal?: Vector3;
  49991. });
  49992. /**
  49993. * Creates a pointer drag behavior that can be attached to a mesh
  49994. * @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)
  49995. */
  49996. constructor(options?: {
  49997. dragAxis?: Vector3;
  49998. dragPlaneNormal?: Vector3;
  49999. });
  50000. /**
  50001. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50002. */
  50003. validateDrag: (targetPosition: Vector3) => boolean;
  50004. /**
  50005. * The name of the behavior
  50006. */
  50007. get name(): string;
  50008. /**
  50009. * Initializes the behavior
  50010. */
  50011. init(): void;
  50012. private _tmpVector;
  50013. private _alternatePickedPoint;
  50014. private _worldDragAxis;
  50015. private _targetPosition;
  50016. private _attachedToElement;
  50017. /**
  50018. * Attaches the drag behavior the passed in mesh
  50019. * @param ownerNode The mesh that will be dragged around once attached
  50020. * @param predicate Predicate to use for pick filtering
  50021. */
  50022. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50023. /**
  50024. * Force relase the drag action by code.
  50025. */
  50026. releaseDrag(): void;
  50027. private _startDragRay;
  50028. private _lastPointerRay;
  50029. /**
  50030. * Simulates the start of a pointer drag event on the behavior
  50031. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50032. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50033. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50034. */
  50035. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50036. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50037. private _dragDelta;
  50038. protected _moveDrag(ray: Ray): void;
  50039. private _pickWithRayOnDragPlane;
  50040. private _pointA;
  50041. private _pointC;
  50042. private _localAxis;
  50043. private _lookAt;
  50044. private _updateDragPlanePosition;
  50045. /**
  50046. * Detaches the behavior from the mesh
  50047. */
  50048. detach(): void;
  50049. }
  50050. }
  50051. declare module BABYLON {
  50052. /**
  50053. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50054. */
  50055. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50056. private _dragBehaviorA;
  50057. private _dragBehaviorB;
  50058. private _startDistance;
  50059. private _initialScale;
  50060. private _targetScale;
  50061. private _ownerNode;
  50062. private _sceneRenderObserver;
  50063. /**
  50064. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50065. */
  50066. constructor();
  50067. /**
  50068. * The name of the behavior
  50069. */
  50070. get name(): string;
  50071. /**
  50072. * Initializes the behavior
  50073. */
  50074. init(): void;
  50075. private _getCurrentDistance;
  50076. /**
  50077. * Attaches the scale behavior the passed in mesh
  50078. * @param ownerNode The mesh that will be scaled around once attached
  50079. */
  50080. attach(ownerNode: Mesh): void;
  50081. /**
  50082. * Detaches the behavior from the mesh
  50083. */
  50084. detach(): void;
  50085. }
  50086. }
  50087. declare module BABYLON {
  50088. /**
  50089. * 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
  50090. */
  50091. export class SixDofDragBehavior implements Behavior<Mesh> {
  50092. private static _virtualScene;
  50093. private _ownerNode;
  50094. private _sceneRenderObserver;
  50095. private _scene;
  50096. private _targetPosition;
  50097. private _virtualOriginMesh;
  50098. private _virtualDragMesh;
  50099. private _pointerObserver;
  50100. private _moving;
  50101. private _startingOrientation;
  50102. private _attachedToElement;
  50103. /**
  50104. * 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)
  50105. */
  50106. private zDragFactor;
  50107. /**
  50108. * If the object should rotate to face the drag origin
  50109. */
  50110. rotateDraggedObject: boolean;
  50111. /**
  50112. * If the behavior is currently in a dragging state
  50113. */
  50114. dragging: boolean;
  50115. /**
  50116. * 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)
  50117. */
  50118. dragDeltaRatio: number;
  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. * If camera controls should be detached during the drag
  50125. */
  50126. detachCameraControls: boolean;
  50127. /**
  50128. * Fires each time a drag starts
  50129. */
  50130. onDragStartObservable: Observable<{}>;
  50131. /**
  50132. * Fires each time a drag happens
  50133. */
  50134. onDragObservable: Observable<void>;
  50135. /**
  50136. * Fires each time a drag ends (eg. mouse release after drag)
  50137. */
  50138. onDragEndObservable: Observable<{}>;
  50139. /**
  50140. * 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
  50141. */
  50142. constructor();
  50143. /**
  50144. * The name of the behavior
  50145. */
  50146. get name(): string;
  50147. /**
  50148. * Initializes the behavior
  50149. */
  50150. init(): void;
  50151. /**
  50152. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50153. */
  50154. private get _pointerCamera();
  50155. /**
  50156. * Attaches the scale behavior the passed in mesh
  50157. * @param ownerNode The mesh that will be scaled around once attached
  50158. */
  50159. attach(ownerNode: Mesh): void;
  50160. /**
  50161. * Detaches the behavior from the mesh
  50162. */
  50163. detach(): void;
  50164. }
  50165. }
  50166. declare module BABYLON {
  50167. /**
  50168. * Class used to apply inverse kinematics to bones
  50169. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50170. */
  50171. export class BoneIKController {
  50172. private static _tmpVecs;
  50173. private static _tmpQuat;
  50174. private static _tmpMats;
  50175. /**
  50176. * Gets or sets the target mesh
  50177. */
  50178. targetMesh: AbstractMesh;
  50179. /** Gets or sets the mesh used as pole */
  50180. poleTargetMesh: AbstractMesh;
  50181. /**
  50182. * Gets or sets the bone used as pole
  50183. */
  50184. poleTargetBone: Nullable<Bone>;
  50185. /**
  50186. * Gets or sets the target position
  50187. */
  50188. targetPosition: Vector3;
  50189. /**
  50190. * Gets or sets the pole target position
  50191. */
  50192. poleTargetPosition: Vector3;
  50193. /**
  50194. * Gets or sets the pole target local offset
  50195. */
  50196. poleTargetLocalOffset: Vector3;
  50197. /**
  50198. * Gets or sets the pole angle
  50199. */
  50200. poleAngle: number;
  50201. /**
  50202. * Gets or sets the mesh associated with the controller
  50203. */
  50204. mesh: AbstractMesh;
  50205. /**
  50206. * 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)
  50207. */
  50208. slerpAmount: number;
  50209. private _bone1Quat;
  50210. private _bone1Mat;
  50211. private _bone2Ang;
  50212. private _bone1;
  50213. private _bone2;
  50214. private _bone1Length;
  50215. private _bone2Length;
  50216. private _maxAngle;
  50217. private _maxReach;
  50218. private _rightHandedSystem;
  50219. private _bendAxis;
  50220. private _slerping;
  50221. private _adjustRoll;
  50222. /**
  50223. * Gets or sets maximum allowed angle
  50224. */
  50225. get maxAngle(): number;
  50226. set maxAngle(value: number);
  50227. /**
  50228. * Creates a new BoneIKController
  50229. * @param mesh defines the mesh to control
  50230. * @param bone defines the bone to control
  50231. * @param options defines options to set up the controller
  50232. */
  50233. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50234. targetMesh?: AbstractMesh;
  50235. poleTargetMesh?: AbstractMesh;
  50236. poleTargetBone?: Bone;
  50237. poleTargetLocalOffset?: Vector3;
  50238. poleAngle?: number;
  50239. bendAxis?: Vector3;
  50240. maxAngle?: number;
  50241. slerpAmount?: number;
  50242. });
  50243. private _setMaxAngle;
  50244. /**
  50245. * Force the controller to update the bones
  50246. */
  50247. update(): void;
  50248. }
  50249. }
  50250. declare module BABYLON {
  50251. /**
  50252. * Class used to make a bone look toward a point in space
  50253. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50254. */
  50255. export class BoneLookController {
  50256. private static _tmpVecs;
  50257. private static _tmpQuat;
  50258. private static _tmpMats;
  50259. /**
  50260. * The target Vector3 that the bone will look at
  50261. */
  50262. target: Vector3;
  50263. /**
  50264. * The mesh that the bone is attached to
  50265. */
  50266. mesh: AbstractMesh;
  50267. /**
  50268. * The bone that will be looking to the target
  50269. */
  50270. bone: Bone;
  50271. /**
  50272. * The up axis of the coordinate system that is used when the bone is rotated
  50273. */
  50274. upAxis: Vector3;
  50275. /**
  50276. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  50277. */
  50278. upAxisSpace: Space;
  50279. /**
  50280. * Used to make an adjustment to the yaw of the bone
  50281. */
  50282. adjustYaw: number;
  50283. /**
  50284. * Used to make an adjustment to the pitch of the bone
  50285. */
  50286. adjustPitch: number;
  50287. /**
  50288. * Used to make an adjustment to the roll of the bone
  50289. */
  50290. adjustRoll: number;
  50291. /**
  50292. * 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)
  50293. */
  50294. slerpAmount: number;
  50295. private _minYaw;
  50296. private _maxYaw;
  50297. private _minPitch;
  50298. private _maxPitch;
  50299. private _minYawSin;
  50300. private _minYawCos;
  50301. private _maxYawSin;
  50302. private _maxYawCos;
  50303. private _midYawConstraint;
  50304. private _minPitchTan;
  50305. private _maxPitchTan;
  50306. private _boneQuat;
  50307. private _slerping;
  50308. private _transformYawPitch;
  50309. private _transformYawPitchInv;
  50310. private _firstFrameSkipped;
  50311. private _yawRange;
  50312. private _fowardAxis;
  50313. /**
  50314. * Gets or sets the minimum yaw angle that the bone can look to
  50315. */
  50316. get minYaw(): number;
  50317. set minYaw(value: number);
  50318. /**
  50319. * Gets or sets the maximum yaw angle that the bone can look to
  50320. */
  50321. get maxYaw(): number;
  50322. set maxYaw(value: number);
  50323. /**
  50324. * Gets or sets the minimum pitch angle that the bone can look to
  50325. */
  50326. get minPitch(): number;
  50327. set minPitch(value: number);
  50328. /**
  50329. * Gets or sets the maximum pitch angle that the bone can look to
  50330. */
  50331. get maxPitch(): number;
  50332. set maxPitch(value: number);
  50333. /**
  50334. * Create a BoneLookController
  50335. * @param mesh the mesh that the bone belongs to
  50336. * @param bone the bone that will be looking to the target
  50337. * @param target the target Vector3 to look at
  50338. * @param options optional settings:
  50339. * * maxYaw: the maximum angle the bone will yaw to
  50340. * * minYaw: the minimum angle the bone will yaw to
  50341. * * maxPitch: the maximum angle the bone will pitch to
  50342. * * minPitch: the minimum angle the bone will yaw to
  50343. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  50344. * * upAxis: the up axis of the coordinate system
  50345. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  50346. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  50347. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  50348. * * adjustYaw: used to make an adjustment to the yaw of the bone
  50349. * * adjustPitch: used to make an adjustment to the pitch of the bone
  50350. * * adjustRoll: used to make an adjustment to the roll of the bone
  50351. **/
  50352. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  50353. maxYaw?: number;
  50354. minYaw?: number;
  50355. maxPitch?: number;
  50356. minPitch?: number;
  50357. slerpAmount?: number;
  50358. upAxis?: Vector3;
  50359. upAxisSpace?: Space;
  50360. yawAxis?: Vector3;
  50361. pitchAxis?: Vector3;
  50362. adjustYaw?: number;
  50363. adjustPitch?: number;
  50364. adjustRoll?: number;
  50365. });
  50366. /**
  50367. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  50368. */
  50369. update(): void;
  50370. private _getAngleDiff;
  50371. private _getAngleBetween;
  50372. private _isAngleBetween;
  50373. }
  50374. }
  50375. declare module BABYLON {
  50376. /**
  50377. * Manage the gamepad inputs to control an arc rotate camera.
  50378. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50379. */
  50380. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  50381. /**
  50382. * Defines the camera the input is attached to.
  50383. */
  50384. camera: ArcRotateCamera;
  50385. /**
  50386. * Defines the gamepad the input is gathering event from.
  50387. */
  50388. gamepad: Nullable<Gamepad>;
  50389. /**
  50390. * Defines the gamepad rotation sensiblity.
  50391. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50392. */
  50393. gamepadRotationSensibility: number;
  50394. /**
  50395. * Defines the gamepad move sensiblity.
  50396. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50397. */
  50398. gamepadMoveSensibility: number;
  50399. private _yAxisScale;
  50400. /**
  50401. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50402. */
  50403. get invertYAxis(): boolean;
  50404. set invertYAxis(value: boolean);
  50405. private _onGamepadConnectedObserver;
  50406. private _onGamepadDisconnectedObserver;
  50407. /**
  50408. * Attach the input controls to a specific dom element to get the input from.
  50409. */
  50410. attachControl(): void;
  50411. /**
  50412. * Detach the current controls from the specified dom element.
  50413. */
  50414. detachControl(): void;
  50415. /**
  50416. * Update the current camera state depending on the inputs that have been used this frame.
  50417. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50418. */
  50419. checkInputs(): void;
  50420. /**
  50421. * Gets the class name of the current intput.
  50422. * @returns the class name
  50423. */
  50424. getClassName(): string;
  50425. /**
  50426. * Get the friendly name associated with the input class.
  50427. * @returns the input friendly name
  50428. */
  50429. getSimpleName(): string;
  50430. }
  50431. }
  50432. declare module BABYLON {
  50433. interface ArcRotateCameraInputsManager {
  50434. /**
  50435. * Add orientation input support to the input manager.
  50436. * @returns the current input manager
  50437. */
  50438. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  50439. }
  50440. /**
  50441. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  50442. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50443. */
  50444. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  50445. /**
  50446. * Defines the camera the input is attached to.
  50447. */
  50448. camera: ArcRotateCamera;
  50449. /**
  50450. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  50451. */
  50452. alphaCorrection: number;
  50453. /**
  50454. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  50455. */
  50456. gammaCorrection: number;
  50457. private _alpha;
  50458. private _gamma;
  50459. private _dirty;
  50460. private _deviceOrientationHandler;
  50461. /**
  50462. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  50463. */
  50464. constructor();
  50465. /**
  50466. * Attach the input controls to a specific dom element to get the input from.
  50467. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50468. */
  50469. attachControl(noPreventDefault?: boolean): void;
  50470. /** @hidden */
  50471. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  50472. /**
  50473. * Update the current camera state depending on the inputs that have been used this frame.
  50474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50475. */
  50476. checkInputs(): void;
  50477. /**
  50478. * Detach the current controls from the specified dom element.
  50479. */
  50480. detachControl(): void;
  50481. /**
  50482. * Gets the class name of the current intput.
  50483. * @returns the class name
  50484. */
  50485. getClassName(): string;
  50486. /**
  50487. * Get the friendly name associated with the input class.
  50488. * @returns the input friendly name
  50489. */
  50490. getSimpleName(): string;
  50491. }
  50492. }
  50493. declare module BABYLON {
  50494. /**
  50495. * Listen to mouse events to control the camera.
  50496. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50497. */
  50498. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  50499. /**
  50500. * Defines the camera the input is attached to.
  50501. */
  50502. camera: FlyCamera;
  50503. /**
  50504. * Defines if touch is enabled. (Default is true.)
  50505. */
  50506. touchEnabled: boolean;
  50507. /**
  50508. * Defines the buttons associated with the input to handle camera rotation.
  50509. */
  50510. buttons: number[];
  50511. /**
  50512. * Assign buttons for Yaw control.
  50513. */
  50514. buttonsYaw: number[];
  50515. /**
  50516. * Assign buttons for Pitch control.
  50517. */
  50518. buttonsPitch: number[];
  50519. /**
  50520. * Assign buttons for Roll control.
  50521. */
  50522. buttonsRoll: number[];
  50523. /**
  50524. * Detect if any button is being pressed while mouse is moved.
  50525. * -1 = Mouse locked.
  50526. * 0 = Left button.
  50527. * 1 = Middle Button.
  50528. * 2 = Right Button.
  50529. */
  50530. activeButton: number;
  50531. /**
  50532. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  50533. * Higher values reduce its sensitivity.
  50534. */
  50535. angularSensibility: number;
  50536. private _observer;
  50537. private _rollObserver;
  50538. private previousPosition;
  50539. private noPreventDefault;
  50540. private element;
  50541. /**
  50542. * Listen to mouse events to control the camera.
  50543. * @param touchEnabled Define if touch is enabled. (Default is true.)
  50544. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50545. */
  50546. constructor(touchEnabled?: boolean);
  50547. /**
  50548. * Attach the mouse control to the HTML DOM element.
  50549. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  50550. */
  50551. attachControl(noPreventDefault?: boolean): void;
  50552. /**
  50553. * Detach the current controls from the specified dom element.
  50554. */
  50555. detachControl(): void;
  50556. /**
  50557. * Gets the class name of the current input.
  50558. * @returns the class name.
  50559. */
  50560. getClassName(): string;
  50561. /**
  50562. * Get the friendly name associated with the input class.
  50563. * @returns the input's friendly name.
  50564. */
  50565. getSimpleName(): string;
  50566. private _pointerInput;
  50567. private _onMouseMove;
  50568. /**
  50569. * Rotate camera by mouse offset.
  50570. */
  50571. private rotateCamera;
  50572. }
  50573. }
  50574. declare module BABYLON {
  50575. /**
  50576. * Default Inputs manager for the FlyCamera.
  50577. * It groups all the default supported inputs for ease of use.
  50578. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50579. */
  50580. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  50581. /**
  50582. * Instantiates a new FlyCameraInputsManager.
  50583. * @param camera Defines the camera the inputs belong to.
  50584. */
  50585. constructor(camera: FlyCamera);
  50586. /**
  50587. * Add keyboard input support to the input manager.
  50588. * @returns the new FlyCameraKeyboardMoveInput().
  50589. */
  50590. addKeyboard(): FlyCameraInputsManager;
  50591. /**
  50592. * Add mouse input support to the input manager.
  50593. * @param touchEnabled Enable touch screen support.
  50594. * @returns the new FlyCameraMouseInput().
  50595. */
  50596. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  50597. }
  50598. }
  50599. declare module BABYLON {
  50600. /**
  50601. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50602. * such as in a 3D Space Shooter or a Flight Simulator.
  50603. */
  50604. export class FlyCamera extends TargetCamera {
  50605. /**
  50606. * Define the collision ellipsoid of the camera.
  50607. * This is helpful for simulating a camera body, like a player's body.
  50608. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50609. */
  50610. ellipsoid: Vector3;
  50611. /**
  50612. * Define an offset for the position of the ellipsoid around the camera.
  50613. * This can be helpful if the camera is attached away from the player's body center,
  50614. * such as at its head.
  50615. */
  50616. ellipsoidOffset: Vector3;
  50617. /**
  50618. * Enable or disable collisions of the camera with the rest of the scene objects.
  50619. */
  50620. checkCollisions: boolean;
  50621. /**
  50622. * Enable or disable gravity on the camera.
  50623. */
  50624. applyGravity: boolean;
  50625. /**
  50626. * Define the current direction the camera is moving to.
  50627. */
  50628. cameraDirection: Vector3;
  50629. /**
  50630. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  50631. * This overrides and empties cameraRotation.
  50632. */
  50633. rotationQuaternion: Quaternion;
  50634. /**
  50635. * Track Roll to maintain the wanted Rolling when looking around.
  50636. */
  50637. _trackRoll: number;
  50638. /**
  50639. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  50640. */
  50641. rollCorrect: number;
  50642. /**
  50643. * Mimic a banked turn, Rolling the camera when Yawing.
  50644. * It's recommended to use rollCorrect = 10 for faster banking correction.
  50645. */
  50646. bankedTurn: boolean;
  50647. /**
  50648. * Limit in radians for how much Roll banking will add. (Default: 90°)
  50649. */
  50650. bankedTurnLimit: number;
  50651. /**
  50652. * Value of 0 disables the banked Roll.
  50653. * Value of 1 is equal to the Yaw angle in radians.
  50654. */
  50655. bankedTurnMultiplier: number;
  50656. /**
  50657. * The inputs manager loads all the input sources, such as keyboard and mouse.
  50658. */
  50659. inputs: FlyCameraInputsManager;
  50660. /**
  50661. * Gets the input sensibility for mouse input.
  50662. * Higher values reduce sensitivity.
  50663. */
  50664. get angularSensibility(): number;
  50665. /**
  50666. * Sets the input sensibility for a mouse input.
  50667. * Higher values reduce sensitivity.
  50668. */
  50669. set angularSensibility(value: number);
  50670. /**
  50671. * Get the keys for camera movement forward.
  50672. */
  50673. get keysForward(): number[];
  50674. /**
  50675. * Set the keys for camera movement forward.
  50676. */
  50677. set keysForward(value: number[]);
  50678. /**
  50679. * Get the keys for camera movement backward.
  50680. */
  50681. get keysBackward(): number[];
  50682. set keysBackward(value: number[]);
  50683. /**
  50684. * Get the keys for camera movement up.
  50685. */
  50686. get keysUp(): number[];
  50687. /**
  50688. * Set the keys for camera movement up.
  50689. */
  50690. set keysUp(value: number[]);
  50691. /**
  50692. * Get the keys for camera movement down.
  50693. */
  50694. get keysDown(): number[];
  50695. /**
  50696. * Set the keys for camera movement down.
  50697. */
  50698. set keysDown(value: number[]);
  50699. /**
  50700. * Get the keys for camera movement left.
  50701. */
  50702. get keysLeft(): number[];
  50703. /**
  50704. * Set the keys for camera movement left.
  50705. */
  50706. set keysLeft(value: number[]);
  50707. /**
  50708. * Set the keys for camera movement right.
  50709. */
  50710. get keysRight(): number[];
  50711. /**
  50712. * Set the keys for camera movement right.
  50713. */
  50714. set keysRight(value: number[]);
  50715. /**
  50716. * Event raised when the camera collides with a mesh in the scene.
  50717. */
  50718. onCollide: (collidedMesh: AbstractMesh) => void;
  50719. private _collider;
  50720. private _needMoveForGravity;
  50721. private _oldPosition;
  50722. private _diffPosition;
  50723. private _newPosition;
  50724. /** @hidden */
  50725. _localDirection: Vector3;
  50726. /** @hidden */
  50727. _transformedDirection: Vector3;
  50728. /**
  50729. * Instantiates a FlyCamera.
  50730. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50731. * such as in a 3D Space Shooter or a Flight Simulator.
  50732. * @param name Define the name of the camera in the scene.
  50733. * @param position Define the starting position of the camera in the scene.
  50734. * @param scene Define the scene the camera belongs to.
  50735. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  50736. */
  50737. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50738. /**
  50739. * Attach the input controls to a specific dom element to get the input from.
  50740. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50741. */
  50742. attachControl(noPreventDefault?: boolean): void;
  50743. /**
  50744. * Detach a control from the HTML DOM element.
  50745. * The camera will stop reacting to that input.
  50746. */
  50747. detachControl(): void;
  50748. private _collisionMask;
  50749. /**
  50750. * Get the mask that the camera ignores in collision events.
  50751. */
  50752. get collisionMask(): number;
  50753. /**
  50754. * Set the mask that the camera ignores in collision events.
  50755. */
  50756. set collisionMask(mask: number);
  50757. /** @hidden */
  50758. _collideWithWorld(displacement: Vector3): void;
  50759. /** @hidden */
  50760. private _onCollisionPositionChange;
  50761. /** @hidden */
  50762. _checkInputs(): void;
  50763. /** @hidden */
  50764. _decideIfNeedsToMove(): boolean;
  50765. /** @hidden */
  50766. _updatePosition(): void;
  50767. /**
  50768. * Restore the Roll to its target value at the rate specified.
  50769. * @param rate - Higher means slower restoring.
  50770. * @hidden
  50771. */
  50772. restoreRoll(rate: number): void;
  50773. /**
  50774. * Destroy the camera and release the current resources held by it.
  50775. */
  50776. dispose(): void;
  50777. /**
  50778. * Get the current object class name.
  50779. * @returns the class name.
  50780. */
  50781. getClassName(): string;
  50782. }
  50783. }
  50784. declare module BABYLON {
  50785. /**
  50786. * Listen to keyboard events to control the camera.
  50787. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50788. */
  50789. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  50790. /**
  50791. * Defines the camera the input is attached to.
  50792. */
  50793. camera: FlyCamera;
  50794. /**
  50795. * The list of keyboard keys used to control the forward move of the camera.
  50796. */
  50797. keysForward: number[];
  50798. /**
  50799. * The list of keyboard keys used to control the backward move of the camera.
  50800. */
  50801. keysBackward: number[];
  50802. /**
  50803. * The list of keyboard keys used to control the forward move of the camera.
  50804. */
  50805. keysUp: number[];
  50806. /**
  50807. * The list of keyboard keys used to control the backward move of the camera.
  50808. */
  50809. keysDown: number[];
  50810. /**
  50811. * The list of keyboard keys used to control the right strafe move of the camera.
  50812. */
  50813. keysRight: number[];
  50814. /**
  50815. * The list of keyboard keys used to control the left strafe move of the camera.
  50816. */
  50817. keysLeft: number[];
  50818. private _keys;
  50819. private _onCanvasBlurObserver;
  50820. private _onKeyboardObserver;
  50821. private _engine;
  50822. private _scene;
  50823. /**
  50824. * Attach the input controls to a specific dom element to get the input from.
  50825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50826. */
  50827. attachControl(noPreventDefault?: boolean): void;
  50828. /**
  50829. * Detach the current controls from the specified dom element.
  50830. */
  50831. detachControl(): void;
  50832. /**
  50833. * Gets the class name of the current intput.
  50834. * @returns the class name
  50835. */
  50836. getClassName(): string;
  50837. /** @hidden */
  50838. _onLostFocus(e: FocusEvent): void;
  50839. /**
  50840. * Get the friendly name associated with the input class.
  50841. * @returns the input friendly name
  50842. */
  50843. getSimpleName(): string;
  50844. /**
  50845. * Update the current camera state depending on the inputs that have been used this frame.
  50846. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50847. */
  50848. checkInputs(): void;
  50849. }
  50850. }
  50851. declare module BABYLON {
  50852. /**
  50853. * Manage the mouse wheel inputs to control a follow camera.
  50854. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50855. */
  50856. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  50857. /**
  50858. * Defines the camera the input is attached to.
  50859. */
  50860. camera: FollowCamera;
  50861. /**
  50862. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  50863. */
  50864. axisControlRadius: boolean;
  50865. /**
  50866. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  50867. */
  50868. axisControlHeight: boolean;
  50869. /**
  50870. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  50871. */
  50872. axisControlRotation: boolean;
  50873. /**
  50874. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  50875. * relation to mouseWheel events.
  50876. */
  50877. wheelPrecision: number;
  50878. /**
  50879. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  50880. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  50881. */
  50882. wheelDeltaPercentage: number;
  50883. private _wheel;
  50884. private _observer;
  50885. /**
  50886. * Attach the input controls to a specific dom element to get the input from.
  50887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50888. */
  50889. attachControl(noPreventDefault?: boolean): void;
  50890. /**
  50891. * Detach the current controls from the specified dom element.
  50892. */
  50893. detachControl(): void;
  50894. /**
  50895. * Gets the class name of the current intput.
  50896. * @returns the class name
  50897. */
  50898. getClassName(): string;
  50899. /**
  50900. * Get the friendly name associated with the input class.
  50901. * @returns the input friendly name
  50902. */
  50903. getSimpleName(): string;
  50904. }
  50905. }
  50906. declare module BABYLON {
  50907. /**
  50908. * Manage the pointers inputs to control an follow camera.
  50909. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50910. */
  50911. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  50912. /**
  50913. * Defines the camera the input is attached to.
  50914. */
  50915. camera: FollowCamera;
  50916. /**
  50917. * Gets the class name of the current input.
  50918. * @returns the class name
  50919. */
  50920. getClassName(): string;
  50921. /**
  50922. * Defines the pointer angular sensibility along the X axis or how fast is
  50923. * the camera rotating.
  50924. * A negative number will reverse the axis direction.
  50925. */
  50926. angularSensibilityX: number;
  50927. /**
  50928. * Defines the pointer angular sensibility along the Y axis or how fast is
  50929. * the camera rotating.
  50930. * A negative number will reverse the axis direction.
  50931. */
  50932. angularSensibilityY: number;
  50933. /**
  50934. * Defines the pointer pinch precision or how fast is the camera zooming.
  50935. * A negative number will reverse the axis direction.
  50936. */
  50937. pinchPrecision: number;
  50938. /**
  50939. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  50940. * from 0.
  50941. * It defines the percentage of current camera.radius to use as delta when
  50942. * pinch zoom is used.
  50943. */
  50944. pinchDeltaPercentage: number;
  50945. /**
  50946. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  50947. */
  50948. axisXControlRadius: boolean;
  50949. /**
  50950. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  50951. */
  50952. axisXControlHeight: boolean;
  50953. /**
  50954. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  50955. */
  50956. axisXControlRotation: boolean;
  50957. /**
  50958. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  50959. */
  50960. axisYControlRadius: boolean;
  50961. /**
  50962. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  50963. */
  50964. axisYControlHeight: boolean;
  50965. /**
  50966. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  50967. */
  50968. axisYControlRotation: boolean;
  50969. /**
  50970. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  50971. */
  50972. axisPinchControlRadius: boolean;
  50973. /**
  50974. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  50975. */
  50976. axisPinchControlHeight: boolean;
  50977. /**
  50978. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  50979. */
  50980. axisPinchControlRotation: boolean;
  50981. /**
  50982. * Log error messages if basic misconfiguration has occurred.
  50983. */
  50984. warningEnable: boolean;
  50985. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  50986. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  50987. private _warningCounter;
  50988. private _warning;
  50989. }
  50990. }
  50991. declare module BABYLON {
  50992. /**
  50993. * Default Inputs manager for the FollowCamera.
  50994. * It groups all the default supported inputs for ease of use.
  50995. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50996. */
  50997. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  50998. /**
  50999. * Instantiates a new FollowCameraInputsManager.
  51000. * @param camera Defines the camera the inputs belong to
  51001. */
  51002. constructor(camera: FollowCamera);
  51003. /**
  51004. * Add keyboard input support to the input manager.
  51005. * @returns the current input manager
  51006. */
  51007. addKeyboard(): FollowCameraInputsManager;
  51008. /**
  51009. * Add mouse wheel input support to the input manager.
  51010. * @returns the current input manager
  51011. */
  51012. addMouseWheel(): FollowCameraInputsManager;
  51013. /**
  51014. * Add pointers input support to the input manager.
  51015. * @returns the current input manager
  51016. */
  51017. addPointers(): FollowCameraInputsManager;
  51018. /**
  51019. * Add orientation input support to the input manager.
  51020. * @returns the current input manager
  51021. */
  51022. addVRDeviceOrientation(): FollowCameraInputsManager;
  51023. }
  51024. }
  51025. declare module BABYLON {
  51026. /**
  51027. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51028. * an arc rotate version arcFollowCamera are available.
  51029. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51030. */
  51031. export class FollowCamera extends TargetCamera {
  51032. /**
  51033. * Distance the follow camera should follow an object at
  51034. */
  51035. radius: number;
  51036. /**
  51037. * Minimum allowed distance of the camera to the axis of rotation
  51038. * (The camera can not get closer).
  51039. * This can help limiting how the Camera is able to move in the scene.
  51040. */
  51041. lowerRadiusLimit: Nullable<number>;
  51042. /**
  51043. * Maximum allowed distance of the camera to the axis of rotation
  51044. * (The camera can not get further).
  51045. * This can help limiting how the Camera is able to move in the scene.
  51046. */
  51047. upperRadiusLimit: Nullable<number>;
  51048. /**
  51049. * Define a rotation offset between the camera and the object it follows
  51050. */
  51051. rotationOffset: number;
  51052. /**
  51053. * Minimum allowed angle to camera position relative to target object.
  51054. * This can help limiting how the Camera is able to move in the scene.
  51055. */
  51056. lowerRotationOffsetLimit: Nullable<number>;
  51057. /**
  51058. * Maximum allowed angle to camera position relative to target object.
  51059. * This can help limiting how the Camera is able to move in the scene.
  51060. */
  51061. upperRotationOffsetLimit: Nullable<number>;
  51062. /**
  51063. * Define a height offset between the camera and the object it follows.
  51064. * It can help following an object from the top (like a car chaing a plane)
  51065. */
  51066. heightOffset: number;
  51067. /**
  51068. * Minimum allowed height of camera position relative to target object.
  51069. * This can help limiting how the Camera is able to move in the scene.
  51070. */
  51071. lowerHeightOffsetLimit: Nullable<number>;
  51072. /**
  51073. * Maximum allowed height of camera position relative to target object.
  51074. * This can help limiting how the Camera is able to move in the scene.
  51075. */
  51076. upperHeightOffsetLimit: Nullable<number>;
  51077. /**
  51078. * Define how fast the camera can accelerate to follow it s target.
  51079. */
  51080. cameraAcceleration: number;
  51081. /**
  51082. * Define the speed limit of the camera following an object.
  51083. */
  51084. maxCameraSpeed: number;
  51085. /**
  51086. * Define the target of the camera.
  51087. */
  51088. lockedTarget: Nullable<AbstractMesh>;
  51089. /**
  51090. * Defines the input associated with the camera.
  51091. */
  51092. inputs: FollowCameraInputsManager;
  51093. /**
  51094. * Instantiates the follow camera.
  51095. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51096. * @param name Define the name of the camera in the scene
  51097. * @param position Define the position of the camera
  51098. * @param scene Define the scene the camera belong to
  51099. * @param lockedTarget Define the target of the camera
  51100. */
  51101. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51102. private _follow;
  51103. /**
  51104. * Attach the input controls to a specific dom element to get the input from.
  51105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51106. */
  51107. attachControl(noPreventDefault?: boolean): void;
  51108. /**
  51109. * Detach the current controls from the specified dom element.
  51110. */
  51111. detachControl(): void;
  51112. /** @hidden */
  51113. _checkInputs(): void;
  51114. private _checkLimits;
  51115. /**
  51116. * Gets the camera class name.
  51117. * @returns the class name
  51118. */
  51119. getClassName(): string;
  51120. }
  51121. /**
  51122. * Arc Rotate version of the follow camera.
  51123. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51124. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51125. */
  51126. export class ArcFollowCamera extends TargetCamera {
  51127. /** The longitudinal angle of the camera */
  51128. alpha: number;
  51129. /** The latitudinal angle of the camera */
  51130. beta: number;
  51131. /** The radius of the camera from its target */
  51132. radius: number;
  51133. private _cartesianCoordinates;
  51134. /** Define the camera target (the mesh it should follow) */
  51135. private _meshTarget;
  51136. /**
  51137. * Instantiates a new ArcFollowCamera
  51138. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51139. * @param name Define the name of the camera
  51140. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  51141. * @param beta Define the rotation angle of the camera around the elevation axis
  51142. * @param radius Define the radius of the camera from its target point
  51143. * @param target Define the target of the camera
  51144. * @param scene Define the scene the camera belongs to
  51145. */
  51146. constructor(name: string,
  51147. /** The longitudinal angle of the camera */
  51148. alpha: number,
  51149. /** The latitudinal angle of the camera */
  51150. beta: number,
  51151. /** The radius of the camera from its target */
  51152. radius: number,
  51153. /** Define the camera target (the mesh it should follow) */
  51154. target: Nullable<AbstractMesh>, scene: Scene);
  51155. private _follow;
  51156. /** @hidden */
  51157. _checkInputs(): void;
  51158. /**
  51159. * Returns the class name of the object.
  51160. * It is mostly used internally for serialization purposes.
  51161. */
  51162. getClassName(): string;
  51163. }
  51164. }
  51165. declare module BABYLON {
  51166. /**
  51167. * Manage the keyboard inputs to control the movement of a follow camera.
  51168. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51169. */
  51170. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51171. /**
  51172. * Defines the camera the input is attached to.
  51173. */
  51174. camera: FollowCamera;
  51175. /**
  51176. * Defines the list of key codes associated with the up action (increase heightOffset)
  51177. */
  51178. keysHeightOffsetIncr: number[];
  51179. /**
  51180. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51181. */
  51182. keysHeightOffsetDecr: number[];
  51183. /**
  51184. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51185. */
  51186. keysHeightOffsetModifierAlt: boolean;
  51187. /**
  51188. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51189. */
  51190. keysHeightOffsetModifierCtrl: boolean;
  51191. /**
  51192. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51193. */
  51194. keysHeightOffsetModifierShift: boolean;
  51195. /**
  51196. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51197. */
  51198. keysRotationOffsetIncr: number[];
  51199. /**
  51200. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51201. */
  51202. keysRotationOffsetDecr: number[];
  51203. /**
  51204. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51205. */
  51206. keysRotationOffsetModifierAlt: boolean;
  51207. /**
  51208. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51209. */
  51210. keysRotationOffsetModifierCtrl: boolean;
  51211. /**
  51212. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51213. */
  51214. keysRotationOffsetModifierShift: boolean;
  51215. /**
  51216. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51217. */
  51218. keysRadiusIncr: number[];
  51219. /**
  51220. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51221. */
  51222. keysRadiusDecr: number[];
  51223. /**
  51224. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51225. */
  51226. keysRadiusModifierAlt: boolean;
  51227. /**
  51228. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51229. */
  51230. keysRadiusModifierCtrl: boolean;
  51231. /**
  51232. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51233. */
  51234. keysRadiusModifierShift: boolean;
  51235. /**
  51236. * Defines the rate of change of heightOffset.
  51237. */
  51238. heightSensibility: number;
  51239. /**
  51240. * Defines the rate of change of rotationOffset.
  51241. */
  51242. rotationSensibility: number;
  51243. /**
  51244. * Defines the rate of change of radius.
  51245. */
  51246. radiusSensibility: number;
  51247. private _keys;
  51248. private _ctrlPressed;
  51249. private _altPressed;
  51250. private _shiftPressed;
  51251. private _onCanvasBlurObserver;
  51252. private _onKeyboardObserver;
  51253. private _engine;
  51254. private _scene;
  51255. /**
  51256. * Attach the input controls to a specific dom element to get the input from.
  51257. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51258. */
  51259. attachControl(noPreventDefault?: boolean): void;
  51260. /**
  51261. * Detach the current controls from the specified dom element.
  51262. */
  51263. detachControl(): void;
  51264. /**
  51265. * Update the current camera state depending on the inputs that have been used this frame.
  51266. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51267. */
  51268. checkInputs(): void;
  51269. /**
  51270. * Gets the class name of the current input.
  51271. * @returns the class name
  51272. */
  51273. getClassName(): string;
  51274. /**
  51275. * Get the friendly name associated with the input class.
  51276. * @returns the input friendly name
  51277. */
  51278. getSimpleName(): string;
  51279. /**
  51280. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51281. * allow modification of the heightOffset value.
  51282. */
  51283. private _modifierHeightOffset;
  51284. /**
  51285. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51286. * allow modification of the rotationOffset value.
  51287. */
  51288. private _modifierRotationOffset;
  51289. /**
  51290. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51291. * allow modification of the radius value.
  51292. */
  51293. private _modifierRadius;
  51294. }
  51295. }
  51296. declare module BABYLON {
  51297. interface FreeCameraInputsManager {
  51298. /**
  51299. * @hidden
  51300. */
  51301. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  51302. /**
  51303. * Add orientation input support to the input manager.
  51304. * @returns the current input manager
  51305. */
  51306. addDeviceOrientation(): FreeCameraInputsManager;
  51307. }
  51308. /**
  51309. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  51310. * Screen rotation is taken into account.
  51311. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51312. */
  51313. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  51314. private _camera;
  51315. private _screenOrientationAngle;
  51316. private _constantTranform;
  51317. private _screenQuaternion;
  51318. private _alpha;
  51319. private _beta;
  51320. private _gamma;
  51321. /**
  51322. * Can be used to detect if a device orientation sensor is available on a device
  51323. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  51324. * @returns a promise that will resolve on orientation change
  51325. */
  51326. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  51327. /**
  51328. * @hidden
  51329. */
  51330. _onDeviceOrientationChangedObservable: Observable<void>;
  51331. /**
  51332. * Instantiates a new input
  51333. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51334. */
  51335. constructor();
  51336. /**
  51337. * Define the camera controlled by the input.
  51338. */
  51339. get camera(): FreeCamera;
  51340. set camera(camera: FreeCamera);
  51341. /**
  51342. * Attach the input controls to a specific dom element to get the input from.
  51343. */
  51344. attachControl(): void;
  51345. private _orientationChanged;
  51346. private _deviceOrientation;
  51347. /**
  51348. * Detach the current controls from the specified dom element.
  51349. */
  51350. detachControl(): void;
  51351. /**
  51352. * Update the current camera state depending on the inputs that have been used this frame.
  51353. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51354. */
  51355. checkInputs(): void;
  51356. /**
  51357. * Gets the class name of the current intput.
  51358. * @returns the class name
  51359. */
  51360. getClassName(): string;
  51361. /**
  51362. * Get the friendly name associated with the input class.
  51363. * @returns the input friendly name
  51364. */
  51365. getSimpleName(): string;
  51366. }
  51367. }
  51368. declare module BABYLON {
  51369. /**
  51370. * Manage the gamepad inputs to control a free camera.
  51371. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51372. */
  51373. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  51374. /**
  51375. * Define the camera the input is attached to.
  51376. */
  51377. camera: FreeCamera;
  51378. /**
  51379. * Define the Gamepad controlling the input
  51380. */
  51381. gamepad: Nullable<Gamepad>;
  51382. /**
  51383. * Defines the gamepad rotation sensiblity.
  51384. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51385. */
  51386. gamepadAngularSensibility: number;
  51387. /**
  51388. * Defines the gamepad move sensiblity.
  51389. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51390. */
  51391. gamepadMoveSensibility: number;
  51392. private _yAxisScale;
  51393. /**
  51394. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51395. */
  51396. get invertYAxis(): boolean;
  51397. set invertYAxis(value: boolean);
  51398. private _onGamepadConnectedObserver;
  51399. private _onGamepadDisconnectedObserver;
  51400. private _cameraTransform;
  51401. private _deltaTransform;
  51402. private _vector3;
  51403. private _vector2;
  51404. /**
  51405. * Attach the input controls to a specific dom element to get the input from.
  51406. */
  51407. attachControl(): void;
  51408. /**
  51409. * Detach the current controls from the specified dom element.
  51410. */
  51411. detachControl(): void;
  51412. /**
  51413. * Update the current camera state depending on the inputs that have been used this frame.
  51414. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51415. */
  51416. checkInputs(): void;
  51417. /**
  51418. * Gets the class name of the current intput.
  51419. * @returns the class name
  51420. */
  51421. getClassName(): string;
  51422. /**
  51423. * Get the friendly name associated with the input class.
  51424. * @returns the input friendly name
  51425. */
  51426. getSimpleName(): string;
  51427. }
  51428. }
  51429. declare module BABYLON {
  51430. /**
  51431. * Defines the potential axis of a Joystick
  51432. */
  51433. export enum JoystickAxis {
  51434. /** X axis */
  51435. X = 0,
  51436. /** Y axis */
  51437. Y = 1,
  51438. /** Z axis */
  51439. Z = 2
  51440. }
  51441. /**
  51442. * Represents the different customization options available
  51443. * for VirtualJoystick
  51444. */
  51445. interface VirtualJoystickCustomizations {
  51446. /**
  51447. * Size of the joystick's puck
  51448. */
  51449. puckSize: number;
  51450. /**
  51451. * Size of the joystick's container
  51452. */
  51453. containerSize: number;
  51454. /**
  51455. * Color of the joystick && puck
  51456. */
  51457. color: string;
  51458. /**
  51459. * Image URL for the joystick's puck
  51460. */
  51461. puckImage?: string;
  51462. /**
  51463. * Image URL for the joystick's container
  51464. */
  51465. containerImage?: string;
  51466. /**
  51467. * Defines the unmoving position of the joystick container
  51468. */
  51469. position?: {
  51470. x: number;
  51471. y: number;
  51472. };
  51473. /**
  51474. * Defines whether or not the joystick container is always visible
  51475. */
  51476. alwaysVisible: boolean;
  51477. /**
  51478. * Defines whether or not to limit the movement of the puck to the joystick's container
  51479. */
  51480. limitToContainer: boolean;
  51481. }
  51482. /**
  51483. * Class used to define virtual joystick (used in touch mode)
  51484. */
  51485. export class VirtualJoystick {
  51486. /**
  51487. * Gets or sets a boolean indicating that left and right values must be inverted
  51488. */
  51489. reverseLeftRight: boolean;
  51490. /**
  51491. * Gets or sets a boolean indicating that up and down values must be inverted
  51492. */
  51493. reverseUpDown: boolean;
  51494. /**
  51495. * Gets the offset value for the position (ie. the change of the position value)
  51496. */
  51497. deltaPosition: Vector3;
  51498. /**
  51499. * Gets a boolean indicating if the virtual joystick was pressed
  51500. */
  51501. pressed: boolean;
  51502. /**
  51503. * Canvas the virtual joystick will render onto, default z-index of this is 5
  51504. */
  51505. static Canvas: Nullable<HTMLCanvasElement>;
  51506. /**
  51507. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  51508. */
  51509. limitToContainer: boolean;
  51510. private static _globalJoystickIndex;
  51511. private static _alwaysVisibleSticks;
  51512. private static vjCanvasContext;
  51513. private static vjCanvasWidth;
  51514. private static vjCanvasHeight;
  51515. private static halfWidth;
  51516. private static _GetDefaultOptions;
  51517. private _action;
  51518. private _axisTargetedByLeftAndRight;
  51519. private _axisTargetedByUpAndDown;
  51520. private _joystickSensibility;
  51521. private _inversedSensibility;
  51522. private _joystickPointerID;
  51523. private _joystickColor;
  51524. private _joystickPointerPos;
  51525. private _joystickPreviousPointerPos;
  51526. private _joystickPointerStartPos;
  51527. private _deltaJoystickVector;
  51528. private _leftJoystick;
  51529. private _touches;
  51530. private _joystickPosition;
  51531. private _alwaysVisible;
  51532. private _puckImage;
  51533. private _containerImage;
  51534. private _joystickPuckSize;
  51535. private _joystickContainerSize;
  51536. private _clearPuckSize;
  51537. private _clearContainerSize;
  51538. private _clearPuckSizeOffset;
  51539. private _clearContainerSizeOffset;
  51540. private _onPointerDownHandlerRef;
  51541. private _onPointerMoveHandlerRef;
  51542. private _onPointerUpHandlerRef;
  51543. private _onResize;
  51544. /**
  51545. * Creates a new virtual joystick
  51546. * @param leftJoystick defines that the joystick is for left hand (false by default)
  51547. * @param customizations Defines the options we want to customize the VirtualJoystick
  51548. */
  51549. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  51550. /**
  51551. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  51552. * @param newJoystickSensibility defines the new sensibility
  51553. */
  51554. setJoystickSensibility(newJoystickSensibility: number): void;
  51555. private _onPointerDown;
  51556. private _onPointerMove;
  51557. private _onPointerUp;
  51558. /**
  51559. * Change the color of the virtual joystick
  51560. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  51561. */
  51562. setJoystickColor(newColor: string): void;
  51563. /**
  51564. * Size of the joystick's container
  51565. */
  51566. set containerSize(newSize: number);
  51567. get containerSize(): number;
  51568. /**
  51569. * Size of the joystick's puck
  51570. */
  51571. set puckSize(newSize: number);
  51572. get puckSize(): number;
  51573. /**
  51574. * Clears the set position of the joystick
  51575. */
  51576. clearPosition(): void;
  51577. /**
  51578. * Defines whether or not the joystick container is always visible
  51579. */
  51580. set alwaysVisible(value: boolean);
  51581. get alwaysVisible(): boolean;
  51582. /**
  51583. * Sets the constant position of the Joystick container
  51584. * @param x X axis coordinate
  51585. * @param y Y axis coordinate
  51586. */
  51587. setPosition(x: number, y: number): void;
  51588. /**
  51589. * Defines a callback to call when the joystick is touched
  51590. * @param action defines the callback
  51591. */
  51592. setActionOnTouch(action: () => any): void;
  51593. /**
  51594. * Defines which axis you'd like to control for left & right
  51595. * @param axis defines the axis to use
  51596. */
  51597. setAxisForLeftRight(axis: JoystickAxis): void;
  51598. /**
  51599. * Defines which axis you'd like to control for up & down
  51600. * @param axis defines the axis to use
  51601. */
  51602. setAxisForUpDown(axis: JoystickAxis): void;
  51603. /**
  51604. * Clears the canvas from the previous puck / container draw
  51605. */
  51606. private _clearPreviousDraw;
  51607. /**
  51608. * Loads `urlPath` to be used for the container's image
  51609. * @param urlPath defines the urlPath of an image to use
  51610. */
  51611. setContainerImage(urlPath: string): void;
  51612. /**
  51613. * Loads `urlPath` to be used for the puck's image
  51614. * @param urlPath defines the urlPath of an image to use
  51615. */
  51616. setPuckImage(urlPath: string): void;
  51617. /**
  51618. * Draws the Virtual Joystick's container
  51619. */
  51620. private _drawContainer;
  51621. /**
  51622. * Draws the Virtual Joystick's puck
  51623. */
  51624. private _drawPuck;
  51625. private _drawVirtualJoystick;
  51626. /**
  51627. * Release internal HTML canvas
  51628. */
  51629. releaseCanvas(): void;
  51630. }
  51631. }
  51632. declare module BABYLON {
  51633. interface FreeCameraInputsManager {
  51634. /**
  51635. * Add virtual joystick input support to the input manager.
  51636. * @returns the current input manager
  51637. */
  51638. addVirtualJoystick(): FreeCameraInputsManager;
  51639. }
  51640. /**
  51641. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  51642. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51643. */
  51644. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  51645. /**
  51646. * Defines the camera the input is attached to.
  51647. */
  51648. camera: FreeCamera;
  51649. private _leftjoystick;
  51650. private _rightjoystick;
  51651. /**
  51652. * Gets the left stick of the virtual joystick.
  51653. * @returns The virtual Joystick
  51654. */
  51655. getLeftJoystick(): VirtualJoystick;
  51656. /**
  51657. * Gets the right stick of the virtual joystick.
  51658. * @returns The virtual Joystick
  51659. */
  51660. getRightJoystick(): VirtualJoystick;
  51661. /**
  51662. * Update the current camera state depending on the inputs that have been used this frame.
  51663. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51664. */
  51665. checkInputs(): void;
  51666. /**
  51667. * Attach the input controls to a specific dom element to get the input from.
  51668. */
  51669. attachControl(): void;
  51670. /**
  51671. * Detach the current controls from the specified dom element.
  51672. */
  51673. detachControl(): void;
  51674. /**
  51675. * Gets the class name of the current intput.
  51676. * @returns the class name
  51677. */
  51678. getClassName(): string;
  51679. /**
  51680. * Get the friendly name associated with the input class.
  51681. * @returns the input friendly name
  51682. */
  51683. getSimpleName(): string;
  51684. }
  51685. }
  51686. declare module BABYLON {
  51687. /**
  51688. * This represents a FPS type of camera controlled by touch.
  51689. * This is like a universal camera minus the Gamepad controls.
  51690. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51691. */
  51692. export class TouchCamera extends FreeCamera {
  51693. /**
  51694. * Defines the touch sensibility for rotation.
  51695. * The higher the faster.
  51696. */
  51697. get touchAngularSensibility(): number;
  51698. set touchAngularSensibility(value: number);
  51699. /**
  51700. * Defines the touch sensibility for move.
  51701. * The higher the faster.
  51702. */
  51703. get touchMoveSensibility(): number;
  51704. set touchMoveSensibility(value: number);
  51705. /**
  51706. * Instantiates a new touch camera.
  51707. * This represents a FPS type of camera controlled by touch.
  51708. * This is like a universal camera minus the Gamepad controls.
  51709. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51710. * @param name Define the name of the camera in the scene
  51711. * @param position Define the start position of the camera in the scene
  51712. * @param scene Define the scene the camera belongs to
  51713. */
  51714. constructor(name: string, position: Vector3, scene: Scene);
  51715. /**
  51716. * Gets the current object class name.
  51717. * @return the class name
  51718. */
  51719. getClassName(): string;
  51720. /** @hidden */
  51721. _setupInputs(): void;
  51722. }
  51723. }
  51724. declare module BABYLON {
  51725. /**
  51726. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  51727. * being tilted forward or back and left or right.
  51728. */
  51729. export class DeviceOrientationCamera extends FreeCamera {
  51730. private _initialQuaternion;
  51731. private _quaternionCache;
  51732. private _tmpDragQuaternion;
  51733. private _disablePointerInputWhenUsingDeviceOrientation;
  51734. /**
  51735. * Creates a new device orientation camera
  51736. * @param name The name of the camera
  51737. * @param position The start position camera
  51738. * @param scene The scene the camera belongs to
  51739. */
  51740. constructor(name: string, position: Vector3, scene: Scene);
  51741. /**
  51742. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  51743. */
  51744. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  51745. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  51746. private _dragFactor;
  51747. /**
  51748. * Enabled turning on the y axis when the orientation sensor is active
  51749. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  51750. */
  51751. enableHorizontalDragging(dragFactor?: number): void;
  51752. /**
  51753. * Gets the current instance class name ("DeviceOrientationCamera").
  51754. * This helps avoiding instanceof at run time.
  51755. * @returns the class name
  51756. */
  51757. getClassName(): string;
  51758. /**
  51759. * @hidden
  51760. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  51761. */
  51762. _checkInputs(): void;
  51763. /**
  51764. * Reset the camera to its default orientation on the specified axis only.
  51765. * @param axis The axis to reset
  51766. */
  51767. resetToCurrentRotation(axis?: Axis): void;
  51768. }
  51769. }
  51770. declare module BABYLON {
  51771. /**
  51772. * Defines supported buttons for XBox360 compatible gamepads
  51773. */
  51774. export enum Xbox360Button {
  51775. /** A */
  51776. A = 0,
  51777. /** B */
  51778. B = 1,
  51779. /** X */
  51780. X = 2,
  51781. /** Y */
  51782. Y = 3,
  51783. /** Left button */
  51784. LB = 4,
  51785. /** Right button */
  51786. RB = 5,
  51787. /** Back */
  51788. Back = 8,
  51789. /** Start */
  51790. Start = 9,
  51791. /** Left stick */
  51792. LeftStick = 10,
  51793. /** Right stick */
  51794. RightStick = 11
  51795. }
  51796. /** Defines values for XBox360 DPad */
  51797. export enum Xbox360Dpad {
  51798. /** Up */
  51799. Up = 12,
  51800. /** Down */
  51801. Down = 13,
  51802. /** Left */
  51803. Left = 14,
  51804. /** Right */
  51805. Right = 15
  51806. }
  51807. /**
  51808. * Defines a XBox360 gamepad
  51809. */
  51810. export class Xbox360Pad extends Gamepad {
  51811. private _leftTrigger;
  51812. private _rightTrigger;
  51813. private _onlefttriggerchanged;
  51814. private _onrighttriggerchanged;
  51815. private _onbuttondown;
  51816. private _onbuttonup;
  51817. private _ondpaddown;
  51818. private _ondpadup;
  51819. /** Observable raised when a button is pressed */
  51820. onButtonDownObservable: Observable<Xbox360Button>;
  51821. /** Observable raised when a button is released */
  51822. onButtonUpObservable: Observable<Xbox360Button>;
  51823. /** Observable raised when a pad is pressed */
  51824. onPadDownObservable: Observable<Xbox360Dpad>;
  51825. /** Observable raised when a pad is released */
  51826. onPadUpObservable: Observable<Xbox360Dpad>;
  51827. private _buttonA;
  51828. private _buttonB;
  51829. private _buttonX;
  51830. private _buttonY;
  51831. private _buttonBack;
  51832. private _buttonStart;
  51833. private _buttonLB;
  51834. private _buttonRB;
  51835. private _buttonLeftStick;
  51836. private _buttonRightStick;
  51837. private _dPadUp;
  51838. private _dPadDown;
  51839. private _dPadLeft;
  51840. private _dPadRight;
  51841. private _isXboxOnePad;
  51842. /**
  51843. * Creates a new XBox360 gamepad object
  51844. * @param id defines the id of this gamepad
  51845. * @param index defines its index
  51846. * @param gamepad defines the internal HTML gamepad object
  51847. * @param xboxOne defines if it is a XBox One gamepad
  51848. */
  51849. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  51850. /**
  51851. * Defines the callback to call when left trigger is pressed
  51852. * @param callback defines the callback to use
  51853. */
  51854. onlefttriggerchanged(callback: (value: number) => void): void;
  51855. /**
  51856. * Defines the callback to call when right trigger is pressed
  51857. * @param callback defines the callback to use
  51858. */
  51859. onrighttriggerchanged(callback: (value: number) => void): void;
  51860. /**
  51861. * Gets the left trigger value
  51862. */
  51863. get leftTrigger(): number;
  51864. /**
  51865. * Sets the left trigger value
  51866. */
  51867. set leftTrigger(newValue: number);
  51868. /**
  51869. * Gets the right trigger value
  51870. */
  51871. get rightTrigger(): number;
  51872. /**
  51873. * Sets the right trigger value
  51874. */
  51875. set rightTrigger(newValue: number);
  51876. /**
  51877. * Defines the callback to call when a button is pressed
  51878. * @param callback defines the callback to use
  51879. */
  51880. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  51881. /**
  51882. * Defines the callback to call when a button is released
  51883. * @param callback defines the callback to use
  51884. */
  51885. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  51886. /**
  51887. * Defines the callback to call when a pad is pressed
  51888. * @param callback defines the callback to use
  51889. */
  51890. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  51891. /**
  51892. * Defines the callback to call when a pad is released
  51893. * @param callback defines the callback to use
  51894. */
  51895. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  51896. private _setButtonValue;
  51897. private _setDPadValue;
  51898. /**
  51899. * Gets the value of the `A` button
  51900. */
  51901. get buttonA(): number;
  51902. /**
  51903. * Sets the value of the `A` button
  51904. */
  51905. set buttonA(value: number);
  51906. /**
  51907. * Gets the value of the `B` button
  51908. */
  51909. get buttonB(): number;
  51910. /**
  51911. * Sets the value of the `B` button
  51912. */
  51913. set buttonB(value: number);
  51914. /**
  51915. * Gets the value of the `X` button
  51916. */
  51917. get buttonX(): number;
  51918. /**
  51919. * Sets the value of the `X` button
  51920. */
  51921. set buttonX(value: number);
  51922. /**
  51923. * Gets the value of the `Y` button
  51924. */
  51925. get buttonY(): number;
  51926. /**
  51927. * Sets the value of the `Y` button
  51928. */
  51929. set buttonY(value: number);
  51930. /**
  51931. * Gets the value of the `Start` button
  51932. */
  51933. get buttonStart(): number;
  51934. /**
  51935. * Sets the value of the `Start` button
  51936. */
  51937. set buttonStart(value: number);
  51938. /**
  51939. * Gets the value of the `Back` button
  51940. */
  51941. get buttonBack(): number;
  51942. /**
  51943. * Sets the value of the `Back` button
  51944. */
  51945. set buttonBack(value: number);
  51946. /**
  51947. * Gets the value of the `Left` button
  51948. */
  51949. get buttonLB(): number;
  51950. /**
  51951. * Sets the value of the `Left` button
  51952. */
  51953. set buttonLB(value: number);
  51954. /**
  51955. * Gets the value of the `Right` button
  51956. */
  51957. get buttonRB(): number;
  51958. /**
  51959. * Sets the value of the `Right` button
  51960. */
  51961. set buttonRB(value: number);
  51962. /**
  51963. * Gets the value of the Left joystick
  51964. */
  51965. get buttonLeftStick(): number;
  51966. /**
  51967. * Sets the value of the Left joystick
  51968. */
  51969. set buttonLeftStick(value: number);
  51970. /**
  51971. * Gets the value of the Right joystick
  51972. */
  51973. get buttonRightStick(): number;
  51974. /**
  51975. * Sets the value of the Right joystick
  51976. */
  51977. set buttonRightStick(value: number);
  51978. /**
  51979. * Gets the value of D-pad up
  51980. */
  51981. get dPadUp(): number;
  51982. /**
  51983. * Sets the value of D-pad up
  51984. */
  51985. set dPadUp(value: number);
  51986. /**
  51987. * Gets the value of D-pad down
  51988. */
  51989. get dPadDown(): number;
  51990. /**
  51991. * Sets the value of D-pad down
  51992. */
  51993. set dPadDown(value: number);
  51994. /**
  51995. * Gets the value of D-pad left
  51996. */
  51997. get dPadLeft(): number;
  51998. /**
  51999. * Sets the value of D-pad left
  52000. */
  52001. set dPadLeft(value: number);
  52002. /**
  52003. * Gets the value of D-pad right
  52004. */
  52005. get dPadRight(): number;
  52006. /**
  52007. * Sets the value of D-pad right
  52008. */
  52009. set dPadRight(value: number);
  52010. /**
  52011. * Force the gamepad to synchronize with device values
  52012. */
  52013. update(): void;
  52014. /**
  52015. * Disposes the gamepad
  52016. */
  52017. dispose(): void;
  52018. }
  52019. }
  52020. declare module BABYLON {
  52021. /**
  52022. * Defines supported buttons for DualShock compatible gamepads
  52023. */
  52024. export enum DualShockButton {
  52025. /** Cross */
  52026. Cross = 0,
  52027. /** Circle */
  52028. Circle = 1,
  52029. /** Square */
  52030. Square = 2,
  52031. /** Triangle */
  52032. Triangle = 3,
  52033. /** L1 */
  52034. L1 = 4,
  52035. /** R1 */
  52036. R1 = 5,
  52037. /** Share */
  52038. Share = 8,
  52039. /** Options */
  52040. Options = 9,
  52041. /** Left stick */
  52042. LeftStick = 10,
  52043. /** Right stick */
  52044. RightStick = 11
  52045. }
  52046. /** Defines values for DualShock DPad */
  52047. export enum DualShockDpad {
  52048. /** Up */
  52049. Up = 12,
  52050. /** Down */
  52051. Down = 13,
  52052. /** Left */
  52053. Left = 14,
  52054. /** Right */
  52055. Right = 15
  52056. }
  52057. /**
  52058. * Defines a DualShock gamepad
  52059. */
  52060. export class DualShockPad extends Gamepad {
  52061. private _leftTrigger;
  52062. private _rightTrigger;
  52063. private _onlefttriggerchanged;
  52064. private _onrighttriggerchanged;
  52065. private _onbuttondown;
  52066. private _onbuttonup;
  52067. private _ondpaddown;
  52068. private _ondpadup;
  52069. /** Observable raised when a button is pressed */
  52070. onButtonDownObservable: Observable<DualShockButton>;
  52071. /** Observable raised when a button is released */
  52072. onButtonUpObservable: Observable<DualShockButton>;
  52073. /** Observable raised when a pad is pressed */
  52074. onPadDownObservable: Observable<DualShockDpad>;
  52075. /** Observable raised when a pad is released */
  52076. onPadUpObservable: Observable<DualShockDpad>;
  52077. private _buttonCross;
  52078. private _buttonCircle;
  52079. private _buttonSquare;
  52080. private _buttonTriangle;
  52081. private _buttonShare;
  52082. private _buttonOptions;
  52083. private _buttonL1;
  52084. private _buttonR1;
  52085. private _buttonLeftStick;
  52086. private _buttonRightStick;
  52087. private _dPadUp;
  52088. private _dPadDown;
  52089. private _dPadLeft;
  52090. private _dPadRight;
  52091. /**
  52092. * Creates a new DualShock gamepad object
  52093. * @param id defines the id of this gamepad
  52094. * @param index defines its index
  52095. * @param gamepad defines the internal HTML gamepad object
  52096. */
  52097. constructor(id: string, index: number, gamepad: any);
  52098. /**
  52099. * Defines the callback to call when left trigger is pressed
  52100. * @param callback defines the callback to use
  52101. */
  52102. onlefttriggerchanged(callback: (value: number) => void): void;
  52103. /**
  52104. * Defines the callback to call when right trigger is pressed
  52105. * @param callback defines the callback to use
  52106. */
  52107. onrighttriggerchanged(callback: (value: number) => void): void;
  52108. /**
  52109. * Gets the left trigger value
  52110. */
  52111. get leftTrigger(): number;
  52112. /**
  52113. * Sets the left trigger value
  52114. */
  52115. set leftTrigger(newValue: number);
  52116. /**
  52117. * Gets the right trigger value
  52118. */
  52119. get rightTrigger(): number;
  52120. /**
  52121. * Sets the right trigger value
  52122. */
  52123. set rightTrigger(newValue: number);
  52124. /**
  52125. * Defines the callback to call when a button is pressed
  52126. * @param callback defines the callback to use
  52127. */
  52128. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52129. /**
  52130. * Defines the callback to call when a button is released
  52131. * @param callback defines the callback to use
  52132. */
  52133. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52134. /**
  52135. * Defines the callback to call when a pad is pressed
  52136. * @param callback defines the callback to use
  52137. */
  52138. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52139. /**
  52140. * Defines the callback to call when a pad is released
  52141. * @param callback defines the callback to use
  52142. */
  52143. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52144. private _setButtonValue;
  52145. private _setDPadValue;
  52146. /**
  52147. * Gets the value of the `Cross` button
  52148. */
  52149. get buttonCross(): number;
  52150. /**
  52151. * Sets the value of the `Cross` button
  52152. */
  52153. set buttonCross(value: number);
  52154. /**
  52155. * Gets the value of the `Circle` button
  52156. */
  52157. get buttonCircle(): number;
  52158. /**
  52159. * Sets the value of the `Circle` button
  52160. */
  52161. set buttonCircle(value: number);
  52162. /**
  52163. * Gets the value of the `Square` button
  52164. */
  52165. get buttonSquare(): number;
  52166. /**
  52167. * Sets the value of the `Square` button
  52168. */
  52169. set buttonSquare(value: number);
  52170. /**
  52171. * Gets the value of the `Triangle` button
  52172. */
  52173. get buttonTriangle(): number;
  52174. /**
  52175. * Sets the value of the `Triangle` button
  52176. */
  52177. set buttonTriangle(value: number);
  52178. /**
  52179. * Gets the value of the `Options` button
  52180. */
  52181. get buttonOptions(): number;
  52182. /**
  52183. * Sets the value of the `Options` button
  52184. */
  52185. set buttonOptions(value: number);
  52186. /**
  52187. * Gets the value of the `Share` button
  52188. */
  52189. get buttonShare(): number;
  52190. /**
  52191. * Sets the value of the `Share` button
  52192. */
  52193. set buttonShare(value: number);
  52194. /**
  52195. * Gets the value of the `L1` button
  52196. */
  52197. get buttonL1(): number;
  52198. /**
  52199. * Sets the value of the `L1` button
  52200. */
  52201. set buttonL1(value: number);
  52202. /**
  52203. * Gets the value of the `R1` button
  52204. */
  52205. get buttonR1(): number;
  52206. /**
  52207. * Sets the value of the `R1` button
  52208. */
  52209. set buttonR1(value: number);
  52210. /**
  52211. * Gets the value of the Left joystick
  52212. */
  52213. get buttonLeftStick(): number;
  52214. /**
  52215. * Sets the value of the Left joystick
  52216. */
  52217. set buttonLeftStick(value: number);
  52218. /**
  52219. * Gets the value of the Right joystick
  52220. */
  52221. get buttonRightStick(): number;
  52222. /**
  52223. * Sets the value of the Right joystick
  52224. */
  52225. set buttonRightStick(value: number);
  52226. /**
  52227. * Gets the value of D-pad up
  52228. */
  52229. get dPadUp(): number;
  52230. /**
  52231. * Sets the value of D-pad up
  52232. */
  52233. set dPadUp(value: number);
  52234. /**
  52235. * Gets the value of D-pad down
  52236. */
  52237. get dPadDown(): number;
  52238. /**
  52239. * Sets the value of D-pad down
  52240. */
  52241. set dPadDown(value: number);
  52242. /**
  52243. * Gets the value of D-pad left
  52244. */
  52245. get dPadLeft(): number;
  52246. /**
  52247. * Sets the value of D-pad left
  52248. */
  52249. set dPadLeft(value: number);
  52250. /**
  52251. * Gets the value of D-pad right
  52252. */
  52253. get dPadRight(): number;
  52254. /**
  52255. * Sets the value of D-pad right
  52256. */
  52257. set dPadRight(value: number);
  52258. /**
  52259. * Force the gamepad to synchronize with device values
  52260. */
  52261. update(): void;
  52262. /**
  52263. * Disposes the gamepad
  52264. */
  52265. dispose(): void;
  52266. }
  52267. }
  52268. declare module BABYLON {
  52269. /**
  52270. * Manager for handling gamepads
  52271. */
  52272. export class GamepadManager {
  52273. private _scene?;
  52274. private _babylonGamepads;
  52275. private _oneGamepadConnected;
  52276. /** @hidden */
  52277. _isMonitoring: boolean;
  52278. private _gamepadEventSupported;
  52279. private _gamepadSupport?;
  52280. /**
  52281. * observable to be triggered when the gamepad controller has been connected
  52282. */
  52283. onGamepadConnectedObservable: Observable<Gamepad>;
  52284. /**
  52285. * observable to be triggered when the gamepad controller has been disconnected
  52286. */
  52287. onGamepadDisconnectedObservable: Observable<Gamepad>;
  52288. private _onGamepadConnectedEvent;
  52289. private _onGamepadDisconnectedEvent;
  52290. /**
  52291. * Initializes the gamepad manager
  52292. * @param _scene BabylonJS scene
  52293. */
  52294. constructor(_scene?: Scene | undefined);
  52295. /**
  52296. * The gamepads in the game pad manager
  52297. */
  52298. get gamepads(): Gamepad[];
  52299. /**
  52300. * Get the gamepad controllers based on type
  52301. * @param type The type of gamepad controller
  52302. * @returns Nullable gamepad
  52303. */
  52304. getGamepadByType(type?: number): Nullable<Gamepad>;
  52305. /**
  52306. * Disposes the gamepad manager
  52307. */
  52308. dispose(): void;
  52309. private _addNewGamepad;
  52310. private _startMonitoringGamepads;
  52311. private _stopMonitoringGamepads;
  52312. /** @hidden */
  52313. _checkGamepadsStatus(): void;
  52314. private _updateGamepadObjects;
  52315. }
  52316. }
  52317. declare module BABYLON {
  52318. interface Scene {
  52319. /** @hidden */
  52320. _gamepadManager: Nullable<GamepadManager>;
  52321. /**
  52322. * Gets the gamepad manager associated with the scene
  52323. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  52324. */
  52325. gamepadManager: GamepadManager;
  52326. }
  52327. /**
  52328. * Interface representing a free camera inputs manager
  52329. */
  52330. interface FreeCameraInputsManager {
  52331. /**
  52332. * Adds gamepad input support to the FreeCameraInputsManager.
  52333. * @returns the FreeCameraInputsManager
  52334. */
  52335. addGamepad(): FreeCameraInputsManager;
  52336. }
  52337. /**
  52338. * Interface representing an arc rotate camera inputs manager
  52339. */
  52340. interface ArcRotateCameraInputsManager {
  52341. /**
  52342. * Adds gamepad input support to the ArcRotateCamera InputManager.
  52343. * @returns the camera inputs manager
  52344. */
  52345. addGamepad(): ArcRotateCameraInputsManager;
  52346. }
  52347. /**
  52348. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  52349. */
  52350. export class GamepadSystemSceneComponent implements ISceneComponent {
  52351. /**
  52352. * The component name helpfull to identify the component in the list of scene components.
  52353. */
  52354. readonly name: string;
  52355. /**
  52356. * The scene the component belongs to.
  52357. */
  52358. scene: Scene;
  52359. /**
  52360. * Creates a new instance of the component for the given scene
  52361. * @param scene Defines the scene to register the component in
  52362. */
  52363. constructor(scene: Scene);
  52364. /**
  52365. * Registers the component in a given scene
  52366. */
  52367. register(): void;
  52368. /**
  52369. * Rebuilds the elements related to this component in case of
  52370. * context lost for instance.
  52371. */
  52372. rebuild(): void;
  52373. /**
  52374. * Disposes the component and the associated ressources
  52375. */
  52376. dispose(): void;
  52377. private _beforeCameraUpdate;
  52378. }
  52379. }
  52380. declare module BABYLON {
  52381. /**
  52382. * 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,
  52383. * which still works and will still be found in many Playgrounds.
  52384. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52385. */
  52386. export class UniversalCamera extends TouchCamera {
  52387. /**
  52388. * Defines the gamepad rotation sensiblity.
  52389. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52390. */
  52391. get gamepadAngularSensibility(): number;
  52392. set gamepadAngularSensibility(value: number);
  52393. /**
  52394. * Defines the gamepad move sensiblity.
  52395. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52396. */
  52397. get gamepadMoveSensibility(): number;
  52398. set gamepadMoveSensibility(value: number);
  52399. /**
  52400. * 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,
  52401. * which still works and will still be found in many Playgrounds.
  52402. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52403. * @param name Define the name of the camera in the scene
  52404. * @param position Define the start position of the camera in the scene
  52405. * @param scene Define the scene the camera belongs to
  52406. */
  52407. constructor(name: string, position: Vector3, scene: Scene);
  52408. /**
  52409. * Gets the current object class name.
  52410. * @return the class name
  52411. */
  52412. getClassName(): string;
  52413. }
  52414. }
  52415. declare module BABYLON {
  52416. /**
  52417. * This represents a FPS type of camera. This is only here for back compat purpose.
  52418. * Please use the UniversalCamera instead as both are identical.
  52419. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52420. */
  52421. export class GamepadCamera extends UniversalCamera {
  52422. /**
  52423. * Instantiates a new Gamepad Camera
  52424. * This represents a FPS type of camera. This is only here for back compat purpose.
  52425. * Please use the UniversalCamera instead as both are identical.
  52426. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52427. * @param name Define the name of the camera in the scene
  52428. * @param position Define the start position of the camera in the scene
  52429. * @param scene Define the scene the camera belongs to
  52430. */
  52431. constructor(name: string, position: Vector3, scene: Scene);
  52432. /**
  52433. * Gets the current object class name.
  52434. * @return the class name
  52435. */
  52436. getClassName(): string;
  52437. }
  52438. }
  52439. declare module BABYLON {
  52440. /** @hidden */
  52441. export var anaglyphPixelShader: {
  52442. name: string;
  52443. shader: string;
  52444. };
  52445. }
  52446. declare module BABYLON {
  52447. /**
  52448. * Postprocess used to generate anaglyphic rendering
  52449. */
  52450. export class AnaglyphPostProcess extends PostProcess {
  52451. private _passedProcess;
  52452. /**
  52453. * Gets a string identifying the name of the class
  52454. * @returns "AnaglyphPostProcess" string
  52455. */
  52456. getClassName(): string;
  52457. /**
  52458. * Creates a new AnaglyphPostProcess
  52459. * @param name defines postprocess name
  52460. * @param options defines creation options or target ratio scale
  52461. * @param rigCameras defines cameras using this postprocess
  52462. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  52463. * @param engine defines hosting engine
  52464. * @param reusable defines if the postprocess will be reused multiple times per frame
  52465. */
  52466. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  52467. }
  52468. }
  52469. declare module BABYLON {
  52470. /**
  52471. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  52472. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52473. */
  52474. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  52475. /**
  52476. * Creates a new AnaglyphArcRotateCamera
  52477. * @param name defines camera name
  52478. * @param alpha defines alpha angle (in radians)
  52479. * @param beta defines beta angle (in radians)
  52480. * @param radius defines radius
  52481. * @param target defines camera target
  52482. * @param interaxialDistance defines distance between each color axis
  52483. * @param scene defines the hosting scene
  52484. */
  52485. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  52486. /**
  52487. * Gets camera class name
  52488. * @returns AnaglyphArcRotateCamera
  52489. */
  52490. getClassName(): string;
  52491. }
  52492. }
  52493. declare module BABYLON {
  52494. /**
  52495. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  52496. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52497. */
  52498. export class AnaglyphFreeCamera extends FreeCamera {
  52499. /**
  52500. * Creates a new AnaglyphFreeCamera
  52501. * @param name defines camera name
  52502. * @param position defines initial position
  52503. * @param interaxialDistance defines distance between each color axis
  52504. * @param scene defines the hosting scene
  52505. */
  52506. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52507. /**
  52508. * Gets camera class name
  52509. * @returns AnaglyphFreeCamera
  52510. */
  52511. getClassName(): string;
  52512. }
  52513. }
  52514. declare module BABYLON {
  52515. /**
  52516. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  52517. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52518. */
  52519. export class AnaglyphGamepadCamera extends GamepadCamera {
  52520. /**
  52521. * Creates a new AnaglyphGamepadCamera
  52522. * @param name defines camera name
  52523. * @param position defines initial position
  52524. * @param interaxialDistance defines distance between each color axis
  52525. * @param scene defines the hosting scene
  52526. */
  52527. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52528. /**
  52529. * Gets camera class name
  52530. * @returns AnaglyphGamepadCamera
  52531. */
  52532. getClassName(): string;
  52533. }
  52534. }
  52535. declare module BABYLON {
  52536. /**
  52537. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  52538. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52539. */
  52540. export class AnaglyphUniversalCamera extends UniversalCamera {
  52541. /**
  52542. * Creates a new AnaglyphUniversalCamera
  52543. * @param name defines camera name
  52544. * @param position defines initial position
  52545. * @param interaxialDistance defines distance between each color axis
  52546. * @param scene defines the hosting scene
  52547. */
  52548. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52549. /**
  52550. * Gets camera class name
  52551. * @returns AnaglyphUniversalCamera
  52552. */
  52553. getClassName(): string;
  52554. }
  52555. }
  52556. declare module BABYLON {
  52557. /**
  52558. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  52559. * @see https://doc.babylonjs.com/features/cameras
  52560. */
  52561. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  52562. /**
  52563. * Creates a new StereoscopicArcRotateCamera
  52564. * @param name defines camera name
  52565. * @param alpha defines alpha angle (in radians)
  52566. * @param beta defines beta angle (in radians)
  52567. * @param radius defines radius
  52568. * @param target defines camera target
  52569. * @param interaxialDistance defines distance between each color axis
  52570. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52571. * @param scene defines the hosting scene
  52572. */
  52573. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52574. /**
  52575. * Gets camera class name
  52576. * @returns StereoscopicArcRotateCamera
  52577. */
  52578. getClassName(): string;
  52579. }
  52580. }
  52581. declare module BABYLON {
  52582. /**
  52583. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  52584. * @see https://doc.babylonjs.com/features/cameras
  52585. */
  52586. export class StereoscopicFreeCamera extends FreeCamera {
  52587. /**
  52588. * Creates a new StereoscopicFreeCamera
  52589. * @param name defines camera name
  52590. * @param position defines initial position
  52591. * @param interaxialDistance defines distance between each color axis
  52592. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52593. * @param scene defines the hosting scene
  52594. */
  52595. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52596. /**
  52597. * Gets camera class name
  52598. * @returns StereoscopicFreeCamera
  52599. */
  52600. getClassName(): string;
  52601. }
  52602. }
  52603. declare module BABYLON {
  52604. /**
  52605. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  52606. * @see https://doc.babylonjs.com/features/cameras
  52607. */
  52608. export class StereoscopicGamepadCamera extends GamepadCamera {
  52609. /**
  52610. * Creates a new StereoscopicGamepadCamera
  52611. * @param name defines camera name
  52612. * @param position defines initial position
  52613. * @param interaxialDistance defines distance between each color axis
  52614. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52615. * @param scene defines the hosting scene
  52616. */
  52617. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52618. /**
  52619. * Gets camera class name
  52620. * @returns StereoscopicGamepadCamera
  52621. */
  52622. getClassName(): string;
  52623. }
  52624. }
  52625. declare module BABYLON {
  52626. /**
  52627. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  52628. * @see https://doc.babylonjs.com/features/cameras
  52629. */
  52630. export class StereoscopicUniversalCamera extends UniversalCamera {
  52631. /**
  52632. * Creates a new StereoscopicUniversalCamera
  52633. * @param name defines camera name
  52634. * @param position defines initial position
  52635. * @param interaxialDistance defines distance between each color axis
  52636. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52637. * @param scene defines the hosting scene
  52638. */
  52639. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52640. /**
  52641. * Gets camera class name
  52642. * @returns StereoscopicUniversalCamera
  52643. */
  52644. getClassName(): string;
  52645. }
  52646. }
  52647. declare module BABYLON {
  52648. /**
  52649. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  52650. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52651. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52652. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52653. */
  52654. export class VirtualJoysticksCamera extends FreeCamera {
  52655. /**
  52656. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  52657. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52658. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52659. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52660. * @param name Define the name of the camera in the scene
  52661. * @param position Define the start position of the camera in the scene
  52662. * @param scene Define the scene the camera belongs to
  52663. */
  52664. constructor(name: string, position: Vector3, scene: Scene);
  52665. /**
  52666. * Gets the current object class name.
  52667. * @return the class name
  52668. */
  52669. getClassName(): string;
  52670. }
  52671. }
  52672. declare module BABYLON {
  52673. /**
  52674. * This represents all the required metrics to create a VR camera.
  52675. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  52676. */
  52677. export class VRCameraMetrics {
  52678. /**
  52679. * Define the horizontal resolution off the screen.
  52680. */
  52681. hResolution: number;
  52682. /**
  52683. * Define the vertical resolution off the screen.
  52684. */
  52685. vResolution: number;
  52686. /**
  52687. * Define the horizontal screen size.
  52688. */
  52689. hScreenSize: number;
  52690. /**
  52691. * Define the vertical screen size.
  52692. */
  52693. vScreenSize: number;
  52694. /**
  52695. * Define the vertical screen center position.
  52696. */
  52697. vScreenCenter: number;
  52698. /**
  52699. * Define the distance of the eyes to the screen.
  52700. */
  52701. eyeToScreenDistance: number;
  52702. /**
  52703. * Define the distance between both lenses
  52704. */
  52705. lensSeparationDistance: number;
  52706. /**
  52707. * Define the distance between both viewer's eyes.
  52708. */
  52709. interpupillaryDistance: number;
  52710. /**
  52711. * Define the distortion factor of the VR postprocess.
  52712. * Please, touch with care.
  52713. */
  52714. distortionK: number[];
  52715. /**
  52716. * Define the chromatic aberration correction factors for the VR post process.
  52717. */
  52718. chromaAbCorrection: number[];
  52719. /**
  52720. * Define the scale factor of the post process.
  52721. * The smaller the better but the slower.
  52722. */
  52723. postProcessScaleFactor: number;
  52724. /**
  52725. * Define an offset for the lens center.
  52726. */
  52727. lensCenterOffset: number;
  52728. /**
  52729. * Define if the current vr camera should compensate the distortion of the lense or not.
  52730. */
  52731. compensateDistortion: boolean;
  52732. /**
  52733. * Defines if multiview should be enabled when rendering (Default: false)
  52734. */
  52735. multiviewEnabled: boolean;
  52736. /**
  52737. * Gets the rendering aspect ratio based on the provided resolutions.
  52738. */
  52739. get aspectRatio(): number;
  52740. /**
  52741. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  52742. */
  52743. get aspectRatioFov(): number;
  52744. /**
  52745. * @hidden
  52746. */
  52747. get leftHMatrix(): Matrix;
  52748. /**
  52749. * @hidden
  52750. */
  52751. get rightHMatrix(): Matrix;
  52752. /**
  52753. * @hidden
  52754. */
  52755. get leftPreViewMatrix(): Matrix;
  52756. /**
  52757. * @hidden
  52758. */
  52759. get rightPreViewMatrix(): Matrix;
  52760. /**
  52761. * Get the default VRMetrics based on the most generic setup.
  52762. * @returns the default vr metrics
  52763. */
  52764. static GetDefault(): VRCameraMetrics;
  52765. }
  52766. }
  52767. declare module BABYLON {
  52768. /** @hidden */
  52769. export var vrDistortionCorrectionPixelShader: {
  52770. name: string;
  52771. shader: string;
  52772. };
  52773. }
  52774. declare module BABYLON {
  52775. /**
  52776. * VRDistortionCorrectionPostProcess used for mobile VR
  52777. */
  52778. export class VRDistortionCorrectionPostProcess extends PostProcess {
  52779. private _isRightEye;
  52780. private _distortionFactors;
  52781. private _postProcessScaleFactor;
  52782. private _lensCenterOffset;
  52783. private _scaleIn;
  52784. private _scaleFactor;
  52785. private _lensCenter;
  52786. /**
  52787. * Gets a string identifying the name of the class
  52788. * @returns "VRDistortionCorrectionPostProcess" string
  52789. */
  52790. getClassName(): string;
  52791. /**
  52792. * Initializes the VRDistortionCorrectionPostProcess
  52793. * @param name The name of the effect.
  52794. * @param camera The camera to apply the render pass to.
  52795. * @param isRightEye If this is for the right eye distortion
  52796. * @param vrMetrics All the required metrics for the VR camera
  52797. */
  52798. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  52799. }
  52800. }
  52801. declare module BABYLON {
  52802. /**
  52803. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  52804. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52805. */
  52806. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  52807. /**
  52808. * Creates a new VRDeviceOrientationArcRotateCamera
  52809. * @param name defines camera name
  52810. * @param alpha defines the camera rotation along the logitudinal axis
  52811. * @param beta defines the camera rotation along the latitudinal axis
  52812. * @param radius defines the camera distance from its target
  52813. * @param target defines the camera target
  52814. * @param scene defines the scene the camera belongs to
  52815. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52816. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52817. */
  52818. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52819. /**
  52820. * Gets camera class name
  52821. * @returns VRDeviceOrientationArcRotateCamera
  52822. */
  52823. getClassName(): string;
  52824. }
  52825. }
  52826. declare module BABYLON {
  52827. /**
  52828. * Camera used to simulate VR rendering (based on FreeCamera)
  52829. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52830. */
  52831. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  52832. /**
  52833. * Creates a new VRDeviceOrientationFreeCamera
  52834. * @param name defines camera name
  52835. * @param position defines the start position of the camera
  52836. * @param scene defines the scene the camera belongs to
  52837. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52838. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52839. */
  52840. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52841. /**
  52842. * Gets camera class name
  52843. * @returns VRDeviceOrientationFreeCamera
  52844. */
  52845. getClassName(): string;
  52846. }
  52847. }
  52848. declare module BABYLON {
  52849. /**
  52850. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  52851. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52852. */
  52853. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  52854. /**
  52855. * Creates a new VRDeviceOrientationGamepadCamera
  52856. * @param name defines camera name
  52857. * @param position defines the start position of the camera
  52858. * @param scene defines the scene the camera belongs to
  52859. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52860. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52861. */
  52862. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52863. /**
  52864. * Gets camera class name
  52865. * @returns VRDeviceOrientationGamepadCamera
  52866. */
  52867. getClassName(): string;
  52868. }
  52869. }
  52870. declare module BABYLON {
  52871. /**
  52872. * A class extending Texture allowing drawing on a texture
  52873. * @see https://doc.babylonjs.com/how_to/dynamictexture
  52874. */
  52875. export class DynamicTexture extends Texture {
  52876. private _generateMipMaps;
  52877. private _canvas;
  52878. private _context;
  52879. /**
  52880. * Creates a DynamicTexture
  52881. * @param name defines the name of the texture
  52882. * @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
  52883. * @param scene defines the scene where you want the texture
  52884. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  52885. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52886. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  52887. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  52888. */
  52889. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  52890. /**
  52891. * Get the current class name of the texture useful for serialization or dynamic coding.
  52892. * @returns "DynamicTexture"
  52893. */
  52894. getClassName(): string;
  52895. /**
  52896. * Gets the current state of canRescale
  52897. */
  52898. get canRescale(): boolean;
  52899. private _recreate;
  52900. /**
  52901. * Scales the texture
  52902. * @param ratio the scale factor to apply to both width and height
  52903. */
  52904. scale(ratio: number): void;
  52905. /**
  52906. * Resizes the texture
  52907. * @param width the new width
  52908. * @param height the new height
  52909. */
  52910. scaleTo(width: number, height: number): void;
  52911. /**
  52912. * Gets the context of the canvas used by the texture
  52913. * @returns the canvas context of the dynamic texture
  52914. */
  52915. getContext(): CanvasRenderingContext2D;
  52916. /**
  52917. * Clears the texture
  52918. */
  52919. clear(): void;
  52920. /**
  52921. * Updates the texture
  52922. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52923. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  52924. */
  52925. update(invertY?: boolean, premulAlpha?: boolean): void;
  52926. /**
  52927. * Draws text onto the texture
  52928. * @param text defines the text to be drawn
  52929. * @param x defines the placement of the text from the left
  52930. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  52931. * @param font defines the font to be used with font-style, font-size, font-name
  52932. * @param color defines the color used for the text
  52933. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  52934. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  52935. * @param update defines whether texture is immediately update (default is true)
  52936. */
  52937. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  52938. /**
  52939. * Clones the texture
  52940. * @returns the clone of the texture.
  52941. */
  52942. clone(): DynamicTexture;
  52943. /**
  52944. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  52945. * @returns a serialized dynamic texture object
  52946. */
  52947. serialize(): any;
  52948. private _IsCanvasElement;
  52949. /** @hidden */
  52950. _rebuild(): void;
  52951. }
  52952. }
  52953. declare module BABYLON {
  52954. /**
  52955. * Class containing static functions to help procedurally build meshes
  52956. */
  52957. export class GroundBuilder {
  52958. /**
  52959. * Creates a ground mesh
  52960. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52961. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52963. * @param name defines the name of the mesh
  52964. * @param options defines the options used to create the mesh
  52965. * @param scene defines the hosting scene
  52966. * @returns the ground mesh
  52967. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52968. */
  52969. static CreateGround(name: string, options: {
  52970. width?: number;
  52971. height?: number;
  52972. subdivisions?: number;
  52973. subdivisionsX?: number;
  52974. subdivisionsY?: number;
  52975. updatable?: boolean;
  52976. }, scene: any): Mesh;
  52977. /**
  52978. * Creates a tiled ground mesh
  52979. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52980. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52981. * * 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
  52982. * * 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
  52983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52984. * @param name defines the name of the mesh
  52985. * @param options defines the options used to create the mesh
  52986. * @param scene defines the hosting scene
  52987. * @returns the tiled ground mesh
  52988. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52989. */
  52990. static CreateTiledGround(name: string, options: {
  52991. xmin: number;
  52992. zmin: number;
  52993. xmax: number;
  52994. zmax: number;
  52995. subdivisions?: {
  52996. w: number;
  52997. h: number;
  52998. };
  52999. precision?: {
  53000. w: number;
  53001. h: number;
  53002. };
  53003. updatable?: boolean;
  53004. }, scene?: Nullable<Scene>): Mesh;
  53005. /**
  53006. * Creates a ground mesh from a height map
  53007. * * The parameter `url` sets the URL of the height map image resource.
  53008. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53009. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53010. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53011. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53012. * * 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.
  53013. * * 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).
  53014. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53016. * @param name defines the name of the mesh
  53017. * @param url defines the url to the height map
  53018. * @param options defines the options used to create the mesh
  53019. * @param scene defines the hosting scene
  53020. * @returns the ground mesh
  53021. * @see https://doc.babylonjs.com/babylon101/height_map
  53022. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53023. */
  53024. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53025. width?: number;
  53026. height?: number;
  53027. subdivisions?: number;
  53028. minHeight?: number;
  53029. maxHeight?: number;
  53030. colorFilter?: Color3;
  53031. alphaFilter?: number;
  53032. updatable?: boolean;
  53033. onReady?: (mesh: GroundMesh) => void;
  53034. }, scene?: Nullable<Scene>): GroundMesh;
  53035. }
  53036. }
  53037. declare module BABYLON {
  53038. /**
  53039. * Class containing static functions to help procedurally build meshes
  53040. */
  53041. export class TorusBuilder {
  53042. /**
  53043. * Creates a torus mesh
  53044. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53045. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53046. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53047. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53048. * * 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
  53049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53050. * @param name defines the name of the mesh
  53051. * @param options defines the options used to create the mesh
  53052. * @param scene defines the hosting scene
  53053. * @returns the torus mesh
  53054. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53055. */
  53056. static CreateTorus(name: string, options: {
  53057. diameter?: number;
  53058. thickness?: number;
  53059. tessellation?: number;
  53060. updatable?: boolean;
  53061. sideOrientation?: number;
  53062. frontUVs?: Vector4;
  53063. backUVs?: Vector4;
  53064. }, scene: any): Mesh;
  53065. }
  53066. }
  53067. declare module BABYLON {
  53068. /**
  53069. * Class containing static functions to help procedurally build meshes
  53070. */
  53071. export class CylinderBuilder {
  53072. /**
  53073. * Creates a cylinder or a cone mesh
  53074. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53075. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53076. * * 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.
  53077. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53078. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53079. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53080. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53081. * * 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).
  53082. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53083. * * 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).
  53084. * * 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
  53085. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53086. * * 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
  53087. * * 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.
  53088. * * If `enclose` is false, a ring surface is one element.
  53089. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53090. * * 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
  53091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53092. * * 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
  53093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53094. * @param name defines the name of the mesh
  53095. * @param options defines the options used to create the mesh
  53096. * @param scene defines the hosting scene
  53097. * @returns the cylinder mesh
  53098. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53099. */
  53100. static CreateCylinder(name: string, options: {
  53101. height?: number;
  53102. diameterTop?: number;
  53103. diameterBottom?: number;
  53104. diameter?: number;
  53105. tessellation?: number;
  53106. subdivisions?: number;
  53107. arc?: number;
  53108. faceColors?: Color4[];
  53109. faceUV?: Vector4[];
  53110. updatable?: boolean;
  53111. hasRings?: boolean;
  53112. enclose?: boolean;
  53113. cap?: number;
  53114. sideOrientation?: number;
  53115. frontUVs?: Vector4;
  53116. backUVs?: Vector4;
  53117. }, scene: any): Mesh;
  53118. }
  53119. }
  53120. declare module BABYLON {
  53121. /**
  53122. * States of the webXR experience
  53123. */
  53124. export enum WebXRState {
  53125. /**
  53126. * Transitioning to being in XR mode
  53127. */
  53128. ENTERING_XR = 0,
  53129. /**
  53130. * Transitioning to non XR mode
  53131. */
  53132. EXITING_XR = 1,
  53133. /**
  53134. * In XR mode and presenting
  53135. */
  53136. IN_XR = 2,
  53137. /**
  53138. * Not entered XR mode
  53139. */
  53140. NOT_IN_XR = 3
  53141. }
  53142. /**
  53143. * The state of the XR camera's tracking
  53144. */
  53145. export enum WebXRTrackingState {
  53146. /**
  53147. * No transformation received, device is not being tracked
  53148. */
  53149. NOT_TRACKING = 0,
  53150. /**
  53151. * Tracking lost - using emulated position
  53152. */
  53153. TRACKING_LOST = 1,
  53154. /**
  53155. * Transformation tracking works normally
  53156. */
  53157. TRACKING = 2
  53158. }
  53159. /**
  53160. * Abstraction of the XR render target
  53161. */
  53162. export interface WebXRRenderTarget extends IDisposable {
  53163. /**
  53164. * xrpresent context of the canvas which can be used to display/mirror xr content
  53165. */
  53166. canvasContext: WebGLRenderingContext;
  53167. /**
  53168. * xr layer for the canvas
  53169. */
  53170. xrLayer: Nullable<XRWebGLLayer>;
  53171. /**
  53172. * Initializes the xr layer for the session
  53173. * @param xrSession xr session
  53174. * @returns a promise that will resolve once the XR Layer has been created
  53175. */
  53176. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53177. }
  53178. }
  53179. declare module BABYLON {
  53180. /**
  53181. * COnfiguration object for WebXR output canvas
  53182. */
  53183. export class WebXRManagedOutputCanvasOptions {
  53184. /**
  53185. * An optional canvas in case you wish to create it yourself and provide it here.
  53186. * If not provided, a new canvas will be created
  53187. */
  53188. canvasElement?: HTMLCanvasElement;
  53189. /**
  53190. * Options for this XR Layer output
  53191. */
  53192. canvasOptions?: XRWebGLLayerInit;
  53193. /**
  53194. * CSS styling for a newly created canvas (if not provided)
  53195. */
  53196. newCanvasCssStyle?: string;
  53197. /**
  53198. * Get the default values of the configuration object
  53199. * @param engine defines the engine to use (can be null)
  53200. * @returns default values of this configuration object
  53201. */
  53202. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53203. }
  53204. /**
  53205. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53206. */
  53207. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53208. private _options;
  53209. private _canvas;
  53210. private _engine;
  53211. private _originalCanvasSize;
  53212. /**
  53213. * Rendering context of the canvas which can be used to display/mirror xr content
  53214. */
  53215. canvasContext: WebGLRenderingContext;
  53216. /**
  53217. * xr layer for the canvas
  53218. */
  53219. xrLayer: Nullable<XRWebGLLayer>;
  53220. /**
  53221. * Obseervers registered here will be triggered when the xr layer was initialized
  53222. */
  53223. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  53224. /**
  53225. * Initializes the canvas to be added/removed upon entering/exiting xr
  53226. * @param _xrSessionManager The XR Session manager
  53227. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  53228. */
  53229. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  53230. /**
  53231. * Disposes of the object
  53232. */
  53233. dispose(): void;
  53234. /**
  53235. * Initializes the xr layer for the session
  53236. * @param xrSession xr session
  53237. * @returns a promise that will resolve once the XR Layer has been created
  53238. */
  53239. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53240. private _addCanvas;
  53241. private _removeCanvas;
  53242. private _setCanvasSize;
  53243. private _setManagedOutputCanvas;
  53244. }
  53245. }
  53246. declare module BABYLON {
  53247. /**
  53248. * Manages an XRSession to work with Babylon's engine
  53249. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  53250. */
  53251. export class WebXRSessionManager implements IDisposable {
  53252. /** The scene which the session should be created for */
  53253. scene: Scene;
  53254. private _referenceSpace;
  53255. private _rttProvider;
  53256. private _sessionEnded;
  53257. private _xrNavigator;
  53258. private baseLayer;
  53259. /**
  53260. * The base reference space from which the session started. good if you want to reset your
  53261. * reference space
  53262. */
  53263. baseReferenceSpace: XRReferenceSpace;
  53264. /**
  53265. * Current XR frame
  53266. */
  53267. currentFrame: Nullable<XRFrame>;
  53268. /** WebXR timestamp updated every frame */
  53269. currentTimestamp: number;
  53270. /**
  53271. * Used just in case of a failure to initialize an immersive session.
  53272. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  53273. */
  53274. defaultHeightCompensation: number;
  53275. /**
  53276. * Fires every time a new xrFrame arrives which can be used to update the camera
  53277. */
  53278. onXRFrameObservable: Observable<XRFrame>;
  53279. /**
  53280. * Fires when the reference space changed
  53281. */
  53282. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  53283. /**
  53284. * Fires when the xr session is ended either by the device or manually done
  53285. */
  53286. onXRSessionEnded: Observable<any>;
  53287. /**
  53288. * Fires when the xr session is ended either by the device or manually done
  53289. */
  53290. onXRSessionInit: Observable<XRSession>;
  53291. /**
  53292. * Underlying xr session
  53293. */
  53294. session: XRSession;
  53295. /**
  53296. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  53297. * or get the offset the player is currently at.
  53298. */
  53299. viewerReferenceSpace: XRReferenceSpace;
  53300. /**
  53301. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  53302. * @param scene The scene which the session should be created for
  53303. */
  53304. constructor(
  53305. /** The scene which the session should be created for */
  53306. scene: Scene);
  53307. /**
  53308. * The current reference space used in this session. This reference space can constantly change!
  53309. * It is mainly used to offset the camera's position.
  53310. */
  53311. get referenceSpace(): XRReferenceSpace;
  53312. /**
  53313. * Set a new reference space and triggers the observable
  53314. */
  53315. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  53316. /**
  53317. * Disposes of the session manager
  53318. */
  53319. dispose(): void;
  53320. /**
  53321. * Stops the xrSession and restores the render loop
  53322. * @returns Promise which resolves after it exits XR
  53323. */
  53324. exitXRAsync(): Promise<void>;
  53325. /**
  53326. * Gets the correct render target texture to be rendered this frame for this eye
  53327. * @param eye the eye for which to get the render target
  53328. * @returns the render target for the specified eye
  53329. */
  53330. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  53331. /**
  53332. * Creates a WebXRRenderTarget object for the XR session
  53333. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  53334. * @param options optional options to provide when creating a new render target
  53335. * @returns a WebXR render target to which the session can render
  53336. */
  53337. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  53338. /**
  53339. * Initializes the manager
  53340. * After initialization enterXR can be called to start an XR session
  53341. * @returns Promise which resolves after it is initialized
  53342. */
  53343. initializeAsync(): Promise<void>;
  53344. /**
  53345. * Initializes an xr session
  53346. * @param xrSessionMode mode to initialize
  53347. * @param xrSessionInit defines optional and required values to pass to the session builder
  53348. * @returns a promise which will resolve once the session has been initialized
  53349. */
  53350. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  53351. /**
  53352. * Checks if a session would be supported for the creation options specified
  53353. * @param sessionMode session mode to check if supported eg. immersive-vr
  53354. * @returns A Promise that resolves to true if supported and false if not
  53355. */
  53356. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53357. /**
  53358. * Resets the reference space to the one started the session
  53359. */
  53360. resetReferenceSpace(): void;
  53361. /**
  53362. * Starts rendering to the xr layer
  53363. */
  53364. runXRRenderLoop(): void;
  53365. /**
  53366. * Sets the reference space on the xr session
  53367. * @param referenceSpaceType space to set
  53368. * @returns a promise that will resolve once the reference space has been set
  53369. */
  53370. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  53371. /**
  53372. * Updates the render state of the session
  53373. * @param state state to set
  53374. * @returns a promise that resolves once the render state has been updated
  53375. */
  53376. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  53377. /**
  53378. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  53379. * @param sessionMode defines the session to test
  53380. * @returns a promise with boolean as final value
  53381. */
  53382. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53383. /**
  53384. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  53385. */
  53386. get isNative(): boolean;
  53387. private _createRenderTargetTexture;
  53388. }
  53389. }
  53390. declare module BABYLON {
  53391. /**
  53392. * WebXR Camera which holds the views for the xrSession
  53393. * @see https://doc.babylonjs.com/how_to/webxr_camera
  53394. */
  53395. export class WebXRCamera extends FreeCamera {
  53396. private _xrSessionManager;
  53397. private _firstFrame;
  53398. private _referenceQuaternion;
  53399. private _referencedPosition;
  53400. private _xrInvPositionCache;
  53401. private _xrInvQuaternionCache;
  53402. private _trackingState;
  53403. /**
  53404. * Observable raised before camera teleportation
  53405. */
  53406. onBeforeCameraTeleport: Observable<Vector3>;
  53407. /**
  53408. * Observable raised after camera teleportation
  53409. */
  53410. onAfterCameraTeleport: Observable<Vector3>;
  53411. /**
  53412. * Notifies when the camera's tracking state has changed.
  53413. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  53414. */
  53415. onTrackingStateChanged: Observable<WebXRTrackingState>;
  53416. /**
  53417. * Should position compensation execute on first frame.
  53418. * This is used when copying the position from a native (non XR) camera
  53419. */
  53420. compensateOnFirstFrame: boolean;
  53421. /**
  53422. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  53423. * @param name the name of the camera
  53424. * @param scene the scene to add the camera to
  53425. * @param _xrSessionManager a constructed xr session manager
  53426. */
  53427. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  53428. /**
  53429. * Get the current XR tracking state of the camera
  53430. */
  53431. get trackingState(): WebXRTrackingState;
  53432. private _setTrackingState;
  53433. /**
  53434. * Return the user's height, unrelated to the current ground.
  53435. * This will be the y position of this camera, when ground level is 0.
  53436. */
  53437. get realWorldHeight(): number;
  53438. /** @hidden */
  53439. _updateForDualEyeDebugging(): void;
  53440. /**
  53441. * Sets this camera's transformation based on a non-vr camera
  53442. * @param otherCamera the non-vr camera to copy the transformation from
  53443. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  53444. */
  53445. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  53446. /**
  53447. * Gets the current instance class name ("WebXRCamera").
  53448. * @returns the class name
  53449. */
  53450. getClassName(): string;
  53451. private _rotate180;
  53452. private _updateFromXRSession;
  53453. private _updateNumberOfRigCameras;
  53454. private _updateReferenceSpace;
  53455. private _updateReferenceSpaceOffset;
  53456. }
  53457. }
  53458. declare module BABYLON {
  53459. /**
  53460. * Defining the interface required for a (webxr) feature
  53461. */
  53462. export interface IWebXRFeature extends IDisposable {
  53463. /**
  53464. * Is this feature attached
  53465. */
  53466. attached: boolean;
  53467. /**
  53468. * Should auto-attach be disabled?
  53469. */
  53470. disableAutoAttach: boolean;
  53471. /**
  53472. * Attach the feature to the session
  53473. * Will usually be called by the features manager
  53474. *
  53475. * @param force should attachment be forced (even when already attached)
  53476. * @returns true if successful.
  53477. */
  53478. attach(force?: boolean): boolean;
  53479. /**
  53480. * Detach the feature from the session
  53481. * Will usually be called by the features manager
  53482. *
  53483. * @returns true if successful.
  53484. */
  53485. detach(): boolean;
  53486. /**
  53487. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53488. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53489. *
  53490. * @returns whether or not the feature is compatible in this environment
  53491. */
  53492. isCompatible(): boolean;
  53493. /**
  53494. * Was this feature disposed;
  53495. */
  53496. isDisposed: boolean;
  53497. /**
  53498. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  53499. */
  53500. xrNativeFeatureName?: string;
  53501. /**
  53502. * A list of (Babylon WebXR) features this feature depends on
  53503. */
  53504. dependsOn?: string[];
  53505. }
  53506. /**
  53507. * A list of the currently available features without referencing them
  53508. */
  53509. export class WebXRFeatureName {
  53510. /**
  53511. * The name of the anchor system feature
  53512. */
  53513. static readonly ANCHOR_SYSTEM: string;
  53514. /**
  53515. * The name of the background remover feature
  53516. */
  53517. static readonly BACKGROUND_REMOVER: string;
  53518. /**
  53519. * The name of the hit test feature
  53520. */
  53521. static readonly HIT_TEST: string;
  53522. /**
  53523. * The name of the mesh detection feature
  53524. */
  53525. static readonly MESH_DETECTION: string;
  53526. /**
  53527. * physics impostors for xr controllers feature
  53528. */
  53529. static readonly PHYSICS_CONTROLLERS: string;
  53530. /**
  53531. * The name of the plane detection feature
  53532. */
  53533. static readonly PLANE_DETECTION: string;
  53534. /**
  53535. * The name of the pointer selection feature
  53536. */
  53537. static readonly POINTER_SELECTION: string;
  53538. /**
  53539. * The name of the teleportation feature
  53540. */
  53541. static readonly TELEPORTATION: string;
  53542. /**
  53543. * The name of the feature points feature.
  53544. */
  53545. static readonly FEATURE_POINTS: string;
  53546. /**
  53547. * The name of the hand tracking feature.
  53548. */
  53549. static readonly HAND_TRACKING: string;
  53550. }
  53551. /**
  53552. * Defining the constructor of a feature. Used to register the modules.
  53553. */
  53554. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  53555. /**
  53556. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  53557. * It is mainly used in AR sessions.
  53558. *
  53559. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  53560. */
  53561. export class WebXRFeaturesManager implements IDisposable {
  53562. private _xrSessionManager;
  53563. private static readonly _AvailableFeatures;
  53564. private _features;
  53565. /**
  53566. * constructs a new features manages.
  53567. *
  53568. * @param _xrSessionManager an instance of WebXRSessionManager
  53569. */
  53570. constructor(_xrSessionManager: WebXRSessionManager);
  53571. /**
  53572. * Used to register a module. After calling this function a developer can use this feature in the scene.
  53573. * Mainly used internally.
  53574. *
  53575. * @param featureName the name of the feature to register
  53576. * @param constructorFunction the function used to construct the module
  53577. * @param version the (babylon) version of the module
  53578. * @param stable is that a stable version of this module
  53579. */
  53580. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  53581. /**
  53582. * Returns a constructor of a specific feature.
  53583. *
  53584. * @param featureName the name of the feature to construct
  53585. * @param version the version of the feature to load
  53586. * @param xrSessionManager the xrSessionManager. Used to construct the module
  53587. * @param options optional options provided to the module.
  53588. * @returns a function that, when called, will return a new instance of this feature
  53589. */
  53590. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  53591. /**
  53592. * Can be used to return the list of features currently registered
  53593. *
  53594. * @returns an Array of available features
  53595. */
  53596. static GetAvailableFeatures(): string[];
  53597. /**
  53598. * Gets the versions available for a specific feature
  53599. * @param featureName the name of the feature
  53600. * @returns an array with the available versions
  53601. */
  53602. static GetAvailableVersions(featureName: string): string[];
  53603. /**
  53604. * Return the latest unstable version of this feature
  53605. * @param featureName the name of the feature to search
  53606. * @returns the version number. if not found will return -1
  53607. */
  53608. static GetLatestVersionOfFeature(featureName: string): number;
  53609. /**
  53610. * Return the latest stable version of this feature
  53611. * @param featureName the name of the feature to search
  53612. * @returns the version number. if not found will return -1
  53613. */
  53614. static GetStableVersionOfFeature(featureName: string): number;
  53615. /**
  53616. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  53617. * Can be used during a session to start a feature
  53618. * @param featureName the name of feature to attach
  53619. */
  53620. attachFeature(featureName: string): void;
  53621. /**
  53622. * Can be used inside a session or when the session ends to detach a specific feature
  53623. * @param featureName the name of the feature to detach
  53624. */
  53625. detachFeature(featureName: string): void;
  53626. /**
  53627. * Used to disable an already-enabled feature
  53628. * The feature will be disposed and will be recreated once enabled.
  53629. * @param featureName the feature to disable
  53630. * @returns true if disable was successful
  53631. */
  53632. disableFeature(featureName: string | {
  53633. Name: string;
  53634. }): boolean;
  53635. /**
  53636. * dispose this features manager
  53637. */
  53638. dispose(): void;
  53639. /**
  53640. * 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.
  53641. * 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.
  53642. *
  53643. * @param featureName the name of the feature to load or the class of the feature
  53644. * @param version optional version to load. if not provided the latest version will be enabled
  53645. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  53646. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  53647. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  53648. * @returns a new constructed feature or throws an error if feature not found.
  53649. */
  53650. enableFeature(featureName: string | {
  53651. Name: string;
  53652. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  53653. /**
  53654. * get the implementation of an enabled feature.
  53655. * @param featureName the name of the feature to load
  53656. * @returns the feature class, if found
  53657. */
  53658. getEnabledFeature(featureName: string): IWebXRFeature;
  53659. /**
  53660. * Get the list of enabled features
  53661. * @returns an array of enabled features
  53662. */
  53663. getEnabledFeatures(): string[];
  53664. /**
  53665. * This function will exten the session creation configuration object with enabled features.
  53666. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  53667. * according to the defined "required" variable, provided during enableFeature call
  53668. * @param xrSessionInit the xr Session init object to extend
  53669. *
  53670. * @returns an extended XRSessionInit object
  53671. */
  53672. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  53673. }
  53674. }
  53675. declare module BABYLON {
  53676. /**
  53677. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  53678. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  53679. */
  53680. export class WebXRExperienceHelper implements IDisposable {
  53681. private scene;
  53682. private _nonVRCamera;
  53683. private _originalSceneAutoClear;
  53684. private _supported;
  53685. /**
  53686. * Camera used to render xr content
  53687. */
  53688. camera: WebXRCamera;
  53689. /** A features manager for this xr session */
  53690. featuresManager: WebXRFeaturesManager;
  53691. /**
  53692. * Observers registered here will be triggered after the camera's initial transformation is set
  53693. * This can be used to set a different ground level or an extra rotation.
  53694. *
  53695. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  53696. * to the position set after this observable is done executing.
  53697. */
  53698. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  53699. /**
  53700. * Fires when the state of the experience helper has changed
  53701. */
  53702. onStateChangedObservable: Observable<WebXRState>;
  53703. /** Session manager used to keep track of xr session */
  53704. sessionManager: WebXRSessionManager;
  53705. /**
  53706. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  53707. */
  53708. state: WebXRState;
  53709. /**
  53710. * Creates a WebXRExperienceHelper
  53711. * @param scene The scene the helper should be created in
  53712. */
  53713. private constructor();
  53714. /**
  53715. * Creates the experience helper
  53716. * @param scene the scene to attach the experience helper to
  53717. * @returns a promise for the experience helper
  53718. */
  53719. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  53720. /**
  53721. * Disposes of the experience helper
  53722. */
  53723. dispose(): void;
  53724. /**
  53725. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  53726. * @param sessionMode options for the XR session
  53727. * @param referenceSpaceType frame of reference of the XR session
  53728. * @param renderTarget the output canvas that will be used to enter XR mode
  53729. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  53730. * @returns promise that resolves after xr mode has entered
  53731. */
  53732. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  53733. /**
  53734. * Exits XR mode and returns the scene to its original state
  53735. * @returns promise that resolves after xr mode has exited
  53736. */
  53737. exitXRAsync(): Promise<void>;
  53738. private _nonXRToXRCamera;
  53739. private _setState;
  53740. }
  53741. }
  53742. declare module BABYLON {
  53743. /**
  53744. * X-Y values for axes in WebXR
  53745. */
  53746. export interface IWebXRMotionControllerAxesValue {
  53747. /**
  53748. * The value of the x axis
  53749. */
  53750. x: number;
  53751. /**
  53752. * The value of the y-axis
  53753. */
  53754. y: number;
  53755. }
  53756. /**
  53757. * changed / previous values for the values of this component
  53758. */
  53759. export interface IWebXRMotionControllerComponentChangesValues<T> {
  53760. /**
  53761. * current (this frame) value
  53762. */
  53763. current: T;
  53764. /**
  53765. * previous (last change) value
  53766. */
  53767. previous: T;
  53768. }
  53769. /**
  53770. * Represents changes in the component between current frame and last values recorded
  53771. */
  53772. export interface IWebXRMotionControllerComponentChanges {
  53773. /**
  53774. * will be populated with previous and current values if axes changed
  53775. */
  53776. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  53777. /**
  53778. * will be populated with previous and current values if pressed changed
  53779. */
  53780. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53781. /**
  53782. * will be populated with previous and current values if touched changed
  53783. */
  53784. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53785. /**
  53786. * will be populated with previous and current values if value changed
  53787. */
  53788. value?: IWebXRMotionControllerComponentChangesValues<number>;
  53789. }
  53790. /**
  53791. * This class represents a single component (for example button or thumbstick) of a motion controller
  53792. */
  53793. export class WebXRControllerComponent implements IDisposable {
  53794. /**
  53795. * the id of this component
  53796. */
  53797. id: string;
  53798. /**
  53799. * the type of the component
  53800. */
  53801. type: MotionControllerComponentType;
  53802. private _buttonIndex;
  53803. private _axesIndices;
  53804. private _axes;
  53805. private _changes;
  53806. private _currentValue;
  53807. private _hasChanges;
  53808. private _pressed;
  53809. private _touched;
  53810. /**
  53811. * button component type
  53812. */
  53813. static BUTTON_TYPE: MotionControllerComponentType;
  53814. /**
  53815. * squeeze component type
  53816. */
  53817. static SQUEEZE_TYPE: MotionControllerComponentType;
  53818. /**
  53819. * Thumbstick component type
  53820. */
  53821. static THUMBSTICK_TYPE: MotionControllerComponentType;
  53822. /**
  53823. * Touchpad component type
  53824. */
  53825. static TOUCHPAD_TYPE: MotionControllerComponentType;
  53826. /**
  53827. * trigger component type
  53828. */
  53829. static TRIGGER_TYPE: MotionControllerComponentType;
  53830. /**
  53831. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  53832. * the axes data changes
  53833. */
  53834. onAxisValueChangedObservable: Observable<{
  53835. x: number;
  53836. y: number;
  53837. }>;
  53838. /**
  53839. * Observers registered here will be triggered when the state of a button changes
  53840. * State change is either pressed / touched / value
  53841. */
  53842. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  53843. /**
  53844. * Creates a new component for a motion controller.
  53845. * It is created by the motion controller itself
  53846. *
  53847. * @param id the id of this component
  53848. * @param type the type of the component
  53849. * @param _buttonIndex index in the buttons array of the gamepad
  53850. * @param _axesIndices indices of the values in the axes array of the gamepad
  53851. */
  53852. constructor(
  53853. /**
  53854. * the id of this component
  53855. */
  53856. id: string,
  53857. /**
  53858. * the type of the component
  53859. */
  53860. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  53861. /**
  53862. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  53863. */
  53864. get axes(): IWebXRMotionControllerAxesValue;
  53865. /**
  53866. * Get the changes. Elements will be populated only if they changed with their previous and current value
  53867. */
  53868. get changes(): IWebXRMotionControllerComponentChanges;
  53869. /**
  53870. * Return whether or not the component changed the last frame
  53871. */
  53872. get hasChanges(): boolean;
  53873. /**
  53874. * is the button currently pressed
  53875. */
  53876. get pressed(): boolean;
  53877. /**
  53878. * is the button currently touched
  53879. */
  53880. get touched(): boolean;
  53881. /**
  53882. * Get the current value of this component
  53883. */
  53884. get value(): number;
  53885. /**
  53886. * Dispose this component
  53887. */
  53888. dispose(): void;
  53889. /**
  53890. * Are there axes correlating to this component
  53891. * @return true is axes data is available
  53892. */
  53893. isAxes(): boolean;
  53894. /**
  53895. * Is this component a button (hence - pressable)
  53896. * @returns true if can be pressed
  53897. */
  53898. isButton(): boolean;
  53899. /**
  53900. * update this component using the gamepad object it is in. Called on every frame
  53901. * @param nativeController the native gamepad controller object
  53902. */
  53903. update(nativeController: IMinimalMotionControllerObject): void;
  53904. }
  53905. }
  53906. declare module BABYLON {
  53907. /**
  53908. * Type used for the success callback of ImportMesh
  53909. */
  53910. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  53911. /**
  53912. * Interface used for the result of ImportMeshAsync
  53913. */
  53914. export interface ISceneLoaderAsyncResult {
  53915. /**
  53916. * The array of loaded meshes
  53917. */
  53918. readonly meshes: AbstractMesh[];
  53919. /**
  53920. * The array of loaded particle systems
  53921. */
  53922. readonly particleSystems: IParticleSystem[];
  53923. /**
  53924. * The array of loaded skeletons
  53925. */
  53926. readonly skeletons: Skeleton[];
  53927. /**
  53928. * The array of loaded animation groups
  53929. */
  53930. readonly animationGroups: AnimationGroup[];
  53931. /**
  53932. * The array of loaded transform nodes
  53933. */
  53934. readonly transformNodes: TransformNode[];
  53935. /**
  53936. * The array of loaded geometries
  53937. */
  53938. readonly geometries: Geometry[];
  53939. /**
  53940. * The array of loaded lights
  53941. */
  53942. readonly lights: Light[];
  53943. }
  53944. /**
  53945. * Interface used to represent data loading progression
  53946. */
  53947. export interface ISceneLoaderProgressEvent {
  53948. /**
  53949. * Defines if data length to load can be evaluated
  53950. */
  53951. readonly lengthComputable: boolean;
  53952. /**
  53953. * Defines the loaded data length
  53954. */
  53955. readonly loaded: number;
  53956. /**
  53957. * Defines the data length to load
  53958. */
  53959. readonly total: number;
  53960. }
  53961. /**
  53962. * Interface used by SceneLoader plugins to define supported file extensions
  53963. */
  53964. export interface ISceneLoaderPluginExtensions {
  53965. /**
  53966. * Defines the list of supported extensions
  53967. */
  53968. [extension: string]: {
  53969. isBinary: boolean;
  53970. };
  53971. }
  53972. /**
  53973. * Interface used by SceneLoader plugin factory
  53974. */
  53975. export interface ISceneLoaderPluginFactory {
  53976. /**
  53977. * Defines the name of the factory
  53978. */
  53979. name: string;
  53980. /**
  53981. * Function called to create a new plugin
  53982. * @return the new plugin
  53983. */
  53984. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  53985. /**
  53986. * The callback that returns true if the data can be directly loaded.
  53987. * @param data string containing the file data
  53988. * @returns if the data can be loaded directly
  53989. */
  53990. canDirectLoad?(data: string): boolean;
  53991. }
  53992. /**
  53993. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  53994. */
  53995. export interface ISceneLoaderPluginBase {
  53996. /**
  53997. * The friendly name of this plugin.
  53998. */
  53999. name: string;
  54000. /**
  54001. * The file extensions supported by this plugin.
  54002. */
  54003. extensions: string | ISceneLoaderPluginExtensions;
  54004. /**
  54005. * The callback called when loading from a url.
  54006. * @param scene scene loading this url
  54007. * @param url url to load
  54008. * @param onSuccess callback called when the file successfully loads
  54009. * @param onProgress callback called while file is loading (if the server supports this mode)
  54010. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54011. * @param onError callback called when the file fails to load
  54012. * @returns a file request object
  54013. */
  54014. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54015. /**
  54016. * The callback called when loading from a file object.
  54017. * @param scene scene loading this file
  54018. * @param file defines the file to load
  54019. * @param onSuccess defines the callback to call when data is loaded
  54020. * @param onProgress defines the callback to call during loading process
  54021. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54022. * @param onError defines the callback to call when an error occurs
  54023. * @returns a file request object
  54024. */
  54025. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54026. /**
  54027. * The callback that returns true if the data can be directly loaded.
  54028. * @param data string containing the file data
  54029. * @returns if the data can be loaded directly
  54030. */
  54031. canDirectLoad?(data: string): boolean;
  54032. /**
  54033. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54034. * @param scene scene loading this data
  54035. * @param data string containing the data
  54036. * @returns data to pass to the plugin
  54037. */
  54038. directLoad?(scene: Scene, data: string): any;
  54039. /**
  54040. * The callback that allows custom handling of the root url based on the response url.
  54041. * @param rootUrl the original root url
  54042. * @param responseURL the response url if available
  54043. * @returns the new root url
  54044. */
  54045. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54046. }
  54047. /**
  54048. * Interface used to define a SceneLoader plugin
  54049. */
  54050. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54051. /**
  54052. * Import meshes into a scene.
  54053. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54054. * @param scene The scene to import into
  54055. * @param data The data to import
  54056. * @param rootUrl The root url for scene and resources
  54057. * @param meshes The meshes array to import into
  54058. * @param particleSystems The particle systems array to import into
  54059. * @param skeletons The skeletons array to import into
  54060. * @param onError The callback when import fails
  54061. * @returns True if successful or false otherwise
  54062. */
  54063. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54064. /**
  54065. * Load into a scene.
  54066. * @param scene The scene to load into
  54067. * @param data The data to import
  54068. * @param rootUrl The root url for scene and resources
  54069. * @param onError The callback when import fails
  54070. * @returns True if successful or false otherwise
  54071. */
  54072. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54073. /**
  54074. * Load into an asset container.
  54075. * @param scene The scene to load into
  54076. * @param data The data to import
  54077. * @param rootUrl The root url for scene and resources
  54078. * @param onError The callback when import fails
  54079. * @returns The loaded asset container
  54080. */
  54081. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54082. }
  54083. /**
  54084. * Interface used to define an async SceneLoader plugin
  54085. */
  54086. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54087. /**
  54088. * Import meshes into a scene.
  54089. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54090. * @param scene The scene to import into
  54091. * @param data The data to import
  54092. * @param rootUrl The root url for scene and resources
  54093. * @param onProgress The callback when the load progresses
  54094. * @param fileName Defines the name of the file to load
  54095. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54096. */
  54097. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54098. /**
  54099. * Load into a scene.
  54100. * @param scene The scene to load into
  54101. * @param data The data to import
  54102. * @param rootUrl The root url for scene and resources
  54103. * @param onProgress The callback when the load progresses
  54104. * @param fileName Defines the name of the file to load
  54105. * @returns Nothing
  54106. */
  54107. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54108. /**
  54109. * Load into an asset container.
  54110. * @param scene The scene to load into
  54111. * @param data The data to import
  54112. * @param rootUrl The root url for scene and resources
  54113. * @param onProgress The callback when the load progresses
  54114. * @param fileName Defines the name of the file to load
  54115. * @returns The loaded asset container
  54116. */
  54117. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54118. }
  54119. /**
  54120. * Mode that determines how to handle old animation groups before loading new ones.
  54121. */
  54122. export enum SceneLoaderAnimationGroupLoadingMode {
  54123. /**
  54124. * Reset all old animations to initial state then dispose them.
  54125. */
  54126. Clean = 0,
  54127. /**
  54128. * Stop all old animations.
  54129. */
  54130. Stop = 1,
  54131. /**
  54132. * Restart old animations from first frame.
  54133. */
  54134. Sync = 2,
  54135. /**
  54136. * Old animations remains untouched.
  54137. */
  54138. NoSync = 3
  54139. }
  54140. /**
  54141. * Defines a plugin registered by the SceneLoader
  54142. */
  54143. interface IRegisteredPlugin {
  54144. /**
  54145. * Defines the plugin to use
  54146. */
  54147. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54148. /**
  54149. * Defines if the plugin supports binary data
  54150. */
  54151. isBinary: boolean;
  54152. }
  54153. /**
  54154. * Class used to load scene from various file formats using registered plugins
  54155. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54156. */
  54157. export class SceneLoader {
  54158. /**
  54159. * No logging while loading
  54160. */
  54161. static readonly NO_LOGGING: number;
  54162. /**
  54163. * Minimal logging while loading
  54164. */
  54165. static readonly MINIMAL_LOGGING: number;
  54166. /**
  54167. * Summary logging while loading
  54168. */
  54169. static readonly SUMMARY_LOGGING: number;
  54170. /**
  54171. * Detailled logging while loading
  54172. */
  54173. static readonly DETAILED_LOGGING: number;
  54174. /**
  54175. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54176. */
  54177. static get ForceFullSceneLoadingForIncremental(): boolean;
  54178. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54179. /**
  54180. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54181. */
  54182. static get ShowLoadingScreen(): boolean;
  54183. static set ShowLoadingScreen(value: boolean);
  54184. /**
  54185. * Defines the current logging level (while loading the scene)
  54186. * @ignorenaming
  54187. */
  54188. static get loggingLevel(): number;
  54189. static set loggingLevel(value: number);
  54190. /**
  54191. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54192. */
  54193. static get CleanBoneMatrixWeights(): boolean;
  54194. static set CleanBoneMatrixWeights(value: boolean);
  54195. /**
  54196. * Event raised when a plugin is used to load a scene
  54197. */
  54198. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54199. private static _registeredPlugins;
  54200. private static _showingLoadingScreen;
  54201. /**
  54202. * Gets the default plugin (used to load Babylon files)
  54203. * @returns the .babylon plugin
  54204. */
  54205. static GetDefaultPlugin(): IRegisteredPlugin;
  54206. private static _GetPluginForExtension;
  54207. private static _GetPluginForDirectLoad;
  54208. private static _GetPluginForFilename;
  54209. private static _GetDirectLoad;
  54210. private static _LoadData;
  54211. private static _GetFileInfo;
  54212. /**
  54213. * Gets a plugin that can load the given extension
  54214. * @param extension defines the extension to load
  54215. * @returns a plugin or null if none works
  54216. */
  54217. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54218. /**
  54219. * Gets a boolean indicating that the given extension can be loaded
  54220. * @param extension defines the extension to load
  54221. * @returns true if the extension is supported
  54222. */
  54223. static IsPluginForExtensionAvailable(extension: string): boolean;
  54224. /**
  54225. * Adds a new plugin to the list of registered plugins
  54226. * @param plugin defines the plugin to add
  54227. */
  54228. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  54229. /**
  54230. * Import meshes into a scene
  54231. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54232. * @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)
  54233. * @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)
  54234. * @param scene the instance of BABYLON.Scene to append to
  54235. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  54236. * @param onProgress a callback with a progress event for each file being loaded
  54237. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54238. * @param pluginExtension the extension used to determine the plugin
  54239. * @returns The loaded plugin
  54240. */
  54241. 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>;
  54242. /**
  54243. * Import meshes into a scene
  54244. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54245. * @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)
  54246. * @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)
  54247. * @param scene the instance of BABYLON.Scene to append to
  54248. * @param onProgress a callback with a progress event for each file being loaded
  54249. * @param pluginExtension the extension used to determine the plugin
  54250. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  54251. */
  54252. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  54253. /**
  54254. * Load a scene
  54255. * @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)
  54256. * @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)
  54257. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54258. * @param onSuccess a callback with the scene when import succeeds
  54259. * @param onProgress a callback with a progress event for each file being loaded
  54260. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54261. * @param pluginExtension the extension used to determine the plugin
  54262. * @returns The loaded plugin
  54263. */
  54264. 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>;
  54265. /**
  54266. * Load a scene
  54267. * @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)
  54268. * @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)
  54269. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54270. * @param onProgress a callback with a progress event for each file being loaded
  54271. * @param pluginExtension the extension used to determine the plugin
  54272. * @returns The loaded scene
  54273. */
  54274. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54275. /**
  54276. * Append a scene
  54277. * @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)
  54278. * @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)
  54279. * @param scene is the instance of BABYLON.Scene to append to
  54280. * @param onSuccess a callback with the scene when import succeeds
  54281. * @param onProgress a callback with a progress event for each file being loaded
  54282. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54283. * @param pluginExtension the extension used to determine the plugin
  54284. * @returns The loaded plugin
  54285. */
  54286. 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>;
  54287. /**
  54288. * Append a scene
  54289. * @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)
  54290. * @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)
  54291. * @param scene is the instance of BABYLON.Scene to append to
  54292. * @param onProgress a callback with a progress event for each file being loaded
  54293. * @param pluginExtension the extension used to determine the plugin
  54294. * @returns The given scene
  54295. */
  54296. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54297. /**
  54298. * Load a scene into an asset container
  54299. * @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)
  54300. * @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)
  54301. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54302. * @param onSuccess a callback with the scene when import succeeds
  54303. * @param onProgress a callback with a progress event for each file being loaded
  54304. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54305. * @param pluginExtension the extension used to determine the plugin
  54306. * @returns The loaded plugin
  54307. */
  54308. 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>;
  54309. /**
  54310. * Load a scene into an asset container
  54311. * @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)
  54312. * @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)
  54313. * @param scene is the instance of Scene to append to
  54314. * @param onProgress a callback with a progress event for each file being loaded
  54315. * @param pluginExtension the extension used to determine the plugin
  54316. * @returns The loaded asset container
  54317. */
  54318. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  54319. /**
  54320. * Import animations from a file into a scene
  54321. * @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)
  54322. * @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)
  54323. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54324. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54325. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54326. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54327. * @param onSuccess a callback with the scene when import succeeds
  54328. * @param onProgress a callback with a progress event for each file being loaded
  54329. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54330. * @param pluginExtension the extension used to determine the plugin
  54331. */
  54332. 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;
  54333. /**
  54334. * Import animations from a file into a scene
  54335. * @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)
  54336. * @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)
  54337. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54338. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54339. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54340. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54341. * @param onSuccess a callback with the scene when import succeeds
  54342. * @param onProgress a callback with a progress event for each file being loaded
  54343. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54344. * @param pluginExtension the extension used to determine the plugin
  54345. * @returns the updated scene with imported animations
  54346. */
  54347. 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>;
  54348. }
  54349. }
  54350. declare module BABYLON {
  54351. /**
  54352. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  54353. */
  54354. export type MotionControllerHandedness = "none" | "left" | "right";
  54355. /**
  54356. * The type of components available in motion controllers.
  54357. * This is not the name of the component.
  54358. */
  54359. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  54360. /**
  54361. * The state of a controller component
  54362. */
  54363. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  54364. /**
  54365. * The schema of motion controller layout.
  54366. * No object will be initialized using this interface
  54367. * This is used just to define the profile.
  54368. */
  54369. export interface IMotionControllerLayout {
  54370. /**
  54371. * Path to load the assets. Usually relative to the base path
  54372. */
  54373. assetPath: string;
  54374. /**
  54375. * Available components (unsorted)
  54376. */
  54377. components: {
  54378. /**
  54379. * A map of component Ids
  54380. */
  54381. [componentId: string]: {
  54382. /**
  54383. * The type of input the component outputs
  54384. */
  54385. type: MotionControllerComponentType;
  54386. /**
  54387. * The indices of this component in the gamepad object
  54388. */
  54389. gamepadIndices: {
  54390. /**
  54391. * Index of button
  54392. */
  54393. button?: number;
  54394. /**
  54395. * If available, index of x-axis
  54396. */
  54397. xAxis?: number;
  54398. /**
  54399. * If available, index of y-axis
  54400. */
  54401. yAxis?: number;
  54402. };
  54403. /**
  54404. * The mesh's root node name
  54405. */
  54406. rootNodeName: string;
  54407. /**
  54408. * Animation definitions for this model
  54409. */
  54410. visualResponses: {
  54411. [stateKey: string]: {
  54412. /**
  54413. * What property will be animated
  54414. */
  54415. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  54416. /**
  54417. * What states influence this visual response
  54418. */
  54419. states: MotionControllerComponentStateType[];
  54420. /**
  54421. * Type of animation - movement or visibility
  54422. */
  54423. valueNodeProperty: "transform" | "visibility";
  54424. /**
  54425. * Base node name to move. Its position will be calculated according to the min and max nodes
  54426. */
  54427. valueNodeName?: string;
  54428. /**
  54429. * Minimum movement node
  54430. */
  54431. minNodeName?: string;
  54432. /**
  54433. * Max movement node
  54434. */
  54435. maxNodeName?: string;
  54436. };
  54437. };
  54438. /**
  54439. * If touch enabled, what is the name of node to display user feedback
  54440. */
  54441. touchPointNodeName?: string;
  54442. };
  54443. };
  54444. /**
  54445. * Is it xr standard mapping or not
  54446. */
  54447. gamepadMapping: "" | "xr-standard";
  54448. /**
  54449. * Base root node of this entire model
  54450. */
  54451. rootNodeName: string;
  54452. /**
  54453. * Defines the main button component id
  54454. */
  54455. selectComponentId: string;
  54456. }
  54457. /**
  54458. * A definition for the layout map in the input profile
  54459. */
  54460. export interface IMotionControllerLayoutMap {
  54461. /**
  54462. * Layouts with handedness type as a key
  54463. */
  54464. [handedness: string]: IMotionControllerLayout;
  54465. }
  54466. /**
  54467. * The XR Input profile schema
  54468. * Profiles can be found here:
  54469. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  54470. */
  54471. export interface IMotionControllerProfile {
  54472. /**
  54473. * fallback profiles for this profileId
  54474. */
  54475. fallbackProfileIds: string[];
  54476. /**
  54477. * The layout map, with handedness as key
  54478. */
  54479. layouts: IMotionControllerLayoutMap;
  54480. /**
  54481. * The id of this profile
  54482. * correlates to the profile(s) in the xrInput.profiles array
  54483. */
  54484. profileId: string;
  54485. }
  54486. /**
  54487. * A helper-interface for the 3 meshes needed for controller button animation
  54488. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  54489. */
  54490. export interface IMotionControllerButtonMeshMap {
  54491. /**
  54492. * the mesh that defines the pressed value mesh position.
  54493. * This is used to find the max-position of this button
  54494. */
  54495. pressedMesh: AbstractMesh;
  54496. /**
  54497. * the mesh that defines the unpressed value mesh position.
  54498. * This is used to find the min (or initial) position of this button
  54499. */
  54500. unpressedMesh: AbstractMesh;
  54501. /**
  54502. * The mesh that will be changed when value changes
  54503. */
  54504. valueMesh: AbstractMesh;
  54505. }
  54506. /**
  54507. * A helper-interface for the 3 meshes needed for controller axis animation.
  54508. * This will be expanded when touchpad animations are fully supported
  54509. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  54510. */
  54511. export interface IMotionControllerMeshMap {
  54512. /**
  54513. * the mesh that defines the maximum value mesh position.
  54514. */
  54515. maxMesh?: AbstractMesh;
  54516. /**
  54517. * the mesh that defines the minimum value mesh position.
  54518. */
  54519. minMesh?: AbstractMesh;
  54520. /**
  54521. * The mesh that will be changed when axis value changes
  54522. */
  54523. valueMesh?: AbstractMesh;
  54524. }
  54525. /**
  54526. * The elements needed for change-detection of the gamepad objects in motion controllers
  54527. */
  54528. export interface IMinimalMotionControllerObject {
  54529. /**
  54530. * Available axes of this controller
  54531. */
  54532. axes: number[];
  54533. /**
  54534. * An array of available buttons
  54535. */
  54536. buttons: Array<{
  54537. /**
  54538. * Value of the button/trigger
  54539. */
  54540. value: number;
  54541. /**
  54542. * If the button/trigger is currently touched
  54543. */
  54544. touched: boolean;
  54545. /**
  54546. * If the button/trigger is currently pressed
  54547. */
  54548. pressed: boolean;
  54549. }>;
  54550. /**
  54551. * EXPERIMENTAL haptic support.
  54552. */
  54553. hapticActuators?: Array<{
  54554. pulse: (value: number, duration: number) => Promise<boolean>;
  54555. }>;
  54556. }
  54557. /**
  54558. * An Abstract Motion controller
  54559. * This class receives an xrInput and a profile layout and uses those to initialize the components
  54560. * Each component has an observable to check for changes in value and state
  54561. */
  54562. export abstract class WebXRAbstractMotionController implements IDisposable {
  54563. protected scene: Scene;
  54564. protected layout: IMotionControllerLayout;
  54565. /**
  54566. * The gamepad object correlating to this controller
  54567. */
  54568. gamepadObject: IMinimalMotionControllerObject;
  54569. /**
  54570. * handedness (left/right/none) of this controller
  54571. */
  54572. handedness: MotionControllerHandedness;
  54573. private _initComponent;
  54574. private _modelReady;
  54575. /**
  54576. * A map of components (WebXRControllerComponent) in this motion controller
  54577. * Components have a ComponentType and can also have both button and axis definitions
  54578. */
  54579. readonly components: {
  54580. [id: string]: WebXRControllerComponent;
  54581. };
  54582. /**
  54583. * Disable the model's animation. Can be set at any time.
  54584. */
  54585. disableAnimation: boolean;
  54586. /**
  54587. * Observers registered here will be triggered when the model of this controller is done loading
  54588. */
  54589. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  54590. /**
  54591. * The profile id of this motion controller
  54592. */
  54593. abstract profileId: string;
  54594. /**
  54595. * The root mesh of the model. It is null if the model was not yet initialized
  54596. */
  54597. rootMesh: Nullable<AbstractMesh>;
  54598. /**
  54599. * constructs a new abstract motion controller
  54600. * @param scene the scene to which the model of the controller will be added
  54601. * @param layout The profile layout to load
  54602. * @param gamepadObject The gamepad object correlating to this controller
  54603. * @param handedness handedness (left/right/none) of this controller
  54604. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  54605. */
  54606. constructor(scene: Scene, layout: IMotionControllerLayout,
  54607. /**
  54608. * The gamepad object correlating to this controller
  54609. */
  54610. gamepadObject: IMinimalMotionControllerObject,
  54611. /**
  54612. * handedness (left/right/none) of this controller
  54613. */
  54614. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  54615. /**
  54616. * Dispose this controller, the model mesh and all its components
  54617. */
  54618. dispose(): void;
  54619. /**
  54620. * Returns all components of specific type
  54621. * @param type the type to search for
  54622. * @return an array of components with this type
  54623. */
  54624. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  54625. /**
  54626. * get a component based an its component id as defined in layout.components
  54627. * @param id the id of the component
  54628. * @returns the component correlates to the id or undefined if not found
  54629. */
  54630. getComponent(id: string): WebXRControllerComponent;
  54631. /**
  54632. * Get the list of components available in this motion controller
  54633. * @returns an array of strings correlating to available components
  54634. */
  54635. getComponentIds(): string[];
  54636. /**
  54637. * Get the first component of specific type
  54638. * @param type type of component to find
  54639. * @return a controller component or null if not found
  54640. */
  54641. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  54642. /**
  54643. * Get the main (Select) component of this controller as defined in the layout
  54644. * @returns the main component of this controller
  54645. */
  54646. getMainComponent(): WebXRControllerComponent;
  54647. /**
  54648. * Loads the model correlating to this controller
  54649. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  54650. * @returns A promise fulfilled with the result of the model loading
  54651. */
  54652. loadModel(): Promise<boolean>;
  54653. /**
  54654. * Update this model using the current XRFrame
  54655. * @param xrFrame the current xr frame to use and update the model
  54656. */
  54657. updateFromXRFrame(xrFrame: XRFrame): void;
  54658. /**
  54659. * Backwards compatibility due to a deeply-integrated typo
  54660. */
  54661. get handness(): XREye;
  54662. /**
  54663. * Pulse (vibrate) this controller
  54664. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  54665. * Consecutive calls to this function will cancel the last pulse call
  54666. *
  54667. * @param value the strength of the pulse in 0.0...1.0 range
  54668. * @param duration Duration of the pulse in milliseconds
  54669. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  54670. * @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
  54671. */
  54672. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  54673. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54674. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54675. /**
  54676. * Moves the axis on the controller mesh based on its current state
  54677. * @param axis the index of the axis
  54678. * @param axisValue the value of the axis which determines the meshes new position
  54679. * @hidden
  54680. */
  54681. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  54682. /**
  54683. * Update the model itself with the current frame data
  54684. * @param xrFrame the frame to use for updating the model mesh
  54685. */
  54686. protected updateModel(xrFrame: XRFrame): void;
  54687. /**
  54688. * Get the filename and path for this controller's model
  54689. * @returns a map of filename and path
  54690. */
  54691. protected abstract _getFilenameAndPath(): {
  54692. filename: string;
  54693. path: string;
  54694. };
  54695. /**
  54696. * This function is called before the mesh is loaded. It checks for loading constraints.
  54697. * For example, this function can check if the GLB loader is available
  54698. * If this function returns false, the generic controller will be loaded instead
  54699. * @returns Is the client ready to load the mesh
  54700. */
  54701. protected abstract _getModelLoadingConstraints(): boolean;
  54702. /**
  54703. * This function will be called after the model was successfully loaded and can be used
  54704. * for mesh transformations before it is available for the user
  54705. * @param meshes the loaded meshes
  54706. */
  54707. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  54708. /**
  54709. * Set the root mesh for this controller. Important for the WebXR controller class
  54710. * @param meshes the loaded meshes
  54711. */
  54712. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  54713. /**
  54714. * A function executed each frame that updates the mesh (if needed)
  54715. * @param xrFrame the current xrFrame
  54716. */
  54717. protected abstract _updateModel(xrFrame: XRFrame): void;
  54718. private _getGenericFilenameAndPath;
  54719. private _getGenericParentMesh;
  54720. }
  54721. }
  54722. declare module BABYLON {
  54723. /**
  54724. * A generic trigger-only motion controller for WebXR
  54725. */
  54726. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  54727. /**
  54728. * Static version of the profile id of this controller
  54729. */
  54730. static ProfileId: string;
  54731. profileId: string;
  54732. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  54733. protected _getFilenameAndPath(): {
  54734. filename: string;
  54735. path: string;
  54736. };
  54737. protected _getModelLoadingConstraints(): boolean;
  54738. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  54739. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54740. protected _updateModel(): void;
  54741. }
  54742. }
  54743. declare module BABYLON {
  54744. /**
  54745. * Class containing static functions to help procedurally build meshes
  54746. */
  54747. export class SphereBuilder {
  54748. /**
  54749. * Creates a sphere mesh
  54750. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54751. * * 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`)
  54752. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54753. * * 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
  54754. * * 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)
  54755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54756. * * 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
  54757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54758. * @param name defines the name of the mesh
  54759. * @param options defines the options used to create the mesh
  54760. * @param scene defines the hosting scene
  54761. * @returns the sphere mesh
  54762. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54763. */
  54764. static CreateSphere(name: string, options: {
  54765. segments?: number;
  54766. diameter?: number;
  54767. diameterX?: number;
  54768. diameterY?: number;
  54769. diameterZ?: number;
  54770. arc?: number;
  54771. slice?: number;
  54772. sideOrientation?: number;
  54773. frontUVs?: Vector4;
  54774. backUVs?: Vector4;
  54775. updatable?: boolean;
  54776. }, scene?: Nullable<Scene>): Mesh;
  54777. }
  54778. }
  54779. declare module BABYLON {
  54780. /**
  54781. * A profiled motion controller has its profile loaded from an online repository.
  54782. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  54783. */
  54784. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  54785. private _repositoryUrl;
  54786. private _buttonMeshMapping;
  54787. private _touchDots;
  54788. /**
  54789. * The profile ID of this controller. Will be populated when the controller initializes.
  54790. */
  54791. profileId: string;
  54792. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  54793. dispose(): void;
  54794. protected _getFilenameAndPath(): {
  54795. filename: string;
  54796. path: string;
  54797. };
  54798. protected _getModelLoadingConstraints(): boolean;
  54799. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  54800. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54801. protected _updateModel(_xrFrame: XRFrame): void;
  54802. }
  54803. }
  54804. declare module BABYLON {
  54805. /**
  54806. * A construction function type to create a new controller based on an xrInput object
  54807. */
  54808. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  54809. /**
  54810. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  54811. *
  54812. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  54813. * it should be replaced with auto-loaded controllers.
  54814. *
  54815. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  54816. */
  54817. export class WebXRMotionControllerManager {
  54818. private static _AvailableControllers;
  54819. private static _Fallbacks;
  54820. private static _ProfileLoadingPromises;
  54821. private static _ProfilesList;
  54822. /**
  54823. * The base URL of the online controller repository. Can be changed at any time.
  54824. */
  54825. static BaseRepositoryUrl: string;
  54826. /**
  54827. * Which repository gets priority - local or online
  54828. */
  54829. static PrioritizeOnlineRepository: boolean;
  54830. /**
  54831. * Use the online repository, or use only locally-defined controllers
  54832. */
  54833. static UseOnlineRepository: boolean;
  54834. /**
  54835. * Clear the cache used for profile loading and reload when requested again
  54836. */
  54837. static ClearProfilesCache(): void;
  54838. /**
  54839. * Register the default fallbacks.
  54840. * This function is called automatically when this file is imported.
  54841. */
  54842. static DefaultFallbacks(): void;
  54843. /**
  54844. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  54845. * @param profileId the profile to which a fallback needs to be found
  54846. * @return an array with corresponding fallback profiles
  54847. */
  54848. static FindFallbackWithProfileId(profileId: string): string[];
  54849. /**
  54850. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  54851. * The order of search:
  54852. *
  54853. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  54854. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  54855. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  54856. * 4) return the generic trigger controller if none were found
  54857. *
  54858. * @param xrInput the xrInput to which a new controller is initialized
  54859. * @param scene the scene to which the model will be added
  54860. * @param forceProfile force a certain profile for this controller
  54861. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  54862. */
  54863. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  54864. /**
  54865. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  54866. *
  54867. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  54868. *
  54869. * @param type the profile type to register
  54870. * @param constructFunction the function to be called when loading this profile
  54871. */
  54872. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  54873. /**
  54874. * Register a fallback to a specific profile.
  54875. * @param profileId the profileId that will receive the fallbacks
  54876. * @param fallbacks A list of fallback profiles
  54877. */
  54878. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  54879. /**
  54880. * Will update the list of profiles available in the repository
  54881. * @return a promise that resolves to a map of profiles available online
  54882. */
  54883. static UpdateProfilesList(): Promise<{
  54884. [profile: string]: string;
  54885. }>;
  54886. private static _LoadProfileFromRepository;
  54887. private static _LoadProfilesFromAvailableControllers;
  54888. }
  54889. }
  54890. declare module BABYLON {
  54891. /**
  54892. * Configuration options for the WebXR controller creation
  54893. */
  54894. export interface IWebXRControllerOptions {
  54895. /**
  54896. * Should the controller mesh be animated when a user interacts with it
  54897. * The pressed buttons / thumbstick and touchpad animations will be disabled
  54898. */
  54899. disableMotionControllerAnimation?: boolean;
  54900. /**
  54901. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  54902. */
  54903. doNotLoadControllerMesh?: boolean;
  54904. /**
  54905. * Force a specific controller type for this controller.
  54906. * This can be used when creating your own profile or when testing different controllers
  54907. */
  54908. forceControllerProfile?: string;
  54909. /**
  54910. * Defines a rendering group ID for meshes that will be loaded.
  54911. * This is for the default controllers only.
  54912. */
  54913. renderingGroupId?: number;
  54914. }
  54915. /**
  54916. * Represents an XR controller
  54917. */
  54918. export class WebXRInputSource {
  54919. private _scene;
  54920. /** The underlying input source for the controller */
  54921. inputSource: XRInputSource;
  54922. private _options;
  54923. private _tmpVector;
  54924. private _uniqueId;
  54925. private _disposed;
  54926. /**
  54927. * 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
  54928. */
  54929. grip?: AbstractMesh;
  54930. /**
  54931. * If available, this is the gamepad object related to this controller.
  54932. * Using this object it is possible to get click events and trackpad changes of the
  54933. * webxr controller that is currently being used.
  54934. */
  54935. motionController?: WebXRAbstractMotionController;
  54936. /**
  54937. * Event that fires when the controller is removed/disposed.
  54938. * The object provided as event data is this controller, after associated assets were disposed.
  54939. * uniqueId is still available.
  54940. */
  54941. onDisposeObservable: Observable<WebXRInputSource>;
  54942. /**
  54943. * Will be triggered when the mesh associated with the motion controller is done loading.
  54944. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  54945. * A shortened version of controller -> motion controller -> on mesh loaded.
  54946. */
  54947. onMeshLoadedObservable: Observable<AbstractMesh>;
  54948. /**
  54949. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  54950. */
  54951. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  54952. /**
  54953. * Pointer which can be used to select objects or attach a visible laser to
  54954. */
  54955. pointer: AbstractMesh;
  54956. /**
  54957. * Creates the input source object
  54958. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  54959. * @param _scene the scene which the controller should be associated to
  54960. * @param inputSource the underlying input source for the controller
  54961. * @param _options options for this controller creation
  54962. */
  54963. constructor(_scene: Scene,
  54964. /** The underlying input source for the controller */
  54965. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  54966. /**
  54967. * Get this controllers unique id
  54968. */
  54969. get uniqueId(): string;
  54970. /**
  54971. * Disposes of the object
  54972. */
  54973. dispose(): void;
  54974. /**
  54975. * Gets a world space ray coming from the pointer or grip
  54976. * @param result the resulting ray
  54977. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  54978. */
  54979. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  54980. /**
  54981. * Updates the controller pose based on the given XRFrame
  54982. * @param xrFrame xr frame to update the pose with
  54983. * @param referenceSpace reference space to use
  54984. */
  54985. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  54986. }
  54987. }
  54988. declare module BABYLON {
  54989. /**
  54990. * The schema for initialization options of the XR Input class
  54991. */
  54992. export interface IWebXRInputOptions {
  54993. /**
  54994. * If set to true no model will be automatically loaded
  54995. */
  54996. doNotLoadControllerMeshes?: boolean;
  54997. /**
  54998. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  54999. * If not found, the xr input profile data will be used.
  55000. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55001. */
  55002. forceInputProfile?: string;
  55003. /**
  55004. * Do not send a request to the controller repository to load the profile.
  55005. *
  55006. * Instead, use the controllers available in babylon itself.
  55007. */
  55008. disableOnlineControllerRepository?: boolean;
  55009. /**
  55010. * A custom URL for the controllers repository
  55011. */
  55012. customControllersRepositoryURL?: string;
  55013. /**
  55014. * Should the controller model's components not move according to the user input
  55015. */
  55016. disableControllerAnimation?: boolean;
  55017. /**
  55018. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55019. */
  55020. controllerOptions?: IWebXRControllerOptions;
  55021. }
  55022. /**
  55023. * XR input used to track XR inputs such as controllers/rays
  55024. */
  55025. export class WebXRInput implements IDisposable {
  55026. /**
  55027. * the xr session manager for this session
  55028. */
  55029. xrSessionManager: WebXRSessionManager;
  55030. /**
  55031. * the WebXR camera for this session. Mainly used for teleportation
  55032. */
  55033. xrCamera: WebXRCamera;
  55034. private readonly options;
  55035. /**
  55036. * XR controllers being tracked
  55037. */
  55038. controllers: Array<WebXRInputSource>;
  55039. private _frameObserver;
  55040. private _sessionEndedObserver;
  55041. private _sessionInitObserver;
  55042. /**
  55043. * Event when a controller has been connected/added
  55044. */
  55045. onControllerAddedObservable: Observable<WebXRInputSource>;
  55046. /**
  55047. * Event when a controller has been removed/disconnected
  55048. */
  55049. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55050. /**
  55051. * Initializes the WebXRInput
  55052. * @param xrSessionManager the xr session manager for this session
  55053. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55054. * @param options = initialization options for this xr input
  55055. */
  55056. constructor(
  55057. /**
  55058. * the xr session manager for this session
  55059. */
  55060. xrSessionManager: WebXRSessionManager,
  55061. /**
  55062. * the WebXR camera for this session. Mainly used for teleportation
  55063. */
  55064. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55065. private _onInputSourcesChange;
  55066. private _addAndRemoveControllers;
  55067. /**
  55068. * Disposes of the object
  55069. */
  55070. dispose(): void;
  55071. }
  55072. }
  55073. declare module BABYLON {
  55074. /**
  55075. * This is the base class for all WebXR features.
  55076. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55077. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55078. */
  55079. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55080. protected _xrSessionManager: WebXRSessionManager;
  55081. private _attached;
  55082. private _removeOnDetach;
  55083. /**
  55084. * Is this feature disposed?
  55085. */
  55086. isDisposed: boolean;
  55087. /**
  55088. * Should auto-attach be disabled?
  55089. */
  55090. disableAutoAttach: boolean;
  55091. /**
  55092. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55093. */
  55094. xrNativeFeatureName: string;
  55095. /**
  55096. * Construct a new (abstract) WebXR feature
  55097. * @param _xrSessionManager the xr session manager for this feature
  55098. */
  55099. constructor(_xrSessionManager: WebXRSessionManager);
  55100. /**
  55101. * Is this feature attached
  55102. */
  55103. get attached(): boolean;
  55104. /**
  55105. * attach this feature
  55106. *
  55107. * @param force should attachment be forced (even when already attached)
  55108. * @returns true if successful, false is failed or already attached
  55109. */
  55110. attach(force?: boolean): boolean;
  55111. /**
  55112. * detach this feature.
  55113. *
  55114. * @returns true if successful, false if failed or already detached
  55115. */
  55116. detach(): boolean;
  55117. /**
  55118. * Dispose this feature and all of the resources attached
  55119. */
  55120. dispose(): void;
  55121. /**
  55122. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55123. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55124. *
  55125. * @returns whether or not the feature is compatible in this environment
  55126. */
  55127. isCompatible(): boolean;
  55128. /**
  55129. * This is used to register callbacks that will automatically be removed when detach is called.
  55130. * @param observable the observable to which the observer will be attached
  55131. * @param callback the callback to register
  55132. */
  55133. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55134. /**
  55135. * Code in this function will be executed on each xrFrame received from the browser.
  55136. * This function will not execute after the feature is detached.
  55137. * @param _xrFrame the current frame
  55138. */
  55139. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55140. }
  55141. }
  55142. declare module BABYLON {
  55143. /**
  55144. * Renders a layer on top of an existing scene
  55145. */
  55146. export class UtilityLayerRenderer implements IDisposable {
  55147. /** the original scene that will be rendered on top of */
  55148. originalScene: Scene;
  55149. private _pointerCaptures;
  55150. private _lastPointerEvents;
  55151. private static _DefaultUtilityLayer;
  55152. private static _DefaultKeepDepthUtilityLayer;
  55153. private _sharedGizmoLight;
  55154. private _renderCamera;
  55155. /**
  55156. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55157. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55158. * @returns the camera that is used when rendering the utility layer
  55159. */
  55160. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55161. /**
  55162. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55163. * @param cam the camera that should be used when rendering the utility layer
  55164. */
  55165. setRenderCamera(cam: Nullable<Camera>): void;
  55166. /**
  55167. * @hidden
  55168. * Light which used by gizmos to get light shading
  55169. */
  55170. _getSharedGizmoLight(): HemisphericLight;
  55171. /**
  55172. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55173. */
  55174. pickUtilitySceneFirst: boolean;
  55175. /**
  55176. * 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)
  55177. */
  55178. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55179. /**
  55180. * 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)
  55181. */
  55182. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55183. /**
  55184. * The scene that is rendered on top of the original scene
  55185. */
  55186. utilityLayerScene: Scene;
  55187. /**
  55188. * If the utility layer should automatically be rendered on top of existing scene
  55189. */
  55190. shouldRender: boolean;
  55191. /**
  55192. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55193. */
  55194. onlyCheckPointerDownEvents: boolean;
  55195. /**
  55196. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55197. */
  55198. processAllEvents: boolean;
  55199. /**
  55200. * Observable raised when the pointer move from the utility layer scene to the main scene
  55201. */
  55202. onPointerOutObservable: Observable<number>;
  55203. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55204. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55205. private _afterRenderObserver;
  55206. private _sceneDisposeObserver;
  55207. private _originalPointerObserver;
  55208. /**
  55209. * Instantiates a UtilityLayerRenderer
  55210. * @param originalScene the original scene that will be rendered on top of
  55211. * @param handleEvents boolean indicating if the utility layer should handle events
  55212. */
  55213. constructor(
  55214. /** the original scene that will be rendered on top of */
  55215. originalScene: Scene, handleEvents?: boolean);
  55216. private _notifyObservers;
  55217. /**
  55218. * Renders the utility layers scene on top of the original scene
  55219. */
  55220. render(): void;
  55221. /**
  55222. * Disposes of the renderer
  55223. */
  55224. dispose(): void;
  55225. private _updateCamera;
  55226. }
  55227. }
  55228. declare module BABYLON {
  55229. /**
  55230. * Options interface for the pointer selection module
  55231. */
  55232. export interface IWebXRControllerPointerSelectionOptions {
  55233. /**
  55234. * if provided, this scene will be used to render meshes.
  55235. */
  55236. customUtilityLayerScene?: Scene;
  55237. /**
  55238. * 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)
  55239. * If not disabled, the last picked point will be used to execute a pointer up event
  55240. * If disabled, pointer up event will be triggered right after the pointer down event.
  55241. * Used in screen and gaze target ray mode only
  55242. */
  55243. disablePointerUpOnTouchOut: boolean;
  55244. /**
  55245. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  55246. */
  55247. forceGazeMode: boolean;
  55248. /**
  55249. * 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
  55250. * to start a new countdown to the pointer down event.
  55251. * Defaults to 1.
  55252. */
  55253. gazeModePointerMovedFactor?: number;
  55254. /**
  55255. * Different button type to use instead of the main component
  55256. */
  55257. overrideButtonId?: string;
  55258. /**
  55259. * use this rendering group id for the meshes (optional)
  55260. */
  55261. renderingGroupId?: number;
  55262. /**
  55263. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  55264. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  55265. * 3000 means 3 seconds between pointing at something and selecting it
  55266. */
  55267. timeToSelect?: number;
  55268. /**
  55269. * Should meshes created here be added to a utility layer or the main scene
  55270. */
  55271. useUtilityLayer?: boolean;
  55272. /**
  55273. * Optional WebXR camera to be used for gaze selection
  55274. */
  55275. gazeCamera?: WebXRCamera;
  55276. /**
  55277. * the xr input to use with this pointer selection
  55278. */
  55279. xrInput: WebXRInput;
  55280. /**
  55281. * Should the scene pointerX and pointerY update be disabled
  55282. * This is required for fullscreen AR GUI, but might slow down other experiences.
  55283. * Disable in VR, if not needed.
  55284. * The first rig camera (left eye) will be used to calculate the projection
  55285. */
  55286. disableScenePointerVectorUpdate: boolean;
  55287. /**
  55288. * Enable pointer selection on all controllers instead of switching between them
  55289. */
  55290. enablePointerSelectionOnAllControllers?: boolean;
  55291. /**
  55292. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  55293. * If switch is enabled, it will still allow the user to switch between the different controllers
  55294. */
  55295. preferredHandedness?: XRHandedness;
  55296. /**
  55297. * Disable switching the pointer selection from one controller to the other.
  55298. * 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
  55299. */
  55300. disableSwitchOnClick?: boolean;
  55301. /**
  55302. * The maximum distance of the pointer selection feature. Defaults to 100.
  55303. */
  55304. maxPointerDistance?: number;
  55305. }
  55306. /**
  55307. * A module that will enable pointer selection for motion controllers of XR Input Sources
  55308. */
  55309. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  55310. private readonly _options;
  55311. private static _idCounter;
  55312. private _attachController;
  55313. private _controllers;
  55314. private _scene;
  55315. private _tmpVectorForPickCompare;
  55316. private _attachedController;
  55317. /**
  55318. * The module's name
  55319. */
  55320. static readonly Name: string;
  55321. /**
  55322. * The (Babylon) version of this module.
  55323. * This is an integer representing the implementation version.
  55324. * This number does not correspond to the WebXR specs version
  55325. */
  55326. static readonly Version: number;
  55327. /**
  55328. * Disable lighting on the laser pointer (so it will always be visible)
  55329. */
  55330. disablePointerLighting: boolean;
  55331. /**
  55332. * Disable lighting on the selection mesh (so it will always be visible)
  55333. */
  55334. disableSelectionMeshLighting: boolean;
  55335. /**
  55336. * Should the laser pointer be displayed
  55337. */
  55338. displayLaserPointer: boolean;
  55339. /**
  55340. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  55341. */
  55342. displaySelectionMesh: boolean;
  55343. /**
  55344. * This color will be set to the laser pointer when selection is triggered
  55345. */
  55346. laserPointerPickedColor: Color3;
  55347. /**
  55348. * Default color of the laser pointer
  55349. */
  55350. laserPointerDefaultColor: Color3;
  55351. /**
  55352. * default color of the selection ring
  55353. */
  55354. selectionMeshDefaultColor: Color3;
  55355. /**
  55356. * This color will be applied to the selection ring when selection is triggered
  55357. */
  55358. selectionMeshPickedColor: Color3;
  55359. /**
  55360. * Optional filter to be used for ray selection. This predicate shares behavior with
  55361. * scene.pointerMovePredicate which takes priority if it is also assigned.
  55362. */
  55363. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55364. /**
  55365. * constructs a new background remover module
  55366. * @param _xrSessionManager the session manager for this module
  55367. * @param _options read-only options to be used in this module
  55368. */
  55369. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  55370. /**
  55371. * attach this feature
  55372. * Will usually be called by the features manager
  55373. *
  55374. * @returns true if successful.
  55375. */
  55376. attach(): boolean;
  55377. /**
  55378. * detach this feature.
  55379. * Will usually be called by the features manager
  55380. *
  55381. * @returns true if successful.
  55382. */
  55383. detach(): boolean;
  55384. /**
  55385. * Will get the mesh under a specific pointer.
  55386. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  55387. * @param controllerId the controllerId to check
  55388. * @returns The mesh under pointer or null if no mesh is under the pointer
  55389. */
  55390. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  55391. /**
  55392. * Get the xr controller that correlates to the pointer id in the pointer event
  55393. *
  55394. * @param id the pointer id to search for
  55395. * @returns the controller that correlates to this id or null if not found
  55396. */
  55397. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  55398. private _identityMatrix;
  55399. private _screenCoordinatesRef;
  55400. private _viewportRef;
  55401. protected _onXRFrame(_xrFrame: XRFrame): void;
  55402. private _attachGazeMode;
  55403. private _attachScreenRayMode;
  55404. private _attachTrackedPointerRayMode;
  55405. private _convertNormalToDirectionOfRay;
  55406. private _detachController;
  55407. private _generateNewMeshPair;
  55408. private _pickingMoved;
  55409. private _updatePointerDistance;
  55410. /** @hidden */
  55411. get lasterPointerDefaultColor(): Color3;
  55412. }
  55413. }
  55414. declare module BABYLON {
  55415. /**
  55416. * Button which can be used to enter a different mode of XR
  55417. */
  55418. export class WebXREnterExitUIButton {
  55419. /** button element */
  55420. element: HTMLElement;
  55421. /** XR initialization options for the button */
  55422. sessionMode: XRSessionMode;
  55423. /** Reference space type */
  55424. referenceSpaceType: XRReferenceSpaceType;
  55425. /**
  55426. * Creates a WebXREnterExitUIButton
  55427. * @param element button element
  55428. * @param sessionMode XR initialization session mode
  55429. * @param referenceSpaceType the type of reference space to be used
  55430. */
  55431. constructor(
  55432. /** button element */
  55433. element: HTMLElement,
  55434. /** XR initialization options for the button */
  55435. sessionMode: XRSessionMode,
  55436. /** Reference space type */
  55437. referenceSpaceType: XRReferenceSpaceType);
  55438. /**
  55439. * Extendable function which can be used to update the button's visuals when the state changes
  55440. * @param activeButton the current active button in the UI
  55441. */
  55442. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  55443. }
  55444. /**
  55445. * Options to create the webXR UI
  55446. */
  55447. export class WebXREnterExitUIOptions {
  55448. /**
  55449. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  55450. */
  55451. customButtons?: Array<WebXREnterExitUIButton>;
  55452. /**
  55453. * A reference space type to use when creating the default button.
  55454. * Default is local-floor
  55455. */
  55456. referenceSpaceType?: XRReferenceSpaceType;
  55457. /**
  55458. * Context to enter xr with
  55459. */
  55460. renderTarget?: Nullable<WebXRRenderTarget>;
  55461. /**
  55462. * A session mode to use when creating the default button.
  55463. * Default is immersive-vr
  55464. */
  55465. sessionMode?: XRSessionMode;
  55466. /**
  55467. * A list of optional features to init the session with
  55468. */
  55469. optionalFeatures?: string[];
  55470. /**
  55471. * A list of optional features to init the session with
  55472. */
  55473. requiredFeatures?: string[];
  55474. /**
  55475. * If defined, this function will be executed if the UI encounters an error when entering XR
  55476. */
  55477. onError?: (error: any) => void;
  55478. }
  55479. /**
  55480. * UI to allow the user to enter/exit XR mode
  55481. */
  55482. export class WebXREnterExitUI implements IDisposable {
  55483. private scene;
  55484. /** version of the options passed to this UI */
  55485. options: WebXREnterExitUIOptions;
  55486. private _activeButton;
  55487. private _buttons;
  55488. /**
  55489. * The HTML Div Element to which buttons are added.
  55490. */
  55491. readonly overlay: HTMLDivElement;
  55492. /**
  55493. * Fired every time the active button is changed.
  55494. *
  55495. * When xr is entered via a button that launches xr that button will be the callback parameter
  55496. *
  55497. * When exiting xr the callback parameter will be null)
  55498. */
  55499. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  55500. /**
  55501. *
  55502. * @param scene babylon scene object to use
  55503. * @param options (read-only) version of the options passed to this UI
  55504. */
  55505. private constructor();
  55506. /**
  55507. * Creates UI to allow the user to enter/exit XR mode
  55508. * @param scene the scene to add the ui to
  55509. * @param helper the xr experience helper to enter/exit xr with
  55510. * @param options options to configure the UI
  55511. * @returns the created ui
  55512. */
  55513. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  55514. /**
  55515. * Disposes of the XR UI component
  55516. */
  55517. dispose(): void;
  55518. private _updateButtons;
  55519. }
  55520. }
  55521. declare module BABYLON {
  55522. /**
  55523. * Class containing static functions to help procedurally build meshes
  55524. */
  55525. export class LinesBuilder {
  55526. /**
  55527. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55528. * * 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
  55529. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55530. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55531. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55532. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55533. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55534. * * 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
  55535. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55538. * @param name defines the name of the new line system
  55539. * @param options defines the options used to create the line system
  55540. * @param scene defines the hosting scene
  55541. * @returns a new line system mesh
  55542. */
  55543. static CreateLineSystem(name: string, options: {
  55544. lines: Vector3[][];
  55545. updatable?: boolean;
  55546. instance?: Nullable<LinesMesh>;
  55547. colors?: Nullable<Color4[][]>;
  55548. useVertexAlpha?: boolean;
  55549. }, scene: Nullable<Scene>): LinesMesh;
  55550. /**
  55551. * Creates a line mesh
  55552. * 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
  55553. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55554. * * The parameter `points` is an array successive Vector3
  55555. * * 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
  55556. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55557. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55558. * * When updating an instance, remember that only point positions can change, not the number of points
  55559. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55561. * @param name defines the name of the new line system
  55562. * @param options defines the options used to create the line system
  55563. * @param scene defines the hosting scene
  55564. * @returns a new line mesh
  55565. */
  55566. static CreateLines(name: string, options: {
  55567. points: Vector3[];
  55568. updatable?: boolean;
  55569. instance?: Nullable<LinesMesh>;
  55570. colors?: Color4[];
  55571. useVertexAlpha?: boolean;
  55572. }, scene?: Nullable<Scene>): LinesMesh;
  55573. /**
  55574. * Creates a dashed line mesh
  55575. * * 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
  55576. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55577. * * The parameter `points` is an array successive Vector3
  55578. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55579. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55580. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55581. * * 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
  55582. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55583. * * When updating an instance, remember that only point positions can change, not the number of points
  55584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55585. * @param name defines the name of the mesh
  55586. * @param options defines the options used to create the mesh
  55587. * @param scene defines the hosting scene
  55588. * @returns the dashed line mesh
  55589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55590. */
  55591. static CreateDashedLines(name: string, options: {
  55592. points: Vector3[];
  55593. dashSize?: number;
  55594. gapSize?: number;
  55595. dashNb?: number;
  55596. updatable?: boolean;
  55597. instance?: LinesMesh;
  55598. useVertexAlpha?: boolean;
  55599. }, scene?: Nullable<Scene>): LinesMesh;
  55600. }
  55601. }
  55602. declare module BABYLON {
  55603. /**
  55604. * Construction options for a timer
  55605. */
  55606. export interface ITimerOptions<T> {
  55607. /**
  55608. * Time-to-end
  55609. */
  55610. timeout: number;
  55611. /**
  55612. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  55613. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  55614. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  55615. */
  55616. contextObservable: Observable<T>;
  55617. /**
  55618. * Optional parameters when adding an observer to the observable
  55619. */
  55620. observableParameters?: {
  55621. mask?: number;
  55622. insertFirst?: boolean;
  55623. scope?: any;
  55624. };
  55625. /**
  55626. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  55627. */
  55628. breakCondition?: (data?: ITimerData<T>) => boolean;
  55629. /**
  55630. * Will be triggered when the time condition has met
  55631. */
  55632. onEnded?: (data: ITimerData<any>) => void;
  55633. /**
  55634. * Will be triggered when the break condition has met (prematurely ended)
  55635. */
  55636. onAborted?: (data: ITimerData<any>) => void;
  55637. /**
  55638. * Optional function to execute on each tick (or count)
  55639. */
  55640. onTick?: (data: ITimerData<any>) => void;
  55641. }
  55642. /**
  55643. * An interface defining the data sent by the timer
  55644. */
  55645. export interface ITimerData<T> {
  55646. /**
  55647. * When did it start
  55648. */
  55649. startTime: number;
  55650. /**
  55651. * Time now
  55652. */
  55653. currentTime: number;
  55654. /**
  55655. * Time passed since started
  55656. */
  55657. deltaTime: number;
  55658. /**
  55659. * How much is completed, in [0.0...1.0].
  55660. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55661. */
  55662. completeRate: number;
  55663. /**
  55664. * What the registered observable sent in the last count
  55665. */
  55666. payload: T;
  55667. }
  55668. /**
  55669. * The current state of the timer
  55670. */
  55671. export enum TimerState {
  55672. /**
  55673. * Timer initialized, not yet started
  55674. */
  55675. INIT = 0,
  55676. /**
  55677. * Timer started and counting
  55678. */
  55679. STARTED = 1,
  55680. /**
  55681. * Timer ended (whether aborted or time reached)
  55682. */
  55683. ENDED = 2
  55684. }
  55685. /**
  55686. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55687. *
  55688. * @param options options with which to initialize this timer
  55689. */
  55690. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55691. /**
  55692. * An advanced implementation of a timer class
  55693. */
  55694. export class AdvancedTimer<T = any> implements IDisposable {
  55695. /**
  55696. * Will notify each time the timer calculates the remaining time
  55697. */
  55698. onEachCountObservable: Observable<ITimerData<T>>;
  55699. /**
  55700. * Will trigger when the timer was aborted due to the break condition
  55701. */
  55702. onTimerAbortedObservable: Observable<ITimerData<T>>;
  55703. /**
  55704. * Will trigger when the timer ended successfully
  55705. */
  55706. onTimerEndedObservable: Observable<ITimerData<T>>;
  55707. /**
  55708. * Will trigger when the timer state has changed
  55709. */
  55710. onStateChangedObservable: Observable<TimerState>;
  55711. private _observer;
  55712. private _contextObservable;
  55713. private _observableParameters;
  55714. private _startTime;
  55715. private _timer;
  55716. private _state;
  55717. private _breakCondition;
  55718. private _timeToEnd;
  55719. private _breakOnNextTick;
  55720. /**
  55721. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  55722. * @param options construction options for this advanced timer
  55723. */
  55724. constructor(options: ITimerOptions<T>);
  55725. /**
  55726. * set a breaking condition for this timer. Default is to never break during count
  55727. * @param predicate the new break condition. Returns true to break, false otherwise
  55728. */
  55729. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  55730. /**
  55731. * Reset ALL associated observables in this advanced timer
  55732. */
  55733. clearObservables(): void;
  55734. /**
  55735. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  55736. *
  55737. * @param timeToEnd how much time to measure until timer ended
  55738. */
  55739. start(timeToEnd?: number): void;
  55740. /**
  55741. * Will force a stop on the next tick.
  55742. */
  55743. stop(): void;
  55744. /**
  55745. * Dispose this timer, clearing all resources
  55746. */
  55747. dispose(): void;
  55748. private _setState;
  55749. private _tick;
  55750. private _stop;
  55751. }
  55752. }
  55753. declare module BABYLON {
  55754. /**
  55755. * The options container for the teleportation module
  55756. */
  55757. export interface IWebXRTeleportationOptions {
  55758. /**
  55759. * if provided, this scene will be used to render meshes.
  55760. */
  55761. customUtilityLayerScene?: Scene;
  55762. /**
  55763. * Values to configure the default target mesh
  55764. */
  55765. defaultTargetMeshOptions?: {
  55766. /**
  55767. * Fill color of the teleportation area
  55768. */
  55769. teleportationFillColor?: string;
  55770. /**
  55771. * Border color for the teleportation area
  55772. */
  55773. teleportationBorderColor?: string;
  55774. /**
  55775. * Disable the mesh's animation sequence
  55776. */
  55777. disableAnimation?: boolean;
  55778. /**
  55779. * Disable lighting on the material or the ring and arrow
  55780. */
  55781. disableLighting?: boolean;
  55782. /**
  55783. * Override the default material of the torus and arrow
  55784. */
  55785. torusArrowMaterial?: Material;
  55786. };
  55787. /**
  55788. * A list of meshes to use as floor meshes.
  55789. * Meshes can be added and removed after initializing the feature using the
  55790. * addFloorMesh and removeFloorMesh functions
  55791. * If empty, rotation will still work
  55792. */
  55793. floorMeshes?: AbstractMesh[];
  55794. /**
  55795. * use this rendering group id for the meshes (optional)
  55796. */
  55797. renderingGroupId?: number;
  55798. /**
  55799. * Should teleportation move only to snap points
  55800. */
  55801. snapPointsOnly?: boolean;
  55802. /**
  55803. * An array of points to which the teleportation will snap to.
  55804. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  55805. */
  55806. snapPositions?: Vector3[];
  55807. /**
  55808. * How close should the teleportation ray be in order to snap to position.
  55809. * Default to 0.8 units (meters)
  55810. */
  55811. snapToPositionRadius?: number;
  55812. /**
  55813. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  55814. * If you want to support rotation, make sure your mesh has a direction indicator.
  55815. *
  55816. * When left untouched, the default mesh will be initialized.
  55817. */
  55818. teleportationTargetMesh?: AbstractMesh;
  55819. /**
  55820. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  55821. */
  55822. timeToTeleport?: number;
  55823. /**
  55824. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  55825. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  55826. */
  55827. useMainComponentOnly?: boolean;
  55828. /**
  55829. * Should meshes created here be added to a utility layer or the main scene
  55830. */
  55831. useUtilityLayer?: boolean;
  55832. /**
  55833. * Babylon XR Input class for controller
  55834. */
  55835. xrInput: WebXRInput;
  55836. /**
  55837. * Meshes that the teleportation ray cannot go through
  55838. */
  55839. pickBlockerMeshes?: AbstractMesh[];
  55840. /**
  55841. * Should teleport work only on a specific hand?
  55842. */
  55843. forceHandedness?: XRHandedness;
  55844. /**
  55845. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  55846. */
  55847. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  55848. }
  55849. /**
  55850. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  55851. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  55852. * the input of the attached controllers.
  55853. */
  55854. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  55855. private _options;
  55856. private _controllers;
  55857. private _currentTeleportationControllerId;
  55858. private _floorMeshes;
  55859. private _quadraticBezierCurve;
  55860. private _selectionFeature;
  55861. private _snapToPositions;
  55862. private _snappedToPoint;
  55863. private _teleportationRingMaterial?;
  55864. private _tmpRay;
  55865. private _tmpVector;
  55866. private _tmpQuaternion;
  55867. /**
  55868. * The module's name
  55869. */
  55870. static readonly Name: string;
  55871. /**
  55872. * The (Babylon) version of this module.
  55873. * This is an integer representing the implementation version.
  55874. * This number does not correspond to the webxr specs version
  55875. */
  55876. static readonly Version: number;
  55877. /**
  55878. * Is movement backwards enabled
  55879. */
  55880. backwardsMovementEnabled: boolean;
  55881. /**
  55882. * Distance to travel when moving backwards
  55883. */
  55884. backwardsTeleportationDistance: number;
  55885. /**
  55886. * The distance from the user to the inspection point in the direction of the controller
  55887. * A higher number will allow the user to move further
  55888. * defaults to 5 (meters, in xr units)
  55889. */
  55890. parabolicCheckRadius: number;
  55891. /**
  55892. * Should the module support parabolic ray on top of direct ray
  55893. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  55894. * Very helpful when moving between floors / different heights
  55895. */
  55896. parabolicRayEnabled: boolean;
  55897. /**
  55898. * The second type of ray - straight line.
  55899. * Should it be enabled or should the parabolic line be the only one.
  55900. */
  55901. straightRayEnabled: boolean;
  55902. /**
  55903. * How much rotation should be applied when rotating right and left
  55904. */
  55905. rotationAngle: number;
  55906. private _rotationEnabled;
  55907. /**
  55908. * Is rotation enabled when moving forward?
  55909. * Disabling this feature will prevent the user from deciding the direction when teleporting
  55910. */
  55911. get rotationEnabled(): boolean;
  55912. /**
  55913. * Sets wether rotation is enabled or not
  55914. * @param enabled is rotation enabled when teleportation is shown
  55915. */
  55916. set rotationEnabled(enabled: boolean);
  55917. /**
  55918. * Exposes the currently set teleportation target mesh.
  55919. */
  55920. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  55921. /**
  55922. * constructs a new anchor system
  55923. * @param _xrSessionManager an instance of WebXRSessionManager
  55924. * @param _options configuration object for this feature
  55925. */
  55926. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  55927. /**
  55928. * Get the snapPointsOnly flag
  55929. */
  55930. get snapPointsOnly(): boolean;
  55931. /**
  55932. * Sets the snapPointsOnly flag
  55933. * @param snapToPoints should teleportation be exclusively to snap points
  55934. */
  55935. set snapPointsOnly(snapToPoints: boolean);
  55936. /**
  55937. * Add a new mesh to the floor meshes array
  55938. * @param mesh the mesh to use as floor mesh
  55939. */
  55940. addFloorMesh(mesh: AbstractMesh): void;
  55941. /**
  55942. * Add a new snap-to point to fix teleportation to this position
  55943. * @param newSnapPoint The new Snap-To point
  55944. */
  55945. addSnapPoint(newSnapPoint: Vector3): void;
  55946. attach(): boolean;
  55947. detach(): boolean;
  55948. dispose(): void;
  55949. /**
  55950. * Remove a mesh from the floor meshes array
  55951. * @param mesh the mesh to remove
  55952. */
  55953. removeFloorMesh(mesh: AbstractMesh): void;
  55954. /**
  55955. * Remove a mesh from the floor meshes array using its name
  55956. * @param name the mesh name to remove
  55957. */
  55958. removeFloorMeshByName(name: string): void;
  55959. /**
  55960. * 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
  55961. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  55962. * @returns was the point found and removed or not
  55963. */
  55964. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  55965. /**
  55966. * This function sets a selection feature that will be disabled when
  55967. * the forward ray is shown and will be reattached when hidden.
  55968. * This is used to remove the selection rays when moving.
  55969. * @param selectionFeature the feature to disable when forward movement is enabled
  55970. */
  55971. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  55972. protected _onXRFrame(_xrFrame: XRFrame): void;
  55973. private _attachController;
  55974. private _createDefaultTargetMesh;
  55975. private _detachController;
  55976. private _findClosestSnapPointWithRadius;
  55977. private _setTargetMeshPosition;
  55978. private _setTargetMeshVisibility;
  55979. private _showParabolicPath;
  55980. private _teleportForward;
  55981. }
  55982. }
  55983. declare module BABYLON {
  55984. /**
  55985. * Options for the default xr helper
  55986. */
  55987. export class WebXRDefaultExperienceOptions {
  55988. /**
  55989. * Enable or disable default UI to enter XR
  55990. */
  55991. disableDefaultUI?: boolean;
  55992. /**
  55993. * Should teleportation not initialize. defaults to false.
  55994. */
  55995. disableTeleportation?: boolean;
  55996. /**
  55997. * Floor meshes that will be used for teleport
  55998. */
  55999. floorMeshes?: Array<AbstractMesh>;
  56000. /**
  56001. * If set to true, the first frame will not be used to reset position
  56002. * The first frame is mainly used when copying transformation from the old camera
  56003. * Mainly used in AR
  56004. */
  56005. ignoreNativeCameraTransformation?: boolean;
  56006. /**
  56007. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56008. */
  56009. inputOptions?: IWebXRInputOptions;
  56010. /**
  56011. * optional configuration for the output canvas
  56012. */
  56013. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56014. /**
  56015. * optional UI options. This can be used among other to change session mode and reference space type
  56016. */
  56017. uiOptions?: WebXREnterExitUIOptions;
  56018. /**
  56019. * When loading teleportation and pointer select, use stable versions instead of latest.
  56020. */
  56021. useStablePlugins?: boolean;
  56022. /**
  56023. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56024. */
  56025. renderingGroupId?: number;
  56026. /**
  56027. * A list of optional features to init the session with
  56028. * If set to true, all features we support will be added
  56029. */
  56030. optionalFeatures?: boolean | string[];
  56031. }
  56032. /**
  56033. * Default experience which provides a similar setup to the previous webVRExperience
  56034. */
  56035. export class WebXRDefaultExperience {
  56036. /**
  56037. * Base experience
  56038. */
  56039. baseExperience: WebXRExperienceHelper;
  56040. /**
  56041. * Enables ui for entering/exiting xr
  56042. */
  56043. enterExitUI: WebXREnterExitUI;
  56044. /**
  56045. * Input experience extension
  56046. */
  56047. input: WebXRInput;
  56048. /**
  56049. * Enables laser pointer and selection
  56050. */
  56051. pointerSelection: WebXRControllerPointerSelection;
  56052. /**
  56053. * Default target xr should render to
  56054. */
  56055. renderTarget: WebXRRenderTarget;
  56056. /**
  56057. * Enables teleportation
  56058. */
  56059. teleportation: WebXRMotionControllerTeleportation;
  56060. private constructor();
  56061. /**
  56062. * Creates the default xr experience
  56063. * @param scene scene
  56064. * @param options options for basic configuration
  56065. * @returns resulting WebXRDefaultExperience
  56066. */
  56067. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56068. /**
  56069. * DIsposes of the experience helper
  56070. */
  56071. dispose(): void;
  56072. }
  56073. }
  56074. declare module BABYLON {
  56075. /**
  56076. * Options to modify the vr teleportation behavior.
  56077. */
  56078. export interface VRTeleportationOptions {
  56079. /**
  56080. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56081. */
  56082. floorMeshName?: string;
  56083. /**
  56084. * A list of meshes to be used as the teleportation floor. (default: empty)
  56085. */
  56086. floorMeshes?: Mesh[];
  56087. /**
  56088. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56089. */
  56090. teleportationMode?: number;
  56091. /**
  56092. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56093. */
  56094. teleportationTime?: number;
  56095. /**
  56096. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56097. */
  56098. teleportationSpeed?: number;
  56099. /**
  56100. * The easing function used in the animation or null for Linear. (default CircleEase)
  56101. */
  56102. easingFunction?: EasingFunction;
  56103. }
  56104. /**
  56105. * Options to modify the vr experience helper's behavior.
  56106. */
  56107. export interface VRExperienceHelperOptions extends WebVROptions {
  56108. /**
  56109. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56110. */
  56111. createDeviceOrientationCamera?: boolean;
  56112. /**
  56113. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56114. */
  56115. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56116. /**
  56117. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56118. */
  56119. laserToggle?: boolean;
  56120. /**
  56121. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56122. */
  56123. floorMeshes?: Mesh[];
  56124. /**
  56125. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56126. */
  56127. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56128. /**
  56129. * Defines if WebXR should be used instead of WebVR (if available)
  56130. */
  56131. useXR?: boolean;
  56132. }
  56133. /**
  56134. * Event containing information after VR has been entered
  56135. */
  56136. export class OnAfterEnteringVRObservableEvent {
  56137. /**
  56138. * If entering vr was successful
  56139. */
  56140. success: boolean;
  56141. }
  56142. /**
  56143. * Helps to quickly add VR support to an existing scene.
  56144. * See https://doc.babylonjs.com/how_to/webvr_helper
  56145. */
  56146. export class VRExperienceHelper {
  56147. /** Options to modify the vr experience helper's behavior. */
  56148. webVROptions: VRExperienceHelperOptions;
  56149. private _scene;
  56150. private _position;
  56151. private _btnVR;
  56152. private _btnVRDisplayed;
  56153. private _webVRsupported;
  56154. private _webVRready;
  56155. private _webVRrequesting;
  56156. private _webVRpresenting;
  56157. private _hasEnteredVR;
  56158. private _fullscreenVRpresenting;
  56159. private _inputElement;
  56160. private _webVRCamera;
  56161. private _vrDeviceOrientationCamera;
  56162. private _deviceOrientationCamera;
  56163. private _existingCamera;
  56164. private _onKeyDown;
  56165. private _onVrDisplayPresentChange;
  56166. private _onVRDisplayChanged;
  56167. private _onVRRequestPresentStart;
  56168. private _onVRRequestPresentComplete;
  56169. /**
  56170. * 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)
  56171. */
  56172. enableGazeEvenWhenNoPointerLock: boolean;
  56173. /**
  56174. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56175. */
  56176. exitVROnDoubleTap: boolean;
  56177. /**
  56178. * Observable raised right before entering VR.
  56179. */
  56180. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56181. /**
  56182. * Observable raised when entering VR has completed.
  56183. */
  56184. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56185. /**
  56186. * Observable raised when exiting VR.
  56187. */
  56188. onExitingVRObservable: Observable<VRExperienceHelper>;
  56189. /**
  56190. * Observable raised when controller mesh is loaded.
  56191. */
  56192. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56193. /** Return this.onEnteringVRObservable
  56194. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56195. */
  56196. get onEnteringVR(): Observable<VRExperienceHelper>;
  56197. /** Return this.onExitingVRObservable
  56198. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56199. */
  56200. get onExitingVR(): Observable<VRExperienceHelper>;
  56201. /** Return this.onControllerMeshLoadedObservable
  56202. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56203. */
  56204. get onControllerMeshLoaded(): Observable<WebVRController>;
  56205. private _rayLength;
  56206. private _useCustomVRButton;
  56207. private _teleportationRequested;
  56208. private _teleportActive;
  56209. private _floorMeshName;
  56210. private _floorMeshesCollection;
  56211. private _teleportationMode;
  56212. private _teleportationTime;
  56213. private _teleportationSpeed;
  56214. private _teleportationEasing;
  56215. private _rotationAllowed;
  56216. private _teleportBackwardsVector;
  56217. private _teleportationTarget;
  56218. private _isDefaultTeleportationTarget;
  56219. private _postProcessMove;
  56220. private _teleportationFillColor;
  56221. private _teleportationBorderColor;
  56222. private _rotationAngle;
  56223. private _haloCenter;
  56224. private _cameraGazer;
  56225. private _padSensibilityUp;
  56226. private _padSensibilityDown;
  56227. private _leftController;
  56228. private _rightController;
  56229. private _gazeColor;
  56230. private _laserColor;
  56231. private _pickedLaserColor;
  56232. private _pickedGazeColor;
  56233. /**
  56234. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  56235. */
  56236. onNewMeshSelected: Observable<AbstractMesh>;
  56237. /**
  56238. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  56239. * This observable will provide the mesh and the controller used to select the mesh
  56240. */
  56241. onMeshSelectedWithController: Observable<{
  56242. mesh: AbstractMesh;
  56243. controller: WebVRController;
  56244. }>;
  56245. /**
  56246. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  56247. */
  56248. onNewMeshPicked: Observable<PickingInfo>;
  56249. private _circleEase;
  56250. /**
  56251. * Observable raised before camera teleportation
  56252. */
  56253. onBeforeCameraTeleport: Observable<Vector3>;
  56254. /**
  56255. * Observable raised after camera teleportation
  56256. */
  56257. onAfterCameraTeleport: Observable<Vector3>;
  56258. /**
  56259. * Observable raised when current selected mesh gets unselected
  56260. */
  56261. onSelectedMeshUnselected: Observable<AbstractMesh>;
  56262. private _raySelectionPredicate;
  56263. /**
  56264. * To be optionaly changed by user to define custom ray selection
  56265. */
  56266. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56267. /**
  56268. * To be optionaly changed by user to define custom selection logic (after ray selection)
  56269. */
  56270. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56271. /**
  56272. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  56273. */
  56274. teleportationEnabled: boolean;
  56275. private _defaultHeight;
  56276. private _teleportationInitialized;
  56277. private _interactionsEnabled;
  56278. private _interactionsRequested;
  56279. private _displayGaze;
  56280. private _displayLaserPointer;
  56281. /**
  56282. * The mesh used to display where the user is going to teleport.
  56283. */
  56284. get teleportationTarget(): Mesh;
  56285. /**
  56286. * Sets the mesh to be used to display where the user is going to teleport.
  56287. */
  56288. set teleportationTarget(value: Mesh);
  56289. /**
  56290. * 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
  56291. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  56292. * See https://doc.babylonjs.com/resources/baking_transformations
  56293. */
  56294. get gazeTrackerMesh(): Mesh;
  56295. set gazeTrackerMesh(value: Mesh);
  56296. /**
  56297. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  56298. */
  56299. updateGazeTrackerScale: boolean;
  56300. /**
  56301. * If the gaze trackers color should be updated when selecting meshes
  56302. */
  56303. updateGazeTrackerColor: boolean;
  56304. /**
  56305. * If the controller laser color should be updated when selecting meshes
  56306. */
  56307. updateControllerLaserColor: boolean;
  56308. /**
  56309. * The gaze tracking mesh corresponding to the left controller
  56310. */
  56311. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  56312. /**
  56313. * The gaze tracking mesh corresponding to the right controller
  56314. */
  56315. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  56316. /**
  56317. * If the ray of the gaze should be displayed.
  56318. */
  56319. get displayGaze(): boolean;
  56320. /**
  56321. * Sets if the ray of the gaze should be displayed.
  56322. */
  56323. set displayGaze(value: boolean);
  56324. /**
  56325. * If the ray of the LaserPointer should be displayed.
  56326. */
  56327. get displayLaserPointer(): boolean;
  56328. /**
  56329. * Sets if the ray of the LaserPointer should be displayed.
  56330. */
  56331. set displayLaserPointer(value: boolean);
  56332. /**
  56333. * The deviceOrientationCamera used as the camera when not in VR.
  56334. */
  56335. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  56336. /**
  56337. * Based on the current WebVR support, returns the current VR camera used.
  56338. */
  56339. get currentVRCamera(): Nullable<Camera>;
  56340. /**
  56341. * The webVRCamera which is used when in VR.
  56342. */
  56343. get webVRCamera(): WebVRFreeCamera;
  56344. /**
  56345. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  56346. */
  56347. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  56348. /**
  56349. * The html button that is used to trigger entering into VR.
  56350. */
  56351. get vrButton(): Nullable<HTMLButtonElement>;
  56352. private get _teleportationRequestInitiated();
  56353. /**
  56354. * Defines whether or not Pointer lock should be requested when switching to
  56355. * full screen.
  56356. */
  56357. requestPointerLockOnFullScreen: boolean;
  56358. /**
  56359. * If asking to force XR, this will be populated with the default xr experience
  56360. */
  56361. xr: WebXRDefaultExperience;
  56362. /**
  56363. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  56364. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  56365. */
  56366. xrTestDone: boolean;
  56367. /**
  56368. * Instantiates a VRExperienceHelper.
  56369. * Helps to quickly add VR support to an existing scene.
  56370. * @param scene The scene the VRExperienceHelper belongs to.
  56371. * @param webVROptions Options to modify the vr experience helper's behavior.
  56372. */
  56373. constructor(scene: Scene,
  56374. /** Options to modify the vr experience helper's behavior. */
  56375. webVROptions?: VRExperienceHelperOptions);
  56376. private completeVRInit;
  56377. private _onDefaultMeshLoaded;
  56378. private _onResize;
  56379. private _onFullscreenChange;
  56380. /**
  56381. * Gets a value indicating if we are currently in VR mode.
  56382. */
  56383. get isInVRMode(): boolean;
  56384. private onVrDisplayPresentChange;
  56385. private onVRDisplayChanged;
  56386. private moveButtonToBottomRight;
  56387. private displayVRButton;
  56388. private updateButtonVisibility;
  56389. private _cachedAngularSensibility;
  56390. /**
  56391. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  56392. * Otherwise, will use the fullscreen API.
  56393. */
  56394. enterVR(): void;
  56395. /**
  56396. * Attempt to exit VR, or fullscreen.
  56397. */
  56398. exitVR(): void;
  56399. /**
  56400. * The position of the vr experience helper.
  56401. */
  56402. get position(): Vector3;
  56403. /**
  56404. * Sets the position of the vr experience helper.
  56405. */
  56406. set position(value: Vector3);
  56407. /**
  56408. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  56409. */
  56410. enableInteractions(): void;
  56411. private get _noControllerIsActive();
  56412. private beforeRender;
  56413. private _isTeleportationFloor;
  56414. /**
  56415. * Adds a floor mesh to be used for teleportation.
  56416. * @param floorMesh the mesh to be used for teleportation.
  56417. */
  56418. addFloorMesh(floorMesh: Mesh): void;
  56419. /**
  56420. * Removes a floor mesh from being used for teleportation.
  56421. * @param floorMesh the mesh to be removed.
  56422. */
  56423. removeFloorMesh(floorMesh: Mesh): void;
  56424. /**
  56425. * Enables interactions and teleportation using the VR controllers and gaze.
  56426. * @param vrTeleportationOptions options to modify teleportation behavior.
  56427. */
  56428. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  56429. private _onNewGamepadConnected;
  56430. private _tryEnableInteractionOnController;
  56431. private _onNewGamepadDisconnected;
  56432. private _enableInteractionOnController;
  56433. private _checkTeleportWithRay;
  56434. private _checkRotate;
  56435. private _checkTeleportBackwards;
  56436. private _enableTeleportationOnController;
  56437. private _createTeleportationCircles;
  56438. private _displayTeleportationTarget;
  56439. private _hideTeleportationTarget;
  56440. private _rotateCamera;
  56441. private _moveTeleportationSelectorTo;
  56442. private _workingVector;
  56443. private _workingQuaternion;
  56444. private _workingMatrix;
  56445. /**
  56446. * Time Constant Teleportation Mode
  56447. */
  56448. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  56449. /**
  56450. * Speed Constant Teleportation Mode
  56451. */
  56452. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  56453. /**
  56454. * Teleports the users feet to the desired location
  56455. * @param location The location where the user's feet should be placed
  56456. */
  56457. teleportCamera(location: Vector3): void;
  56458. private _convertNormalToDirectionOfRay;
  56459. private _castRayAndSelectObject;
  56460. private _notifySelectedMeshUnselected;
  56461. /**
  56462. * Permanently set new colors for the laser pointer
  56463. * @param color the new laser color
  56464. * @param pickedColor the new laser color when picked mesh detected
  56465. */
  56466. setLaserColor(color: Color3, pickedColor?: Color3): void;
  56467. /**
  56468. * Set lighting enabled / disabled on the laser pointer of both controllers
  56469. * @param enabled should the lighting be enabled on the laser pointer
  56470. */
  56471. setLaserLightingState(enabled?: boolean): void;
  56472. /**
  56473. * Permanently set new colors for the gaze pointer
  56474. * @param color the new gaze color
  56475. * @param pickedColor the new gaze color when picked mesh detected
  56476. */
  56477. setGazeColor(color: Color3, pickedColor?: Color3): void;
  56478. /**
  56479. * Sets the color of the laser ray from the vr controllers.
  56480. * @param color new color for the ray.
  56481. */
  56482. changeLaserColor(color: Color3): void;
  56483. /**
  56484. * Sets the color of the ray from the vr headsets gaze.
  56485. * @param color new color for the ray.
  56486. */
  56487. changeGazeColor(color: Color3): void;
  56488. /**
  56489. * Exits VR and disposes of the vr experience helper
  56490. */
  56491. dispose(): void;
  56492. /**
  56493. * Gets the name of the VRExperienceHelper class
  56494. * @returns "VRExperienceHelper"
  56495. */
  56496. getClassName(): string;
  56497. }
  56498. }
  56499. declare module BABYLON {
  56500. /**
  56501. * Contains an array of blocks representing the octree
  56502. */
  56503. export interface IOctreeContainer<T> {
  56504. /**
  56505. * Blocks within the octree
  56506. */
  56507. blocks: Array<OctreeBlock<T>>;
  56508. }
  56509. /**
  56510. * Class used to store a cell in an octree
  56511. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56512. */
  56513. export class OctreeBlock<T> {
  56514. /**
  56515. * Gets the content of the current block
  56516. */
  56517. entries: T[];
  56518. /**
  56519. * Gets the list of block children
  56520. */
  56521. blocks: Array<OctreeBlock<T>>;
  56522. private _depth;
  56523. private _maxDepth;
  56524. private _capacity;
  56525. private _minPoint;
  56526. private _maxPoint;
  56527. private _boundingVectors;
  56528. private _creationFunc;
  56529. /**
  56530. * Creates a new block
  56531. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  56532. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  56533. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56534. * @param depth defines the current depth of this block in the octree
  56535. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  56536. * @param creationFunc defines a callback to call when an element is added to the block
  56537. */
  56538. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  56539. /**
  56540. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56541. */
  56542. get capacity(): number;
  56543. /**
  56544. * Gets the minimum vector (in world space) of the block's bounding box
  56545. */
  56546. get minPoint(): Vector3;
  56547. /**
  56548. * Gets the maximum vector (in world space) of the block's bounding box
  56549. */
  56550. get maxPoint(): Vector3;
  56551. /**
  56552. * Add a new element to this block
  56553. * @param entry defines the element to add
  56554. */
  56555. addEntry(entry: T): void;
  56556. /**
  56557. * Remove an element from this block
  56558. * @param entry defines the element to remove
  56559. */
  56560. removeEntry(entry: T): void;
  56561. /**
  56562. * Add an array of elements to this block
  56563. * @param entries defines the array of elements to add
  56564. */
  56565. addEntries(entries: T[]): void;
  56566. /**
  56567. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56568. * @param frustumPlanes defines the frustum planes to test
  56569. * @param selection defines the array to store current content if selection is positive
  56570. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56571. */
  56572. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56573. /**
  56574. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56575. * @param sphereCenter defines the bounding sphere center
  56576. * @param sphereRadius defines the bounding sphere radius
  56577. * @param selection defines the array to store current content if selection is positive
  56578. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56579. */
  56580. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56581. /**
  56582. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56583. * @param ray defines the ray to test with
  56584. * @param selection defines the array to store current content if selection is positive
  56585. */
  56586. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56587. /**
  56588. * Subdivide the content into child blocks (this block will then be empty)
  56589. */
  56590. createInnerBlocks(): void;
  56591. /**
  56592. * @hidden
  56593. */
  56594. 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;
  56595. }
  56596. }
  56597. declare module BABYLON {
  56598. /**
  56599. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56600. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56601. */
  56602. export class Octree<T> {
  56603. /** 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.) */
  56604. maxDepth: number;
  56605. /**
  56606. * Blocks within the octree containing objects
  56607. */
  56608. blocks: Array<OctreeBlock<T>>;
  56609. /**
  56610. * Content stored in the octree
  56611. */
  56612. dynamicContent: T[];
  56613. private _maxBlockCapacity;
  56614. private _selectionContent;
  56615. private _creationFunc;
  56616. /**
  56617. * Creates a octree
  56618. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56619. * @param creationFunc function to be used to instatiate the octree
  56620. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56621. * @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.)
  56622. */
  56623. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56624. /** 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.) */
  56625. maxDepth?: number);
  56626. /**
  56627. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56628. * @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);
  56629. * @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);
  56630. * @param entries meshes to be added to the octree blocks
  56631. */
  56632. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56633. /**
  56634. * Adds a mesh to the octree
  56635. * @param entry Mesh to add to the octree
  56636. */
  56637. addMesh(entry: T): void;
  56638. /**
  56639. * Remove an element from the octree
  56640. * @param entry defines the element to remove
  56641. */
  56642. removeMesh(entry: T): void;
  56643. /**
  56644. * Selects an array of meshes within the frustum
  56645. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56646. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56647. * @returns array of meshes within the frustum
  56648. */
  56649. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56650. /**
  56651. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56652. * @param sphereCenter defines the bounding sphere center
  56653. * @param sphereRadius defines the bounding sphere radius
  56654. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56655. * @returns an array of objects that intersect the sphere
  56656. */
  56657. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56658. /**
  56659. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56660. * @param ray defines the ray to test with
  56661. * @returns array of intersected objects
  56662. */
  56663. intersectsRay(ray: Ray): SmartArray<T>;
  56664. /**
  56665. * Adds a mesh into the octree block if it intersects the block
  56666. */
  56667. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56668. /**
  56669. * Adds a submesh into the octree block if it intersects the block
  56670. */
  56671. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56672. }
  56673. }
  56674. declare module BABYLON {
  56675. interface Scene {
  56676. /**
  56677. * @hidden
  56678. * Backing Filed
  56679. */
  56680. _selectionOctree: Octree<AbstractMesh>;
  56681. /**
  56682. * Gets the octree used to boost mesh selection (picking)
  56683. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56684. */
  56685. selectionOctree: Octree<AbstractMesh>;
  56686. /**
  56687. * Creates or updates the octree used to boost selection (picking)
  56688. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56689. * @param maxCapacity defines the maximum capacity per leaf
  56690. * @param maxDepth defines the maximum depth of the octree
  56691. * @returns an octree of AbstractMesh
  56692. */
  56693. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56694. }
  56695. interface AbstractMesh {
  56696. /**
  56697. * @hidden
  56698. * Backing Field
  56699. */
  56700. _submeshesOctree: Octree<SubMesh>;
  56701. /**
  56702. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  56703. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  56704. * @param maxCapacity defines the maximum size of each block (64 by default)
  56705. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  56706. * @returns the new octree
  56707. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  56708. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56709. */
  56710. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  56711. }
  56712. /**
  56713. * Defines the octree scene component responsible to manage any octrees
  56714. * in a given scene.
  56715. */
  56716. export class OctreeSceneComponent {
  56717. /**
  56718. * The component name help to identify the component in the list of scene components.
  56719. */
  56720. readonly name: string;
  56721. /**
  56722. * The scene the component belongs to.
  56723. */
  56724. scene: Scene;
  56725. /**
  56726. * Indicates if the meshes have been checked to make sure they are isEnabled()
  56727. */
  56728. readonly checksIsEnabled: boolean;
  56729. /**
  56730. * Creates a new instance of the component for the given scene
  56731. * @param scene Defines the scene to register the component in
  56732. */
  56733. constructor(scene: Scene);
  56734. /**
  56735. * Registers the component in a given scene
  56736. */
  56737. register(): void;
  56738. /**
  56739. * Return the list of active meshes
  56740. * @returns the list of active meshes
  56741. */
  56742. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  56743. /**
  56744. * Return the list of active sub meshes
  56745. * @param mesh The mesh to get the candidates sub meshes from
  56746. * @returns the list of active sub meshes
  56747. */
  56748. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  56749. private _tempRay;
  56750. /**
  56751. * Return the list of sub meshes intersecting with a given local ray
  56752. * @param mesh defines the mesh to find the submesh for
  56753. * @param localRay defines the ray in local space
  56754. * @returns the list of intersecting sub meshes
  56755. */
  56756. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  56757. /**
  56758. * Return the list of sub meshes colliding with a collider
  56759. * @param mesh defines the mesh to find the submesh for
  56760. * @param collider defines the collider to evaluate the collision against
  56761. * @returns the list of colliding sub meshes
  56762. */
  56763. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  56764. /**
  56765. * Rebuilds the elements related to this component in case of
  56766. * context lost for instance.
  56767. */
  56768. rebuild(): void;
  56769. /**
  56770. * Disposes the component and the associated ressources.
  56771. */
  56772. dispose(): void;
  56773. }
  56774. }
  56775. declare module BABYLON {
  56776. /**
  56777. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  56778. */
  56779. export interface GizmoAxisCache {
  56780. /** Mesh used to runder the Gizmo */
  56781. gizmoMeshes: Mesh[];
  56782. /** Mesh used to detect user interaction with Gizmo */
  56783. colliderMeshes: Mesh[];
  56784. /** Material used to inicate color of gizmo mesh */
  56785. material: StandardMaterial;
  56786. /** Material used to inicate hover state of the Gizmo */
  56787. hoverMaterial: StandardMaterial;
  56788. /** Material used to inicate disabled state of the Gizmo */
  56789. disableMaterial: StandardMaterial;
  56790. /** Used to indicate Active state of the Gizmo */
  56791. active: boolean;
  56792. }
  56793. /**
  56794. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  56795. */
  56796. export class Gizmo implements IDisposable {
  56797. /** The utility layer the gizmo will be added to */
  56798. gizmoLayer: UtilityLayerRenderer;
  56799. /**
  56800. * The root mesh of the gizmo
  56801. */
  56802. _rootMesh: Mesh;
  56803. private _attachedMesh;
  56804. private _attachedNode;
  56805. /**
  56806. * Ratio for the scale of the gizmo (Default: 1)
  56807. */
  56808. protected _scaleRatio: number;
  56809. /**
  56810. * boolean updated by pointermove when a gizmo mesh is hovered
  56811. */
  56812. protected _isHovered: boolean;
  56813. /**
  56814. * Ratio for the scale of the gizmo (Default: 1)
  56815. */
  56816. set scaleRatio(value: number);
  56817. get scaleRatio(): number;
  56818. /**
  56819. * True when the mouse pointer is hovered a gizmo mesh
  56820. */
  56821. get isHovered(): boolean;
  56822. /**
  56823. * If a custom mesh has been set (Default: false)
  56824. */
  56825. protected _customMeshSet: boolean;
  56826. /**
  56827. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  56828. * * When set, interactions will be enabled
  56829. */
  56830. get attachedMesh(): Nullable<AbstractMesh>;
  56831. set attachedMesh(value: Nullable<AbstractMesh>);
  56832. /**
  56833. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  56834. * * When set, interactions will be enabled
  56835. */
  56836. get attachedNode(): Nullable<Node>;
  56837. set attachedNode(value: Nullable<Node>);
  56838. /**
  56839. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56840. * @param mesh The mesh to replace the default mesh of the gizmo
  56841. */
  56842. setCustomMesh(mesh: Mesh): void;
  56843. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  56844. /**
  56845. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  56846. */
  56847. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56848. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56849. /**
  56850. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  56851. */
  56852. updateGizmoPositionToMatchAttachedMesh: boolean;
  56853. /**
  56854. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  56855. */
  56856. updateScale: boolean;
  56857. protected _interactionsEnabled: boolean;
  56858. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56859. private _beforeRenderObserver;
  56860. private _tempQuaternion;
  56861. private _tempVector;
  56862. private _tempVector2;
  56863. private _tempMatrix1;
  56864. private _tempMatrix2;
  56865. private _rightHandtoLeftHandMatrix;
  56866. /**
  56867. * Creates a gizmo
  56868. * @param gizmoLayer The utility layer the gizmo will be added to
  56869. */
  56870. constructor(
  56871. /** The utility layer the gizmo will be added to */
  56872. gizmoLayer?: UtilityLayerRenderer);
  56873. /**
  56874. * Updates the gizmo to match the attached mesh's position/rotation
  56875. */
  56876. protected _update(): void;
  56877. /**
  56878. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  56879. * @param value Node, TransformNode or mesh
  56880. */
  56881. protected _matrixChanged(): void;
  56882. /**
  56883. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  56884. * @param gizmoLayer The utility layer the gizmo will be added to
  56885. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  56886. * @returns {Observer<PointerInfo>} pointerObserver
  56887. */
  56888. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  56889. /**
  56890. * Disposes of the gizmo
  56891. */
  56892. dispose(): void;
  56893. }
  56894. }
  56895. declare module BABYLON {
  56896. /**
  56897. * Single plane drag gizmo
  56898. */
  56899. export class PlaneDragGizmo extends Gizmo {
  56900. /**
  56901. * Drag behavior responsible for the gizmos dragging interactions
  56902. */
  56903. dragBehavior: PointerDragBehavior;
  56904. private _pointerObserver;
  56905. /**
  56906. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56907. */
  56908. snapDistance: number;
  56909. /**
  56910. * Event that fires each time the gizmo snaps to a new location.
  56911. * * snapDistance is the the change in distance
  56912. */
  56913. onSnapObservable: Observable<{
  56914. snapDistance: number;
  56915. }>;
  56916. private _gizmoMesh;
  56917. private _coloredMaterial;
  56918. private _hoverMaterial;
  56919. private _disableMaterial;
  56920. private _isEnabled;
  56921. private _parent;
  56922. private _dragging;
  56923. /** @hidden */
  56924. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  56925. /**
  56926. * Creates a PlaneDragGizmo
  56927. * @param gizmoLayer The utility layer the gizmo will be added to
  56928. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  56929. * @param color The color of the gizmo
  56930. */
  56931. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  56932. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56933. /**
  56934. * If the gizmo is enabled
  56935. */
  56936. set isEnabled(value: boolean);
  56937. get isEnabled(): boolean;
  56938. /**
  56939. * Disposes of the gizmo
  56940. */
  56941. dispose(): void;
  56942. }
  56943. }
  56944. declare module BABYLON {
  56945. /**
  56946. * Single plane rotation gizmo
  56947. */
  56948. export class PlaneRotationGizmo extends Gizmo {
  56949. /**
  56950. * Drag behavior responsible for the gizmos dragging interactions
  56951. */
  56952. dragBehavior: PointerDragBehavior;
  56953. private _pointerObserver;
  56954. /**
  56955. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56956. */
  56957. snapDistance: number;
  56958. /**
  56959. * Event that fires each time the gizmo snaps to a new location.
  56960. * * snapDistance is the the change in distance
  56961. */
  56962. onSnapObservable: Observable<{
  56963. snapDistance: number;
  56964. }>;
  56965. private _isEnabled;
  56966. private _parent;
  56967. private _coloredMaterial;
  56968. private _hoverMaterial;
  56969. private _disableMaterial;
  56970. private _gizmoMesh;
  56971. private _rotationCircle;
  56972. private _dragging;
  56973. private static _CircleConstants;
  56974. /**
  56975. * Creates a PlaneRotationGizmo
  56976. * @param gizmoLayer The utility layer the gizmo will be added to
  56977. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56978. * @param color The color of the gizmo
  56979. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56980. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56981. * @param thickness display gizmo axis thickness
  56982. */
  56983. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56984. /** Create Geometry for Gizmo */
  56985. private _createGizmoMesh;
  56986. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56987. private setupRotationCircle;
  56988. private updateRotationPath;
  56989. private updateRotationCircle;
  56990. /**
  56991. * If the gizmo is enabled
  56992. */
  56993. set isEnabled(value: boolean);
  56994. get isEnabled(): boolean;
  56995. /**
  56996. * Disposes of the gizmo
  56997. */
  56998. dispose(): void;
  56999. }
  57000. }
  57001. declare module BABYLON {
  57002. /**
  57003. * Gizmo that enables rotating a mesh along 3 axis
  57004. */
  57005. export class RotationGizmo extends Gizmo {
  57006. /**
  57007. * Internal gizmo used for interactions on the x axis
  57008. */
  57009. xGizmo: PlaneRotationGizmo;
  57010. /**
  57011. * Internal gizmo used for interactions on the y axis
  57012. */
  57013. yGizmo: PlaneRotationGizmo;
  57014. /**
  57015. * Internal gizmo used for interactions on the z axis
  57016. */
  57017. zGizmo: PlaneRotationGizmo;
  57018. /** Fires an event when any of it's sub gizmos are dragged */
  57019. onDragStartObservable: Observable<unknown>;
  57020. /** Fires an event when any of it's sub gizmos are released from dragging */
  57021. onDragEndObservable: Observable<unknown>;
  57022. private _meshAttached;
  57023. private _nodeAttached;
  57024. private _observables;
  57025. /** Node Caching for quick lookup */
  57026. private _gizmoAxisCache;
  57027. get attachedMesh(): Nullable<AbstractMesh>;
  57028. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57029. get attachedNode(): Nullable<Node>;
  57030. set attachedNode(node: Nullable<Node>);
  57031. protected _checkBillboardTransform(): void;
  57032. /**
  57033. * True when the mouse pointer is hovering a gizmo mesh
  57034. */
  57035. get isHovered(): boolean;
  57036. /**
  57037. * Creates a RotationGizmo
  57038. * @param gizmoLayer The utility layer the gizmo will be added to
  57039. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57040. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57041. * @param thickness display gizmo axis thickness
  57042. */
  57043. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57044. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57045. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57046. /**
  57047. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57048. */
  57049. set snapDistance(value: number);
  57050. get snapDistance(): number;
  57051. /**
  57052. * Ratio for the scale of the gizmo (Default: 1)
  57053. */
  57054. set scaleRatio(value: number);
  57055. get scaleRatio(): number;
  57056. /**
  57057. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57058. * @param mesh Axis gizmo mesh
  57059. * @param cache Gizmo axis definition used for reactive gizmo UI
  57060. */
  57061. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57062. /**
  57063. * Disposes of the gizmo
  57064. */
  57065. dispose(): void;
  57066. /**
  57067. * CustomMeshes are not supported by this gizmo
  57068. * @param mesh The mesh to replace the default mesh of the gizmo
  57069. */
  57070. setCustomMesh(mesh: Mesh): void;
  57071. }
  57072. }
  57073. declare module BABYLON {
  57074. /**
  57075. * Class containing static functions to help procedurally build meshes
  57076. */
  57077. export class PolyhedronBuilder {
  57078. /**
  57079. * Creates a polyhedron mesh
  57080. * * 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
  57081. * * The parameter `size` (positive float, default 1) sets the polygon size
  57082. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57083. * * 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`
  57084. * * 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
  57085. * * 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)`)
  57086. * * 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
  57087. * * 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
  57088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57089. * * 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
  57090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57091. * @param name defines the name of the mesh
  57092. * @param options defines the options used to create the mesh
  57093. * @param scene defines the hosting scene
  57094. * @returns the polyhedron mesh
  57095. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57096. */
  57097. static CreatePolyhedron(name: string, options: {
  57098. type?: number;
  57099. size?: number;
  57100. sizeX?: number;
  57101. sizeY?: number;
  57102. sizeZ?: number;
  57103. custom?: any;
  57104. faceUV?: Vector4[];
  57105. faceColors?: Color4[];
  57106. flat?: boolean;
  57107. updatable?: boolean;
  57108. sideOrientation?: number;
  57109. frontUVs?: Vector4;
  57110. backUVs?: Vector4;
  57111. }, scene?: Nullable<Scene>): Mesh;
  57112. }
  57113. }
  57114. declare module BABYLON {
  57115. /**
  57116. * Class containing static functions to help procedurally build meshes
  57117. */
  57118. export class BoxBuilder {
  57119. /**
  57120. * Creates a box mesh
  57121. * * The parameter `size` sets the size (float) of each box side (default 1)
  57122. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57123. * * 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)
  57124. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57125. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57126. * * 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
  57127. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57128. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57129. * @param name defines the name of the mesh
  57130. * @param options defines the options used to create the mesh
  57131. * @param scene defines the hosting scene
  57132. * @returns the box mesh
  57133. */
  57134. static CreateBox(name: string, options: {
  57135. size?: number;
  57136. width?: number;
  57137. height?: number;
  57138. depth?: number;
  57139. faceUV?: Vector4[];
  57140. faceColors?: Color4[];
  57141. sideOrientation?: number;
  57142. frontUVs?: Vector4;
  57143. backUVs?: Vector4;
  57144. wrap?: boolean;
  57145. topBaseAt?: number;
  57146. bottomBaseAt?: number;
  57147. updatable?: boolean;
  57148. }, scene?: Nullable<Scene>): Mesh;
  57149. }
  57150. }
  57151. declare module BABYLON {
  57152. /**
  57153. * Single axis scale gizmo
  57154. */
  57155. export class AxisScaleGizmo extends Gizmo {
  57156. /**
  57157. * Drag behavior responsible for the gizmos dragging interactions
  57158. */
  57159. dragBehavior: PointerDragBehavior;
  57160. private _pointerObserver;
  57161. /**
  57162. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57163. */
  57164. snapDistance: number;
  57165. /**
  57166. * Event that fires each time the gizmo snaps to a new location.
  57167. * * snapDistance is the the change in distance
  57168. */
  57169. onSnapObservable: Observable<{
  57170. snapDistance: number;
  57171. }>;
  57172. /**
  57173. * If the scaling operation should be done on all axis (default: false)
  57174. */
  57175. uniformScaling: boolean;
  57176. /**
  57177. * Custom sensitivity value for the drag strength
  57178. */
  57179. sensitivity: number;
  57180. private _isEnabled;
  57181. private _parent;
  57182. private _gizmoMesh;
  57183. private _coloredMaterial;
  57184. private _hoverMaterial;
  57185. private _disableMaterial;
  57186. private _dragging;
  57187. private _tmpVector;
  57188. private _tmpMatrix;
  57189. private _tmpMatrix2;
  57190. /**
  57191. * Creates an AxisScaleGizmo
  57192. * @param gizmoLayer The utility layer the gizmo will be added to
  57193. * @param dragAxis The axis which the gizmo will be able to scale on
  57194. * @param color The color of the gizmo
  57195. * @param thickness display gizmo axis thickness
  57196. */
  57197. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57198. /** Create Geometry for Gizmo */
  57199. private _createGizmoMesh;
  57200. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57201. /**
  57202. * If the gizmo is enabled
  57203. */
  57204. set isEnabled(value: boolean);
  57205. get isEnabled(): boolean;
  57206. /**
  57207. * Disposes of the gizmo
  57208. */
  57209. dispose(): void;
  57210. /**
  57211. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57212. * @param mesh The mesh to replace the default mesh of the gizmo
  57213. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57214. */
  57215. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57216. }
  57217. }
  57218. declare module BABYLON {
  57219. /**
  57220. * Gizmo that enables scaling a mesh along 3 axis
  57221. */
  57222. export class ScaleGizmo extends Gizmo {
  57223. /**
  57224. * Internal gizmo used for interactions on the x axis
  57225. */
  57226. xGizmo: AxisScaleGizmo;
  57227. /**
  57228. * Internal gizmo used for interactions on the y axis
  57229. */
  57230. yGizmo: AxisScaleGizmo;
  57231. /**
  57232. * Internal gizmo used for interactions on the z axis
  57233. */
  57234. zGizmo: AxisScaleGizmo;
  57235. /**
  57236. * Internal gizmo used to scale all axis equally
  57237. */
  57238. uniformScaleGizmo: AxisScaleGizmo;
  57239. private _meshAttached;
  57240. private _nodeAttached;
  57241. private _snapDistance;
  57242. private _uniformScalingMesh;
  57243. private _octahedron;
  57244. private _sensitivity;
  57245. private _coloredMaterial;
  57246. private _hoverMaterial;
  57247. private _disableMaterial;
  57248. private _observables;
  57249. /** Node Caching for quick lookup */
  57250. private _gizmoAxisCache;
  57251. /** Fires an event when any of it's sub gizmos are dragged */
  57252. onDragStartObservable: Observable<unknown>;
  57253. /** Fires an event when any of it's sub gizmos are released from dragging */
  57254. onDragEndObservable: Observable<unknown>;
  57255. get attachedMesh(): Nullable<AbstractMesh>;
  57256. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57257. get attachedNode(): Nullable<Node>;
  57258. set attachedNode(node: Nullable<Node>);
  57259. /**
  57260. * True when the mouse pointer is hovering a gizmo mesh
  57261. */
  57262. get isHovered(): boolean;
  57263. /**
  57264. * Creates a ScaleGizmo
  57265. * @param gizmoLayer The utility layer the gizmo will be added to
  57266. * @param thickness display gizmo axis thickness
  57267. */
  57268. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57269. /** Create Geometry for Gizmo */
  57270. private _createUniformScaleMesh;
  57271. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57272. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57273. /**
  57274. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57275. */
  57276. set snapDistance(value: number);
  57277. get snapDistance(): number;
  57278. /**
  57279. * Ratio for the scale of the gizmo (Default: 1)
  57280. */
  57281. set scaleRatio(value: number);
  57282. get scaleRatio(): number;
  57283. /**
  57284. * Sensitivity factor for dragging (Default: 1)
  57285. */
  57286. set sensitivity(value: number);
  57287. get sensitivity(): number;
  57288. /**
  57289. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57290. * @param mesh Axis gizmo mesh
  57291. * @param cache Gizmo axis definition used for reactive gizmo UI
  57292. */
  57293. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57294. /**
  57295. * Disposes of the gizmo
  57296. */
  57297. dispose(): void;
  57298. }
  57299. }
  57300. declare module BABYLON {
  57301. /**
  57302. * Bounding box gizmo
  57303. */
  57304. export class BoundingBoxGizmo extends Gizmo {
  57305. private _lineBoundingBox;
  57306. private _rotateSpheresParent;
  57307. private _scaleBoxesParent;
  57308. private _boundingDimensions;
  57309. private _renderObserver;
  57310. private _pointerObserver;
  57311. private _scaleDragSpeed;
  57312. private _tmpQuaternion;
  57313. private _tmpVector;
  57314. private _tmpRotationMatrix;
  57315. /**
  57316. * 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)
  57317. */
  57318. ignoreChildren: boolean;
  57319. /**
  57320. * 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)
  57321. */
  57322. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57323. /**
  57324. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57325. */
  57326. rotationSphereSize: number;
  57327. /**
  57328. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57329. */
  57330. scaleBoxSize: number;
  57331. /**
  57332. * 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)
  57333. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57334. */
  57335. fixedDragMeshScreenSize: boolean;
  57336. /**
  57337. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  57338. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57339. */
  57340. fixedDragMeshBoundsSize: boolean;
  57341. /**
  57342. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57343. */
  57344. fixedDragMeshScreenSizeDistanceFactor: number;
  57345. /**
  57346. * Fired when a rotation sphere or scale box is dragged
  57347. */
  57348. onDragStartObservable: Observable<{}>;
  57349. /**
  57350. * Fired when a scale box is dragged
  57351. */
  57352. onScaleBoxDragObservable: Observable<{}>;
  57353. /**
  57354. * Fired when a scale box drag is ended
  57355. */
  57356. onScaleBoxDragEndObservable: Observable<{}>;
  57357. /**
  57358. * Fired when a rotation sphere is dragged
  57359. */
  57360. onRotationSphereDragObservable: Observable<{}>;
  57361. /**
  57362. * Fired when a rotation sphere drag is ended
  57363. */
  57364. onRotationSphereDragEndObservable: Observable<{}>;
  57365. /**
  57366. * 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)
  57367. */
  57368. scalePivot: Nullable<Vector3>;
  57369. /**
  57370. * Mesh used as a pivot to rotate the attached node
  57371. */
  57372. private _anchorMesh;
  57373. private _existingMeshScale;
  57374. private _dragMesh;
  57375. private pointerDragBehavior;
  57376. private coloredMaterial;
  57377. private hoverColoredMaterial;
  57378. /**
  57379. * Sets the color of the bounding box gizmo
  57380. * @param color the color to set
  57381. */
  57382. setColor(color: Color3): void;
  57383. /**
  57384. * Creates an BoundingBoxGizmo
  57385. * @param gizmoLayer The utility layer the gizmo will be added to
  57386. * @param color The color of the gizmo
  57387. */
  57388. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57389. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57390. private _selectNode;
  57391. /**
  57392. * Updates the bounding box information for the Gizmo
  57393. */
  57394. updateBoundingBox(): void;
  57395. private _updateRotationSpheres;
  57396. private _updateScaleBoxes;
  57397. /**
  57398. * Enables rotation on the specified axis and disables rotation on the others
  57399. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57400. */
  57401. setEnabledRotationAxis(axis: string): void;
  57402. /**
  57403. * Enables/disables scaling
  57404. * @param enable if scaling should be enabled
  57405. * @param homogeneousScaling defines if scaling should only be homogeneous
  57406. */
  57407. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57408. private _updateDummy;
  57409. /**
  57410. * Enables a pointer drag behavior on the bounding box of the gizmo
  57411. */
  57412. enableDragBehavior(): void;
  57413. /**
  57414. * Disposes of the gizmo
  57415. */
  57416. dispose(): void;
  57417. /**
  57418. * 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)
  57419. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57420. * @returns the bounding box mesh with the passed in mesh as a child
  57421. */
  57422. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57423. /**
  57424. * CustomMeshes are not supported by this gizmo
  57425. * @param mesh The mesh to replace the default mesh of the gizmo
  57426. */
  57427. setCustomMesh(mesh: Mesh): void;
  57428. }
  57429. }
  57430. declare module BABYLON {
  57431. /**
  57432. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57433. */
  57434. export class GizmoManager implements IDisposable {
  57435. private scene;
  57436. /**
  57437. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57438. */
  57439. gizmos: {
  57440. positionGizmo: Nullable<PositionGizmo>;
  57441. rotationGizmo: Nullable<RotationGizmo>;
  57442. scaleGizmo: Nullable<ScaleGizmo>;
  57443. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57444. };
  57445. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57446. clearGizmoOnEmptyPointerEvent: boolean;
  57447. /** Fires an event when the manager is attached to a mesh */
  57448. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57449. /** Fires an event when the manager is attached to a node */
  57450. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57451. private _gizmosEnabled;
  57452. private _pointerObservers;
  57453. private _attachedMesh;
  57454. private _attachedNode;
  57455. private _boundingBoxColor;
  57456. private _defaultUtilityLayer;
  57457. private _defaultKeepDepthUtilityLayer;
  57458. private _thickness;
  57459. /** Node Caching for quick lookup */
  57460. private _gizmoAxisCache;
  57461. /**
  57462. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57463. */
  57464. boundingBoxDragBehavior: SixDofDragBehavior;
  57465. /**
  57466. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57467. */
  57468. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57469. /**
  57470. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57471. */
  57472. attachableNodes: Nullable<Array<Node>>;
  57473. /**
  57474. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57475. */
  57476. usePointerToAttachGizmos: boolean;
  57477. /**
  57478. * Utility layer that the bounding box gizmo belongs to
  57479. */
  57480. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57481. /**
  57482. * Utility layer that all gizmos besides bounding box belong to
  57483. */
  57484. get utilityLayer(): UtilityLayerRenderer;
  57485. /**
  57486. * True when the mouse pointer is hovering a gizmo mesh
  57487. */
  57488. get isHovered(): boolean;
  57489. /**
  57490. * Instatiates a gizmo manager
  57491. * @param scene the scene to overlay the gizmos on top of
  57492. * @param thickness display gizmo axis thickness
  57493. * @param utilityLayer the layer where gizmos are rendered
  57494. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57495. */
  57496. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57497. /**
  57498. * Subscribes to pointer down events, for attaching and detaching mesh
  57499. * @param scene The sceme layer the observer will be added to
  57500. */
  57501. private _attachToMeshPointerObserver;
  57502. /**
  57503. * Attaches a set of gizmos to the specified mesh
  57504. * @param mesh The mesh the gizmo's should be attached to
  57505. */
  57506. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57507. /**
  57508. * Attaches a set of gizmos to the specified node
  57509. * @param node The node the gizmo's should be attached to
  57510. */
  57511. attachToNode(node: Nullable<Node>): void;
  57512. /**
  57513. * If the position gizmo is enabled
  57514. */
  57515. set positionGizmoEnabled(value: boolean);
  57516. get positionGizmoEnabled(): boolean;
  57517. /**
  57518. * If the rotation gizmo is enabled
  57519. */
  57520. set rotationGizmoEnabled(value: boolean);
  57521. get rotationGizmoEnabled(): boolean;
  57522. /**
  57523. * If the scale gizmo is enabled
  57524. */
  57525. set scaleGizmoEnabled(value: boolean);
  57526. get scaleGizmoEnabled(): boolean;
  57527. /**
  57528. * If the boundingBox gizmo is enabled
  57529. */
  57530. set boundingBoxGizmoEnabled(value: boolean);
  57531. get boundingBoxGizmoEnabled(): boolean;
  57532. /**
  57533. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57534. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57535. */
  57536. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57537. /**
  57538. * Disposes of the gizmo manager
  57539. */
  57540. dispose(): void;
  57541. }
  57542. }
  57543. declare module BABYLON {
  57544. /**
  57545. * Gizmo that enables dragging a mesh along 3 axis
  57546. */
  57547. export class PositionGizmo extends Gizmo {
  57548. /**
  57549. * Internal gizmo used for interactions on the x axis
  57550. */
  57551. xGizmo: AxisDragGizmo;
  57552. /**
  57553. * Internal gizmo used for interactions on the y axis
  57554. */
  57555. yGizmo: AxisDragGizmo;
  57556. /**
  57557. * Internal gizmo used for interactions on the z axis
  57558. */
  57559. zGizmo: AxisDragGizmo;
  57560. /**
  57561. * Internal gizmo used for interactions on the yz plane
  57562. */
  57563. xPlaneGizmo: PlaneDragGizmo;
  57564. /**
  57565. * Internal gizmo used for interactions on the xz plane
  57566. */
  57567. yPlaneGizmo: PlaneDragGizmo;
  57568. /**
  57569. * Internal gizmo used for interactions on the xy plane
  57570. */
  57571. zPlaneGizmo: PlaneDragGizmo;
  57572. /**
  57573. * private variables
  57574. */
  57575. private _meshAttached;
  57576. private _nodeAttached;
  57577. private _snapDistance;
  57578. private _observables;
  57579. /** Node Caching for quick lookup */
  57580. private _gizmoAxisCache;
  57581. /** Fires an event when any of it's sub gizmos are dragged */
  57582. onDragStartObservable: Observable<unknown>;
  57583. /** Fires an event when any of it's sub gizmos are released from dragging */
  57584. onDragEndObservable: Observable<unknown>;
  57585. /**
  57586. * If set to true, planar drag is enabled
  57587. */
  57588. private _planarGizmoEnabled;
  57589. get attachedMesh(): Nullable<AbstractMesh>;
  57590. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57591. get attachedNode(): Nullable<Node>;
  57592. set attachedNode(node: Nullable<Node>);
  57593. /**
  57594. * True when the mouse pointer is hovering a gizmo mesh
  57595. */
  57596. get isHovered(): boolean;
  57597. /**
  57598. * Creates a PositionGizmo
  57599. * @param gizmoLayer The utility layer the gizmo will be added to
  57600. @param thickness display gizmo axis thickness
  57601. */
  57602. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57603. /**
  57604. * If the planar drag gizmo is enabled
  57605. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57606. */
  57607. set planarGizmoEnabled(value: boolean);
  57608. get planarGizmoEnabled(): boolean;
  57609. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57610. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57611. /**
  57612. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57613. */
  57614. set snapDistance(value: number);
  57615. get snapDistance(): number;
  57616. /**
  57617. * Ratio for the scale of the gizmo (Default: 1)
  57618. */
  57619. set scaleRatio(value: number);
  57620. get scaleRatio(): number;
  57621. /**
  57622. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57623. * @param mesh Axis gizmo mesh
  57624. * @param cache Gizmo axis definition used for reactive gizmo UI
  57625. */
  57626. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57627. /**
  57628. * Disposes of the gizmo
  57629. */
  57630. dispose(): void;
  57631. /**
  57632. * CustomMeshes are not supported by this gizmo
  57633. * @param mesh The mesh to replace the default mesh of the gizmo
  57634. */
  57635. setCustomMesh(mesh: Mesh): void;
  57636. }
  57637. }
  57638. declare module BABYLON {
  57639. /**
  57640. * Single axis drag gizmo
  57641. */
  57642. export class AxisDragGizmo extends Gizmo {
  57643. /**
  57644. * Drag behavior responsible for the gizmos dragging interactions
  57645. */
  57646. dragBehavior: PointerDragBehavior;
  57647. private _pointerObserver;
  57648. /**
  57649. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57650. */
  57651. snapDistance: number;
  57652. /**
  57653. * Event that fires each time the gizmo snaps to a new location.
  57654. * * snapDistance is the the change in distance
  57655. */
  57656. onSnapObservable: Observable<{
  57657. snapDistance: number;
  57658. }>;
  57659. private _isEnabled;
  57660. private _parent;
  57661. private _gizmoMesh;
  57662. private _coloredMaterial;
  57663. private _hoverMaterial;
  57664. private _disableMaterial;
  57665. private _dragging;
  57666. /** @hidden */
  57667. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57668. /** @hidden */
  57669. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57670. /**
  57671. * Creates an AxisDragGizmo
  57672. * @param gizmoLayer The utility layer the gizmo will be added to
  57673. * @param dragAxis The axis which the gizmo will be able to drag on
  57674. * @param color The color of the gizmo
  57675. * @param thickness display gizmo axis thickness
  57676. */
  57677. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57678. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57679. /**
  57680. * If the gizmo is enabled
  57681. */
  57682. set isEnabled(value: boolean);
  57683. get isEnabled(): boolean;
  57684. /**
  57685. * Disposes of the gizmo
  57686. */
  57687. dispose(): void;
  57688. }
  57689. }
  57690. declare module BABYLON.Debug {
  57691. /**
  57692. * The Axes viewer will show 3 axes in a specific point in space
  57693. */
  57694. export class AxesViewer {
  57695. private _xAxis;
  57696. private _yAxis;
  57697. private _zAxis;
  57698. private _scaleLinesFactor;
  57699. private _instanced;
  57700. /**
  57701. * Gets the hosting scene
  57702. */
  57703. scene: Nullable<Scene>;
  57704. /**
  57705. * Gets or sets a number used to scale line length
  57706. */
  57707. scaleLines: number;
  57708. /** Gets the node hierarchy used to render x-axis */
  57709. get xAxis(): TransformNode;
  57710. /** Gets the node hierarchy used to render y-axis */
  57711. get yAxis(): TransformNode;
  57712. /** Gets the node hierarchy used to render z-axis */
  57713. get zAxis(): TransformNode;
  57714. /**
  57715. * Creates a new AxesViewer
  57716. * @param scene defines the hosting scene
  57717. * @param scaleLines defines a number used to scale line length (1 by default)
  57718. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  57719. * @param xAxis defines the node hierarchy used to render the x-axis
  57720. * @param yAxis defines the node hierarchy used to render the y-axis
  57721. * @param zAxis defines the node hierarchy used to render the z-axis
  57722. */
  57723. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  57724. /**
  57725. * Force the viewer to update
  57726. * @param position defines the position of the viewer
  57727. * @param xaxis defines the x axis of the viewer
  57728. * @param yaxis defines the y axis of the viewer
  57729. * @param zaxis defines the z axis of the viewer
  57730. */
  57731. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  57732. /**
  57733. * Creates an instance of this axes viewer.
  57734. * @returns a new axes viewer with instanced meshes
  57735. */
  57736. createInstance(): AxesViewer;
  57737. /** Releases resources */
  57738. dispose(): void;
  57739. private static _SetRenderingGroupId;
  57740. }
  57741. }
  57742. declare module BABYLON.Debug {
  57743. /**
  57744. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  57745. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  57746. */
  57747. export class BoneAxesViewer extends AxesViewer {
  57748. /**
  57749. * Gets or sets the target mesh where to display the axes viewer
  57750. */
  57751. mesh: Nullable<Mesh>;
  57752. /**
  57753. * Gets or sets the target bone where to display the axes viewer
  57754. */
  57755. bone: Nullable<Bone>;
  57756. /** Gets current position */
  57757. pos: Vector3;
  57758. /** Gets direction of X axis */
  57759. xaxis: Vector3;
  57760. /** Gets direction of Y axis */
  57761. yaxis: Vector3;
  57762. /** Gets direction of Z axis */
  57763. zaxis: Vector3;
  57764. /**
  57765. * Creates a new BoneAxesViewer
  57766. * @param scene defines the hosting scene
  57767. * @param bone defines the target bone
  57768. * @param mesh defines the target mesh
  57769. * @param scaleLines defines a scaling factor for line length (1 by default)
  57770. */
  57771. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  57772. /**
  57773. * Force the viewer to update
  57774. */
  57775. update(): void;
  57776. /** Releases resources */
  57777. dispose(): void;
  57778. }
  57779. }
  57780. declare module BABYLON {
  57781. /**
  57782. * Interface used to define scene explorer extensibility option
  57783. */
  57784. export interface IExplorerExtensibilityOption {
  57785. /**
  57786. * Define the option label
  57787. */
  57788. label: string;
  57789. /**
  57790. * Defines the action to execute on click
  57791. */
  57792. action: (entity: any) => void;
  57793. }
  57794. /**
  57795. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  57796. */
  57797. export interface IExplorerExtensibilityGroup {
  57798. /**
  57799. * Defines a predicate to test if a given type mut be extended
  57800. */
  57801. predicate: (entity: any) => boolean;
  57802. /**
  57803. * Gets the list of options added to a type
  57804. */
  57805. entries: IExplorerExtensibilityOption[];
  57806. }
  57807. /**
  57808. * Interface used to define the options to use to create the Inspector
  57809. */
  57810. export interface IInspectorOptions {
  57811. /**
  57812. * Display in overlay mode (default: false)
  57813. */
  57814. overlay?: boolean;
  57815. /**
  57816. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  57817. */
  57818. globalRoot?: HTMLElement;
  57819. /**
  57820. * Display the Scene explorer
  57821. */
  57822. showExplorer?: boolean;
  57823. /**
  57824. * Display the property inspector
  57825. */
  57826. showInspector?: boolean;
  57827. /**
  57828. * Display in embed mode (both panes on the right)
  57829. */
  57830. embedMode?: boolean;
  57831. /**
  57832. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  57833. */
  57834. handleResize?: boolean;
  57835. /**
  57836. * Allow the panes to popup (default: true)
  57837. */
  57838. enablePopup?: boolean;
  57839. /**
  57840. * Allow the panes to be closed by users (default: true)
  57841. */
  57842. enableClose?: boolean;
  57843. /**
  57844. * Optional list of extensibility entries
  57845. */
  57846. explorerExtensibility?: IExplorerExtensibilityGroup[];
  57847. /**
  57848. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  57849. */
  57850. inspectorURL?: string;
  57851. /**
  57852. * Optional initial tab (default to DebugLayerTab.Properties)
  57853. */
  57854. initialTab?: DebugLayerTab;
  57855. }
  57856. interface Scene {
  57857. /**
  57858. * @hidden
  57859. * Backing field
  57860. */
  57861. _debugLayer: DebugLayer;
  57862. /**
  57863. * Gets the debug layer (aka Inspector) associated with the scene
  57864. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57865. */
  57866. debugLayer: DebugLayer;
  57867. }
  57868. /**
  57869. * Enum of inspector action tab
  57870. */
  57871. export enum DebugLayerTab {
  57872. /**
  57873. * Properties tag (default)
  57874. */
  57875. Properties = 0,
  57876. /**
  57877. * Debug tab
  57878. */
  57879. Debug = 1,
  57880. /**
  57881. * Statistics tab
  57882. */
  57883. Statistics = 2,
  57884. /**
  57885. * Tools tab
  57886. */
  57887. Tools = 3,
  57888. /**
  57889. * Settings tab
  57890. */
  57891. Settings = 4
  57892. }
  57893. /**
  57894. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57895. * what is happening in your scene
  57896. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57897. */
  57898. export class DebugLayer {
  57899. /**
  57900. * Define the url to get the inspector script from.
  57901. * By default it uses the babylonjs CDN.
  57902. * @ignoreNaming
  57903. */
  57904. static InspectorURL: string;
  57905. private _scene;
  57906. private BJSINSPECTOR;
  57907. private _onPropertyChangedObservable?;
  57908. /**
  57909. * Observable triggered when a property is changed through the inspector.
  57910. */
  57911. get onPropertyChangedObservable(): any;
  57912. /**
  57913. * Instantiates a new debug layer.
  57914. * The debug layer (aka Inspector) is the go to tool in order to better understand
  57915. * what is happening in your scene
  57916. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57917. * @param scene Defines the scene to inspect
  57918. */
  57919. constructor(scene: Scene);
  57920. /** Creates the inspector window. */
  57921. private _createInspector;
  57922. /**
  57923. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  57924. * @param entity defines the entity to select
  57925. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  57926. */
  57927. select(entity: any, lineContainerTitles?: string | string[]): void;
  57928. /** Get the inspector from bundle or global */
  57929. private _getGlobalInspector;
  57930. /**
  57931. * Get if the inspector is visible or not.
  57932. * @returns true if visible otherwise, false
  57933. */
  57934. isVisible(): boolean;
  57935. /**
  57936. * Hide the inspector and close its window.
  57937. */
  57938. hide(): void;
  57939. /**
  57940. * Update the scene in the inspector
  57941. */
  57942. setAsActiveScene(): void;
  57943. /**
  57944. * Launch the debugLayer.
  57945. * @param config Define the configuration of the inspector
  57946. * @return a promise fulfilled when the debug layer is visible
  57947. */
  57948. show(config?: IInspectorOptions): Promise<DebugLayer>;
  57949. }
  57950. }
  57951. declare module BABYLON.Debug {
  57952. /**
  57953. * Used to show the physics impostor around the specific mesh
  57954. */
  57955. export class PhysicsViewer {
  57956. /** @hidden */
  57957. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  57958. /** @hidden */
  57959. protected _meshes: Array<Nullable<AbstractMesh>>;
  57960. /** @hidden */
  57961. protected _scene: Nullable<Scene>;
  57962. /** @hidden */
  57963. protected _numMeshes: number;
  57964. /** @hidden */
  57965. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  57966. private _renderFunction;
  57967. private _utilityLayer;
  57968. private _debugBoxMesh;
  57969. private _debugSphereMesh;
  57970. private _debugCylinderMesh;
  57971. private _debugMaterial;
  57972. private _debugMeshMeshes;
  57973. /**
  57974. * Creates a new PhysicsViewer
  57975. * @param scene defines the hosting scene
  57976. */
  57977. constructor(scene: Scene);
  57978. /** @hidden */
  57979. protected _updateDebugMeshes(): void;
  57980. /**
  57981. * Renders a specified physic impostor
  57982. * @param impostor defines the impostor to render
  57983. * @param targetMesh defines the mesh represented by the impostor
  57984. * @returns the new debug mesh used to render the impostor
  57985. */
  57986. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  57987. /**
  57988. * Hides a specified physic impostor
  57989. * @param impostor defines the impostor to hide
  57990. */
  57991. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  57992. private _getDebugMaterial;
  57993. private _getDebugBoxMesh;
  57994. private _getDebugSphereMesh;
  57995. private _getDebugCylinderMesh;
  57996. private _getDebugMeshMesh;
  57997. private _getDebugMesh;
  57998. /** Releases all resources */
  57999. dispose(): void;
  58000. }
  58001. }
  58002. declare module BABYLON {
  58003. /**
  58004. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58005. * in order to better appreciate the issue one might have.
  58006. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58007. */
  58008. export class RayHelper {
  58009. /**
  58010. * Defines the ray we are currently tryin to visualize.
  58011. */
  58012. ray: Nullable<Ray>;
  58013. private _renderPoints;
  58014. private _renderLine;
  58015. private _renderFunction;
  58016. private _scene;
  58017. private _onAfterRenderObserver;
  58018. private _onAfterStepObserver;
  58019. private _attachedToMesh;
  58020. private _meshSpaceDirection;
  58021. private _meshSpaceOrigin;
  58022. /**
  58023. * Helper function to create a colored helper in a scene in one line.
  58024. * @param ray Defines the ray we are currently tryin to visualize
  58025. * @param scene Defines the scene the ray is used in
  58026. * @param color Defines the color we want to see the ray in
  58027. * @returns The newly created ray helper.
  58028. */
  58029. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58030. /**
  58031. * Instantiate a new ray helper.
  58032. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58033. * in order to better appreciate the issue one might have.
  58034. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58035. * @param ray Defines the ray we are currently tryin to visualize
  58036. */
  58037. constructor(ray: Ray);
  58038. /**
  58039. * Shows the ray we are willing to debug.
  58040. * @param scene Defines the scene the ray needs to be rendered in
  58041. * @param color Defines the color the ray needs to be rendered in
  58042. */
  58043. show(scene: Scene, color?: Color3): void;
  58044. /**
  58045. * Hides the ray we are debugging.
  58046. */
  58047. hide(): void;
  58048. private _render;
  58049. /**
  58050. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58051. * @param mesh Defines the mesh we want the helper attached to
  58052. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58053. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58054. * @param length Defines the length of the ray
  58055. */
  58056. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58057. /**
  58058. * Detach the ray helper from the mesh it has previously been attached to.
  58059. */
  58060. detachFromMesh(): void;
  58061. private _updateToMesh;
  58062. /**
  58063. * Dispose the helper and release its associated resources.
  58064. */
  58065. dispose(): void;
  58066. }
  58067. }
  58068. declare module BABYLON {
  58069. /**
  58070. * Defines the options associated with the creation of a SkeletonViewer.
  58071. */
  58072. export interface ISkeletonViewerOptions {
  58073. /** Should the system pause animations before building the Viewer? */
  58074. pauseAnimations: boolean;
  58075. /** Should the system return the skeleton to rest before building? */
  58076. returnToRest: boolean;
  58077. /** public Display Mode of the Viewer */
  58078. displayMode: number;
  58079. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58080. displayOptions: ISkeletonViewerDisplayOptions;
  58081. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58082. computeBonesUsingShaders: boolean;
  58083. /** Flag ignore non weighted bones */
  58084. useAllBones: boolean;
  58085. }
  58086. /**
  58087. * Defines how to display the various bone meshes for the viewer.
  58088. */
  58089. export interface ISkeletonViewerDisplayOptions {
  58090. /** How far down to start tapering the bone spurs */
  58091. midStep?: number;
  58092. /** How big is the midStep? */
  58093. midStepFactor?: number;
  58094. /** Base for the Sphere Size */
  58095. sphereBaseSize?: number;
  58096. /** The ratio of the sphere to the longest bone in units */
  58097. sphereScaleUnit?: number;
  58098. /** Ratio for the Sphere Size */
  58099. sphereFactor?: number;
  58100. /** Whether a spur should attach its far end to the child bone position */
  58101. spurFollowsChild?: boolean;
  58102. /** Whether to show local axes or not */
  58103. showLocalAxes?: boolean;
  58104. /** Length of each local axis */
  58105. localAxesSize?: number;
  58106. }
  58107. /**
  58108. * Defines the constructor options for the BoneWeight Shader.
  58109. */
  58110. export interface IBoneWeightShaderOptions {
  58111. /** Skeleton to Map */
  58112. skeleton: Skeleton;
  58113. /** Colors for Uninfluenced bones */
  58114. colorBase?: Color3;
  58115. /** Colors for 0.0-0.25 Weight bones */
  58116. colorZero?: Color3;
  58117. /** Color for 0.25-0.5 Weight Influence */
  58118. colorQuarter?: Color3;
  58119. /** Color for 0.5-0.75 Weight Influence */
  58120. colorHalf?: Color3;
  58121. /** Color for 0.75-1 Weight Influence */
  58122. colorFull?: Color3;
  58123. /** Color for Zero Weight Influence */
  58124. targetBoneIndex?: number;
  58125. }
  58126. /**
  58127. * Simple structure of the gradient steps for the Color Map.
  58128. */
  58129. export interface ISkeletonMapShaderColorMapKnot {
  58130. /** Color of the Knot */
  58131. color: Color3;
  58132. /** Location of the Knot */
  58133. location: number;
  58134. }
  58135. /**
  58136. * Defines the constructor options for the SkeletonMap Shader.
  58137. */
  58138. export interface ISkeletonMapShaderOptions {
  58139. /** Skeleton to Map */
  58140. skeleton: Skeleton;
  58141. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58142. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58143. }
  58144. }
  58145. declare module BABYLON {
  58146. /**
  58147. * Class containing static functions to help procedurally build meshes
  58148. */
  58149. export class RibbonBuilder {
  58150. /**
  58151. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58152. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58153. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58154. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58155. * * 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
  58156. * * 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
  58157. * * 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
  58158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58159. * * 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
  58160. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58161. * * 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
  58162. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58163. * * 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
  58164. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58166. * @param name defines the name of the mesh
  58167. * @param options defines the options used to create the mesh
  58168. * @param scene defines the hosting scene
  58169. * @returns the ribbon mesh
  58170. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58171. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58172. */
  58173. static CreateRibbon(name: string, options: {
  58174. pathArray: Vector3[][];
  58175. closeArray?: boolean;
  58176. closePath?: boolean;
  58177. offset?: number;
  58178. updatable?: boolean;
  58179. sideOrientation?: number;
  58180. frontUVs?: Vector4;
  58181. backUVs?: Vector4;
  58182. instance?: Mesh;
  58183. invertUV?: boolean;
  58184. uvs?: Vector2[];
  58185. colors?: Color4[];
  58186. }, scene?: Nullable<Scene>): Mesh;
  58187. }
  58188. }
  58189. declare module BABYLON {
  58190. /**
  58191. * Class containing static functions to help procedurally build meshes
  58192. */
  58193. export class ShapeBuilder {
  58194. /**
  58195. * 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.
  58196. * * 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.
  58197. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58198. * * 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.
  58199. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58200. * * 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
  58201. * * 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
  58202. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58204. * * 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
  58205. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58206. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58207. * @param name defines the name of the mesh
  58208. * @param options defines the options used to create the mesh
  58209. * @param scene defines the hosting scene
  58210. * @returns the extruded shape mesh
  58211. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58212. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58213. */
  58214. static ExtrudeShape(name: string, options: {
  58215. shape: Vector3[];
  58216. path: Vector3[];
  58217. scale?: number;
  58218. rotation?: number;
  58219. cap?: number;
  58220. updatable?: boolean;
  58221. sideOrientation?: number;
  58222. frontUVs?: Vector4;
  58223. backUVs?: Vector4;
  58224. instance?: Mesh;
  58225. invertUV?: boolean;
  58226. }, scene?: Nullable<Scene>): Mesh;
  58227. /**
  58228. * Creates an custom extruded shape mesh.
  58229. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58230. * * 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.
  58231. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58232. * * 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
  58233. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58234. * * 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
  58235. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58236. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58237. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58238. * * 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
  58239. * * 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
  58240. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58242. * * 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
  58243. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58245. * @param name defines the name of the mesh
  58246. * @param options defines the options used to create the mesh
  58247. * @param scene defines the hosting scene
  58248. * @returns the custom extruded shape mesh
  58249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58250. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58251. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58252. */
  58253. static ExtrudeShapeCustom(name: string, options: {
  58254. shape: Vector3[];
  58255. path: Vector3[];
  58256. scaleFunction?: any;
  58257. rotationFunction?: any;
  58258. ribbonCloseArray?: boolean;
  58259. ribbonClosePath?: boolean;
  58260. cap?: number;
  58261. updatable?: boolean;
  58262. sideOrientation?: number;
  58263. frontUVs?: Vector4;
  58264. backUVs?: Vector4;
  58265. instance?: Mesh;
  58266. invertUV?: boolean;
  58267. }, scene?: Nullable<Scene>): Mesh;
  58268. private static _ExtrudeShapeGeneric;
  58269. }
  58270. }
  58271. declare module BABYLON.Debug {
  58272. /**
  58273. * Class used to render a debug view of a given skeleton
  58274. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  58275. */
  58276. export class SkeletonViewer {
  58277. /** defines the skeleton to render */
  58278. skeleton: Skeleton;
  58279. /** defines the mesh attached to the skeleton */
  58280. mesh: AbstractMesh;
  58281. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58282. autoUpdateBonesMatrices: boolean;
  58283. /** defines the rendering group id to use with the viewer */
  58284. renderingGroupId: number;
  58285. /** is the options for the viewer */
  58286. options: Partial<ISkeletonViewerOptions>;
  58287. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  58288. static readonly DISPLAY_LINES: number;
  58289. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  58290. static readonly DISPLAY_SPHERES: number;
  58291. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  58292. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  58293. /** public static method to create a BoneWeight Shader
  58294. * @param options The constructor options
  58295. * @param scene The scene that the shader is scoped to
  58296. * @returns The created ShaderMaterial
  58297. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  58298. */
  58299. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  58300. /** public static method to create a BoneWeight Shader
  58301. * @param options The constructor options
  58302. * @param scene The scene that the shader is scoped to
  58303. * @returns The created ShaderMaterial
  58304. */
  58305. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  58306. /** private static method to create a BoneWeight Shader
  58307. * @param size The size of the buffer to create (usually the bone count)
  58308. * @param colorMap The gradient data to generate
  58309. * @param scene The scene that the shader is scoped to
  58310. * @returns an Array of floats from the color gradient values
  58311. */
  58312. private static _CreateBoneMapColorBuffer;
  58313. /** If SkeletonViewer scene scope. */
  58314. private _scene;
  58315. /** Gets or sets the color used to render the skeleton */
  58316. color: Color3;
  58317. /** Array of the points of the skeleton fo the line view. */
  58318. private _debugLines;
  58319. /** The SkeletonViewers Mesh. */
  58320. private _debugMesh;
  58321. /** The local axes Meshes. */
  58322. private _localAxes;
  58323. /** If SkeletonViewer is enabled. */
  58324. private _isEnabled;
  58325. /** If SkeletonViewer is ready. */
  58326. private _ready;
  58327. /** SkeletonViewer render observable. */
  58328. private _obs;
  58329. /** The Utility Layer to render the gizmos in. */
  58330. private _utilityLayer;
  58331. private _boneIndices;
  58332. /** Gets the Scene. */
  58333. get scene(): Scene;
  58334. /** Gets the utilityLayer. */
  58335. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58336. /** Checks Ready Status. */
  58337. get isReady(): Boolean;
  58338. /** Sets Ready Status. */
  58339. set ready(value: boolean);
  58340. /** Gets the debugMesh */
  58341. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58342. /** Sets the debugMesh */
  58343. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58344. /** Gets the displayMode */
  58345. get displayMode(): number;
  58346. /** Sets the displayMode */
  58347. set displayMode(value: number);
  58348. /**
  58349. * Creates a new SkeletonViewer
  58350. * @param skeleton defines the skeleton to render
  58351. * @param mesh defines the mesh attached to the skeleton
  58352. * @param scene defines the hosting scene
  58353. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58354. * @param renderingGroupId defines the rendering group id to use with the viewer
  58355. * @param options All of the extra constructor options for the SkeletonViewer
  58356. */
  58357. constructor(
  58358. /** defines the skeleton to render */
  58359. skeleton: Skeleton,
  58360. /** defines the mesh attached to the skeleton */
  58361. mesh: AbstractMesh,
  58362. /** The Scene scope*/
  58363. scene: Scene,
  58364. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58365. autoUpdateBonesMatrices?: boolean,
  58366. /** defines the rendering group id to use with the viewer */
  58367. renderingGroupId?: number,
  58368. /** is the options for the viewer */
  58369. options?: Partial<ISkeletonViewerOptions>);
  58370. /** The Dynamic bindings for the update functions */
  58371. private _bindObs;
  58372. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58373. update(): void;
  58374. /** Gets or sets a boolean indicating if the viewer is enabled */
  58375. set isEnabled(value: boolean);
  58376. get isEnabled(): boolean;
  58377. private _getBonePosition;
  58378. private _getLinesForBonesWithLength;
  58379. private _getLinesForBonesNoLength;
  58380. /** function to revert the mesh and scene back to the initial state. */
  58381. private _revert;
  58382. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58383. private _getAbsoluteBindPoseToRef;
  58384. /** function to build and bind sphere joint points and spur bone representations. */
  58385. private _buildSpheresAndSpurs;
  58386. private _buildLocalAxes;
  58387. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58388. private _displayLinesUpdate;
  58389. /** Changes the displayMode of the skeleton viewer
  58390. * @param mode The displayMode numerical value
  58391. */
  58392. changeDisplayMode(mode: number): void;
  58393. /** Sets a display option of the skeleton viewer
  58394. *
  58395. * | Option | Type | Default | Description |
  58396. * | ---------------- | ------- | ------- | ----------- |
  58397. * | 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`. |
  58398. * | 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`. |
  58399. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58400. * | 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`. |
  58401. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58402. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58403. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58404. *
  58405. * @param option String of the option name
  58406. * @param value The numerical option value
  58407. */
  58408. changeDisplayOptions(option: string, value: number): void;
  58409. /** Release associated resources */
  58410. dispose(): void;
  58411. }
  58412. }
  58413. declare module BABYLON {
  58414. /**
  58415. * Enum for Device Types
  58416. */
  58417. export enum DeviceType {
  58418. /** Generic */
  58419. Generic = 0,
  58420. /** Keyboard */
  58421. Keyboard = 1,
  58422. /** Mouse */
  58423. Mouse = 2,
  58424. /** Touch Pointers */
  58425. Touch = 3,
  58426. /** PS4 Dual Shock */
  58427. DualShock = 4,
  58428. /** Xbox */
  58429. Xbox = 5,
  58430. /** Switch Controller */
  58431. Switch = 6
  58432. }
  58433. /**
  58434. * Enum for All Pointers (Touch/Mouse)
  58435. */
  58436. export enum PointerInput {
  58437. /** Horizontal Axis */
  58438. Horizontal = 0,
  58439. /** Vertical Axis */
  58440. Vertical = 1,
  58441. /** Left Click or Touch */
  58442. LeftClick = 2,
  58443. /** Middle Click */
  58444. MiddleClick = 3,
  58445. /** Right Click */
  58446. RightClick = 4,
  58447. /** Browser Back */
  58448. BrowserBack = 5,
  58449. /** Browser Forward */
  58450. BrowserForward = 6
  58451. }
  58452. /**
  58453. * Enum for Dual Shock Gamepad
  58454. */
  58455. export enum DualShockInput {
  58456. /** Cross */
  58457. Cross = 0,
  58458. /** Circle */
  58459. Circle = 1,
  58460. /** Square */
  58461. Square = 2,
  58462. /** Triangle */
  58463. Triangle = 3,
  58464. /** L1 */
  58465. L1 = 4,
  58466. /** R1 */
  58467. R1 = 5,
  58468. /** L2 */
  58469. L2 = 6,
  58470. /** R2 */
  58471. R2 = 7,
  58472. /** Share */
  58473. Share = 8,
  58474. /** Options */
  58475. Options = 9,
  58476. /** L3 */
  58477. L3 = 10,
  58478. /** R3 */
  58479. R3 = 11,
  58480. /** DPadUp */
  58481. DPadUp = 12,
  58482. /** DPadDown */
  58483. DPadDown = 13,
  58484. /** DPadLeft */
  58485. DPadLeft = 14,
  58486. /** DRight */
  58487. DPadRight = 15,
  58488. /** Home */
  58489. Home = 16,
  58490. /** TouchPad */
  58491. TouchPad = 17,
  58492. /** LStickXAxis */
  58493. LStickXAxis = 18,
  58494. /** LStickYAxis */
  58495. LStickYAxis = 19,
  58496. /** RStickXAxis */
  58497. RStickXAxis = 20,
  58498. /** RStickYAxis */
  58499. RStickYAxis = 21
  58500. }
  58501. /**
  58502. * Enum for Xbox Gamepad
  58503. */
  58504. export enum XboxInput {
  58505. /** A */
  58506. A = 0,
  58507. /** B */
  58508. B = 1,
  58509. /** X */
  58510. X = 2,
  58511. /** Y */
  58512. Y = 3,
  58513. /** LB */
  58514. LB = 4,
  58515. /** RB */
  58516. RB = 5,
  58517. /** LT */
  58518. LT = 6,
  58519. /** RT */
  58520. RT = 7,
  58521. /** Back */
  58522. Back = 8,
  58523. /** Start */
  58524. Start = 9,
  58525. /** LS */
  58526. LS = 10,
  58527. /** RS */
  58528. RS = 11,
  58529. /** DPadUp */
  58530. DPadUp = 12,
  58531. /** DPadDown */
  58532. DPadDown = 13,
  58533. /** DPadLeft */
  58534. DPadLeft = 14,
  58535. /** DRight */
  58536. DPadRight = 15,
  58537. /** Home */
  58538. Home = 16,
  58539. /** LStickXAxis */
  58540. LStickXAxis = 17,
  58541. /** LStickYAxis */
  58542. LStickYAxis = 18,
  58543. /** RStickXAxis */
  58544. RStickXAxis = 19,
  58545. /** RStickYAxis */
  58546. RStickYAxis = 20
  58547. }
  58548. /**
  58549. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58550. */
  58551. export enum SwitchInput {
  58552. /** B */
  58553. B = 0,
  58554. /** A */
  58555. A = 1,
  58556. /** Y */
  58557. Y = 2,
  58558. /** X */
  58559. X = 3,
  58560. /** L */
  58561. L = 4,
  58562. /** R */
  58563. R = 5,
  58564. /** ZL */
  58565. ZL = 6,
  58566. /** ZR */
  58567. ZR = 7,
  58568. /** Minus */
  58569. Minus = 8,
  58570. /** Plus */
  58571. Plus = 9,
  58572. /** LS */
  58573. LS = 10,
  58574. /** RS */
  58575. RS = 11,
  58576. /** DPadUp */
  58577. DPadUp = 12,
  58578. /** DPadDown */
  58579. DPadDown = 13,
  58580. /** DPadLeft */
  58581. DPadLeft = 14,
  58582. /** DRight */
  58583. DPadRight = 15,
  58584. /** Home */
  58585. Home = 16,
  58586. /** Capture */
  58587. Capture = 17,
  58588. /** LStickXAxis */
  58589. LStickXAxis = 18,
  58590. /** LStickYAxis */
  58591. LStickYAxis = 19,
  58592. /** RStickXAxis */
  58593. RStickXAxis = 20,
  58594. /** RStickYAxis */
  58595. RStickYAxis = 21
  58596. }
  58597. }
  58598. declare module BABYLON {
  58599. /**
  58600. * This class will take all inputs from Keyboard, Pointer, and
  58601. * any Gamepads and provide a polling system that all devices
  58602. * will use. This class assumes that there will only be one
  58603. * pointer device and one keyboard.
  58604. */
  58605. export class DeviceInputSystem implements IDisposable {
  58606. /**
  58607. * Returns onDeviceConnected callback property
  58608. * @returns Callback with function to execute when a device is connected
  58609. */
  58610. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58611. /**
  58612. * Sets callback function when a device is connected and executes against all connected devices
  58613. * @param callback Function to execute when a device is connected
  58614. */
  58615. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58616. /**
  58617. * Callback to be triggered when a device is disconnected
  58618. */
  58619. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58620. /**
  58621. * Callback to be triggered when event driven input is updated
  58622. */
  58623. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58624. private _inputs;
  58625. private _gamepads;
  58626. private _keyboardActive;
  58627. private _pointerActive;
  58628. private _elementToAttachTo;
  58629. private _keyboardDownEvent;
  58630. private _keyboardUpEvent;
  58631. private _pointerMoveEvent;
  58632. private _pointerDownEvent;
  58633. private _pointerUpEvent;
  58634. private _gamepadConnectedEvent;
  58635. private _gamepadDisconnectedEvent;
  58636. private _onDeviceConnected;
  58637. private static _MAX_KEYCODES;
  58638. private static _MAX_POINTER_INPUTS;
  58639. private constructor();
  58640. /**
  58641. * Creates a new DeviceInputSystem instance
  58642. * @param engine Engine to pull input element from
  58643. * @returns The new instance
  58644. */
  58645. static Create(engine: Engine): DeviceInputSystem;
  58646. /**
  58647. * Checks for current device input value, given an id and input index
  58648. * @param deviceName Id of connected device
  58649. * @param inputIndex Index of device input
  58650. * @returns Current value of input
  58651. */
  58652. /**
  58653. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58654. * @param deviceType Enum specifiying device type
  58655. * @param deviceSlot "Slot" or index that device is referenced in
  58656. * @param inputIndex Id of input to be checked
  58657. * @returns Current value of input
  58658. */
  58659. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58660. /**
  58661. * Dispose of all the eventlisteners
  58662. */
  58663. dispose(): void;
  58664. /**
  58665. * Checks for existing connections to devices and register them, if necessary
  58666. * Currently handles gamepads and mouse
  58667. */
  58668. private _checkForConnectedDevices;
  58669. /**
  58670. * Add a gamepad to the DeviceInputSystem
  58671. * @param gamepad A single DOM Gamepad object
  58672. */
  58673. private _addGamePad;
  58674. /**
  58675. * Add pointer device to DeviceInputSystem
  58676. * @param deviceType Type of Pointer to add
  58677. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58678. * @param currentX Current X at point of adding
  58679. * @param currentY Current Y at point of adding
  58680. */
  58681. private _addPointerDevice;
  58682. /**
  58683. * Add device and inputs to device array
  58684. * @param deviceType Enum specifiying device type
  58685. * @param deviceSlot "Slot" or index that device is referenced in
  58686. * @param numberOfInputs Number of input entries to create for given device
  58687. */
  58688. private _registerDevice;
  58689. /**
  58690. * Given a specific device name, remove that device from the device map
  58691. * @param deviceType Enum specifiying device type
  58692. * @param deviceSlot "Slot" or index that device is referenced in
  58693. */
  58694. private _unregisterDevice;
  58695. /**
  58696. * Handle all actions that come from keyboard interaction
  58697. */
  58698. private _handleKeyActions;
  58699. /**
  58700. * Handle all actions that come from pointer interaction
  58701. */
  58702. private _handlePointerActions;
  58703. /**
  58704. * Handle all actions that come from gamepad interaction
  58705. */
  58706. private _handleGamepadActions;
  58707. /**
  58708. * Update all non-event based devices with each frame
  58709. * @param deviceType Enum specifiying device type
  58710. * @param deviceSlot "Slot" or index that device is referenced in
  58711. * @param inputIndex Id of input to be checked
  58712. */
  58713. private _updateDevice;
  58714. /**
  58715. * Gets DeviceType from the device name
  58716. * @param deviceName Name of Device from DeviceInputSystem
  58717. * @returns DeviceType enum value
  58718. */
  58719. private _getGamepadDeviceType;
  58720. }
  58721. }
  58722. declare module BABYLON {
  58723. /**
  58724. * Type to handle enforcement of inputs
  58725. */
  58726. 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;
  58727. }
  58728. declare module BABYLON {
  58729. /**
  58730. * Class that handles all input for a specific device
  58731. */
  58732. export class DeviceSource<T extends DeviceType> {
  58733. /** Type of device */
  58734. readonly deviceType: DeviceType;
  58735. /** "Slot" or index that device is referenced in */
  58736. readonly deviceSlot: number;
  58737. /**
  58738. * Observable to handle device input changes per device
  58739. */
  58740. readonly onInputChangedObservable: Observable<{
  58741. inputIndex: DeviceInput<T>;
  58742. previousState: Nullable<number>;
  58743. currentState: Nullable<number>;
  58744. }>;
  58745. private readonly _deviceInputSystem;
  58746. /**
  58747. * Default Constructor
  58748. * @param deviceInputSystem Reference to DeviceInputSystem
  58749. * @param deviceType Type of device
  58750. * @param deviceSlot "Slot" or index that device is referenced in
  58751. */
  58752. constructor(deviceInputSystem: DeviceInputSystem,
  58753. /** Type of device */
  58754. deviceType: DeviceType,
  58755. /** "Slot" or index that device is referenced in */
  58756. deviceSlot?: number);
  58757. /**
  58758. * Get input for specific input
  58759. * @param inputIndex index of specific input on device
  58760. * @returns Input value from DeviceInputSystem
  58761. */
  58762. getInput(inputIndex: DeviceInput<T>): number;
  58763. }
  58764. /**
  58765. * Class to keep track of devices
  58766. */
  58767. export class DeviceSourceManager implements IDisposable {
  58768. /**
  58769. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  58770. */
  58771. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  58772. /**
  58773. * Observable to be triggered when after a device is disconnected
  58774. */
  58775. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  58776. private readonly _devices;
  58777. private readonly _firstDevice;
  58778. private readonly _deviceInputSystem;
  58779. /**
  58780. * Default Constructor
  58781. * @param engine engine to pull input element from
  58782. */
  58783. constructor(engine: Engine);
  58784. /**
  58785. * Gets a DeviceSource, given a type and slot
  58786. * @param deviceType Enum specifying device type
  58787. * @param deviceSlot "Slot" or index that device is referenced in
  58788. * @returns DeviceSource object
  58789. */
  58790. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  58791. /**
  58792. * Gets an array of DeviceSource objects for a given device type
  58793. * @param deviceType Enum specifying device type
  58794. * @returns Array of DeviceSource objects
  58795. */
  58796. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  58797. /**
  58798. * Returns a read-only list of all available devices
  58799. * @returns Read-only array with active devices
  58800. */
  58801. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  58802. /**
  58803. * Dispose of DeviceInputSystem and other parts
  58804. */
  58805. dispose(): void;
  58806. /**
  58807. * Function to add device name to device list
  58808. * @param deviceType Enum specifying device type
  58809. * @param deviceSlot "Slot" or index that device is referenced in
  58810. */
  58811. private _addDevice;
  58812. /**
  58813. * Function to remove device name to device list
  58814. * @param deviceType Enum specifying device type
  58815. * @param deviceSlot "Slot" or index that device is referenced in
  58816. */
  58817. private _removeDevice;
  58818. /**
  58819. * Updates array storing first connected device of each type
  58820. * @param type Type of Device
  58821. */
  58822. private _updateFirstDevices;
  58823. }
  58824. }
  58825. declare module BABYLON {
  58826. /**
  58827. * Options to create the null engine
  58828. */
  58829. export class NullEngineOptions {
  58830. /**
  58831. * Render width (Default: 512)
  58832. */
  58833. renderWidth: number;
  58834. /**
  58835. * Render height (Default: 256)
  58836. */
  58837. renderHeight: number;
  58838. /**
  58839. * Texture size (Default: 512)
  58840. */
  58841. textureSize: number;
  58842. /**
  58843. * If delta time between frames should be constant
  58844. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58845. */
  58846. deterministicLockstep: boolean;
  58847. /**
  58848. * Maximum about of steps between frames (Default: 4)
  58849. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58850. */
  58851. lockstepMaxSteps: number;
  58852. /**
  58853. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  58854. */
  58855. useHighPrecisionMatrix?: boolean;
  58856. }
  58857. /**
  58858. * The null engine class provides support for headless version of babylon.js.
  58859. * This can be used in server side scenario or for testing purposes
  58860. */
  58861. export class NullEngine extends Engine {
  58862. private _options;
  58863. /**
  58864. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  58865. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58866. * @returns true if engine is in deterministic lock step mode
  58867. */
  58868. isDeterministicLockStep(): boolean;
  58869. /**
  58870. * Gets the max steps when engine is running in deterministic lock step
  58871. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58872. * @returns the max steps
  58873. */
  58874. getLockstepMaxSteps(): number;
  58875. /**
  58876. * Gets the current hardware scaling level.
  58877. * By default the hardware scaling level is computed from the window device ratio.
  58878. * 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.
  58879. * @returns a number indicating the current hardware scaling level
  58880. */
  58881. getHardwareScalingLevel(): number;
  58882. constructor(options?: NullEngineOptions);
  58883. /**
  58884. * Creates a vertex buffer
  58885. * @param vertices the data for the vertex buffer
  58886. * @returns the new WebGL static buffer
  58887. */
  58888. createVertexBuffer(vertices: FloatArray): DataBuffer;
  58889. /**
  58890. * Creates a new index buffer
  58891. * @param indices defines the content of the index buffer
  58892. * @param updatable defines if the index buffer must be updatable
  58893. * @returns a new webGL buffer
  58894. */
  58895. createIndexBuffer(indices: IndicesArray): DataBuffer;
  58896. /**
  58897. * Clear the current render buffer or the current render target (if any is set up)
  58898. * @param color defines the color to use
  58899. * @param backBuffer defines if the back buffer must be cleared
  58900. * @param depth defines if the depth buffer must be cleared
  58901. * @param stencil defines if the stencil buffer must be cleared
  58902. */
  58903. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58904. /**
  58905. * Gets the current render width
  58906. * @param useScreen defines if screen size must be used (or the current render target if any)
  58907. * @returns a number defining the current render width
  58908. */
  58909. getRenderWidth(useScreen?: boolean): number;
  58910. /**
  58911. * Gets the current render height
  58912. * @param useScreen defines if screen size must be used (or the current render target if any)
  58913. * @returns a number defining the current render height
  58914. */
  58915. getRenderHeight(useScreen?: boolean): number;
  58916. /**
  58917. * Set the WebGL's viewport
  58918. * @param viewport defines the viewport element to be used
  58919. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  58920. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  58921. */
  58922. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  58923. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  58924. /**
  58925. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  58926. * @param pipelineContext defines the pipeline context to use
  58927. * @param uniformsNames defines the list of uniform names
  58928. * @returns an array of webGL uniform locations
  58929. */
  58930. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  58931. /**
  58932. * Gets the lsit of active attributes for a given webGL program
  58933. * @param pipelineContext defines the pipeline context to use
  58934. * @param attributesNames defines the list of attribute names to get
  58935. * @returns an array of indices indicating the offset of each attribute
  58936. */
  58937. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58938. /**
  58939. * Binds an effect to the webGL context
  58940. * @param effect defines the effect to bind
  58941. */
  58942. bindSamplers(effect: Effect): void;
  58943. /**
  58944. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  58945. * @param effect defines the effect to activate
  58946. */
  58947. enableEffect(effect: Effect): void;
  58948. /**
  58949. * Set various states to the webGL context
  58950. * @param culling defines backface culling state
  58951. * @param zOffset defines the value to apply to zOffset (0 by default)
  58952. * @param force defines if states must be applied even if cache is up to date
  58953. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  58954. */
  58955. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58956. /**
  58957. * Set the value of an uniform to an array of int32
  58958. * @param uniform defines the webGL uniform location where to store the value
  58959. * @param array defines the array of int32 to store
  58960. * @returns true if value was set
  58961. */
  58962. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58963. /**
  58964. * Set the value of an uniform to an array of int32 (stored as vec2)
  58965. * @param uniform defines the webGL uniform location where to store the value
  58966. * @param array defines the array of int32 to store
  58967. * @returns true if value was set
  58968. */
  58969. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58970. /**
  58971. * Set the value of an uniform to an array of int32 (stored as vec3)
  58972. * @param uniform defines the webGL uniform location where to store the value
  58973. * @param array defines the array of int32 to store
  58974. * @returns true if value was set
  58975. */
  58976. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58977. /**
  58978. * Set the value of an uniform to an array of int32 (stored as vec4)
  58979. * @param uniform defines the webGL uniform location where to store the value
  58980. * @param array defines the array of int32 to store
  58981. * @returns true if value was set
  58982. */
  58983. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58984. /**
  58985. * Set the value of an uniform to an array of float32
  58986. * @param uniform defines the webGL uniform location where to store the value
  58987. * @param array defines the array of float32 to store
  58988. * @returns true if value was set
  58989. */
  58990. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58991. /**
  58992. * Set the value of an uniform to an array of float32 (stored as vec2)
  58993. * @param uniform defines the webGL uniform location where to store the value
  58994. * @param array defines the array of float32 to store
  58995. * @returns true if value was set
  58996. */
  58997. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58998. /**
  58999. * Set the value of an uniform to an array of float32 (stored as vec3)
  59000. * @param uniform defines the webGL uniform location where to store the value
  59001. * @param array defines the array of float32 to store
  59002. * @returns true if value was set
  59003. */
  59004. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59005. /**
  59006. * Set the value of an uniform to an array of float32 (stored as vec4)
  59007. * @param uniform defines the webGL uniform location where to store the value
  59008. * @param array defines the array of float32 to store
  59009. * @returns true if value was set
  59010. */
  59011. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59012. /**
  59013. * Set the value of an uniform to an array of number
  59014. * @param uniform defines the webGL uniform location where to store the value
  59015. * @param array defines the array of number to store
  59016. * @returns true if value was set
  59017. */
  59018. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59019. /**
  59020. * Set the value of an uniform to an array of number (stored as vec2)
  59021. * @param uniform defines the webGL uniform location where to store the value
  59022. * @param array defines the array of number to store
  59023. * @returns true if value was set
  59024. */
  59025. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59026. /**
  59027. * Set the value of an uniform to an array of number (stored as vec3)
  59028. * @param uniform defines the webGL uniform location where to store the value
  59029. * @param array defines the array of number to store
  59030. * @returns true if value was set
  59031. */
  59032. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59033. /**
  59034. * Set the value of an uniform to an array of number (stored as vec4)
  59035. * @param uniform defines the webGL uniform location where to store the value
  59036. * @param array defines the array of number to store
  59037. * @returns true if value was set
  59038. */
  59039. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59040. /**
  59041. * Set the value of an uniform to an array of float32 (stored as matrices)
  59042. * @param uniform defines the webGL uniform location where to store the value
  59043. * @param matrices defines the array of float32 to store
  59044. * @returns true if value was set
  59045. */
  59046. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59047. /**
  59048. * Set the value of an uniform to a matrix (3x3)
  59049. * @param uniform defines the webGL uniform location where to store the value
  59050. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59051. * @returns true if value was set
  59052. */
  59053. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59054. /**
  59055. * Set the value of an uniform to a matrix (2x2)
  59056. * @param uniform defines the webGL uniform location where to store the value
  59057. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59058. * @returns true if value was set
  59059. */
  59060. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59061. /**
  59062. * Set the value of an uniform to a number (float)
  59063. * @param uniform defines the webGL uniform location where to store the value
  59064. * @param value defines the float number to store
  59065. * @returns true if value was set
  59066. */
  59067. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59068. /**
  59069. * Set the value of an uniform to a vec2
  59070. * @param uniform defines the webGL uniform location where to store the value
  59071. * @param x defines the 1st component of the value
  59072. * @param y defines the 2nd component of the value
  59073. * @returns true if value was set
  59074. */
  59075. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59076. /**
  59077. * Set the value of an uniform to a vec3
  59078. * @param uniform defines the webGL uniform location where to store the value
  59079. * @param x defines the 1st component of the value
  59080. * @param y defines the 2nd component of the value
  59081. * @param z defines the 3rd component of the value
  59082. * @returns true if value was set
  59083. */
  59084. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59085. /**
  59086. * Set the value of an uniform to a boolean
  59087. * @param uniform defines the webGL uniform location where to store the value
  59088. * @param bool defines the boolean to store
  59089. * @returns true if value was set
  59090. */
  59091. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59092. /**
  59093. * Set the value of an uniform to a vec4
  59094. * @param uniform defines the webGL uniform location where to store the value
  59095. * @param x defines the 1st component of the value
  59096. * @param y defines the 2nd component of the value
  59097. * @param z defines the 3rd component of the value
  59098. * @param w defines the 4th component of the value
  59099. * @returns true if value was set
  59100. */
  59101. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59102. /**
  59103. * Sets the current alpha mode
  59104. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59105. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59106. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59107. */
  59108. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59109. /**
  59110. * Bind webGl buffers directly to the webGL context
  59111. * @param vertexBuffers defines the vertex buffer to bind
  59112. * @param indexBuffer defines the index buffer to bind
  59113. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59114. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59115. * @param effect defines the effect associated with the vertex buffer
  59116. */
  59117. bindBuffers(vertexBuffers: {
  59118. [key: string]: VertexBuffer;
  59119. }, indexBuffer: DataBuffer, effect: Effect): void;
  59120. /**
  59121. * Force the entire cache to be cleared
  59122. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59123. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59124. */
  59125. wipeCaches(bruteForce?: boolean): void;
  59126. /**
  59127. * Send a draw order
  59128. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59129. * @param indexStart defines the starting index
  59130. * @param indexCount defines the number of index to draw
  59131. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59132. */
  59133. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59134. /**
  59135. * Draw a list of indexed primitives
  59136. * @param fillMode defines the primitive to use
  59137. * @param indexStart defines the starting index
  59138. * @param indexCount defines the number of index to draw
  59139. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59140. */
  59141. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59142. /**
  59143. * Draw a list of unindexed primitives
  59144. * @param fillMode defines the primitive to use
  59145. * @param verticesStart defines the index of first vertex to draw
  59146. * @param verticesCount defines the count of vertices to draw
  59147. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59148. */
  59149. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59150. /** @hidden */
  59151. protected _createTexture(): WebGLTexture;
  59152. /** @hidden */
  59153. _releaseTexture(texture: InternalTexture): void;
  59154. /**
  59155. * Usually called from Texture.ts.
  59156. * Passed information to create a WebGLTexture
  59157. * @param urlArg defines a value which contains one of the following:
  59158. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59159. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59160. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59161. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59162. * @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)
  59163. * @param scene needed for loading to the correct scene
  59164. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59165. * @param onLoad optional callback to be called upon successful completion
  59166. * @param onError optional callback to be called upon failure
  59167. * @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
  59168. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59169. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59170. * @param forcedExtension defines the extension to use to pick the right loader
  59171. * @param mimeType defines an optional mime type
  59172. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59173. */
  59174. 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;
  59175. /**
  59176. * Creates a new render target texture
  59177. * @param size defines the size of the texture
  59178. * @param options defines the options used to create the texture
  59179. * @returns a new render target texture stored in an InternalTexture
  59180. */
  59181. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59182. /**
  59183. * Update the sampling mode of a given texture
  59184. * @param samplingMode defines the required sampling mode
  59185. * @param texture defines the texture to update
  59186. */
  59187. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59188. /**
  59189. * Binds the frame buffer to the specified texture.
  59190. * @param texture The texture to render to or null for the default canvas
  59191. * @param faceIndex The face of the texture to render to in case of cube texture
  59192. * @param requiredWidth The width of the target to render to
  59193. * @param requiredHeight The height of the target to render to
  59194. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59195. * @param lodLevel defines le lod level to bind to the frame buffer
  59196. */
  59197. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59198. /**
  59199. * Unbind the current render target texture from the webGL context
  59200. * @param texture defines the render target texture to unbind
  59201. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59202. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59203. */
  59204. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59205. /**
  59206. * Creates a dynamic vertex buffer
  59207. * @param vertices the data for the dynamic vertex buffer
  59208. * @returns the new WebGL dynamic buffer
  59209. */
  59210. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  59211. /**
  59212. * Update the content of a dynamic texture
  59213. * @param texture defines the texture to update
  59214. * @param canvas defines the canvas containing the source
  59215. * @param invertY defines if data must be stored with Y axis inverted
  59216. * @param premulAlpha defines if alpha is stored as premultiplied
  59217. * @param format defines the format of the data
  59218. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59219. */
  59220. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59221. /**
  59222. * Gets a boolean indicating if all created effects are ready
  59223. * @returns true if all effects are ready
  59224. */
  59225. areAllEffectsReady(): boolean;
  59226. /**
  59227. * @hidden
  59228. * Get the current error code of the webGL context
  59229. * @returns the error code
  59230. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  59231. */
  59232. getError(): number;
  59233. /** @hidden */
  59234. _getUnpackAlignement(): number;
  59235. /** @hidden */
  59236. _unpackFlipY(value: boolean): void;
  59237. /**
  59238. * Update a dynamic index buffer
  59239. * @param indexBuffer defines the target index buffer
  59240. * @param indices defines the data to update
  59241. * @param offset defines the offset in the target index buffer where update should start
  59242. */
  59243. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  59244. /**
  59245. * Updates a dynamic vertex buffer.
  59246. * @param vertexBuffer the vertex buffer to update
  59247. * @param vertices the data used to update the vertex buffer
  59248. * @param byteOffset the byte offset of the data (optional)
  59249. * @param byteLength the byte length of the data (optional)
  59250. */
  59251. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  59252. /** @hidden */
  59253. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  59254. /** @hidden */
  59255. _bindTexture(channel: number, texture: InternalTexture): void;
  59256. protected _deleteBuffer(buffer: WebGLBuffer): void;
  59257. /**
  59258. * 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
  59259. */
  59260. releaseEffects(): void;
  59261. displayLoadingUI(): void;
  59262. hideLoadingUI(): void;
  59263. /** @hidden */
  59264. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59265. /** @hidden */
  59266. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59267. /** @hidden */
  59268. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59269. /** @hidden */
  59270. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59271. }
  59272. }
  59273. declare module BABYLON {
  59274. /** @hidden */
  59275. export class _OcclusionDataStorage {
  59276. /** @hidden */
  59277. occlusionInternalRetryCounter: number;
  59278. /** @hidden */
  59279. isOcclusionQueryInProgress: boolean;
  59280. /** @hidden */
  59281. isOccluded: boolean;
  59282. /** @hidden */
  59283. occlusionRetryCount: number;
  59284. /** @hidden */
  59285. occlusionType: number;
  59286. /** @hidden */
  59287. occlusionQueryAlgorithmType: number;
  59288. }
  59289. interface Engine {
  59290. /**
  59291. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59292. * @return the new query
  59293. */
  59294. createQuery(): WebGLQuery;
  59295. /**
  59296. * Delete and release a webGL query
  59297. * @param query defines the query to delete
  59298. * @return the current engine
  59299. */
  59300. deleteQuery(query: WebGLQuery): Engine;
  59301. /**
  59302. * Check if a given query has resolved and got its value
  59303. * @param query defines the query to check
  59304. * @returns true if the query got its value
  59305. */
  59306. isQueryResultAvailable(query: WebGLQuery): boolean;
  59307. /**
  59308. * Gets the value of a given query
  59309. * @param query defines the query to check
  59310. * @returns the value of the query
  59311. */
  59312. getQueryResult(query: WebGLQuery): number;
  59313. /**
  59314. * Initiates an occlusion query
  59315. * @param algorithmType defines the algorithm to use
  59316. * @param query defines the query to use
  59317. * @returns the current engine
  59318. * @see https://doc.babylonjs.com/features/occlusionquery
  59319. */
  59320. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59321. /**
  59322. * Ends an occlusion query
  59323. * @see https://doc.babylonjs.com/features/occlusionquery
  59324. * @param algorithmType defines the algorithm to use
  59325. * @returns the current engine
  59326. */
  59327. endOcclusionQuery(algorithmType: number): Engine;
  59328. /**
  59329. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59330. * Please note that only one query can be issued at a time
  59331. * @returns a time token used to track the time span
  59332. */
  59333. startTimeQuery(): Nullable<_TimeToken>;
  59334. /**
  59335. * Ends a time query
  59336. * @param token defines the token used to measure the time span
  59337. * @returns the time spent (in ns)
  59338. */
  59339. endTimeQuery(token: _TimeToken): int;
  59340. /** @hidden */
  59341. _currentNonTimestampToken: Nullable<_TimeToken>;
  59342. /** @hidden */
  59343. _createTimeQuery(): WebGLQuery;
  59344. /** @hidden */
  59345. _deleteTimeQuery(query: WebGLQuery): void;
  59346. /** @hidden */
  59347. _getGlAlgorithmType(algorithmType: number): number;
  59348. /** @hidden */
  59349. _getTimeQueryResult(query: WebGLQuery): any;
  59350. /** @hidden */
  59351. _getTimeQueryAvailability(query: WebGLQuery): any;
  59352. }
  59353. interface AbstractMesh {
  59354. /**
  59355. * Backing filed
  59356. * @hidden
  59357. */
  59358. __occlusionDataStorage: _OcclusionDataStorage;
  59359. /**
  59360. * Access property
  59361. * @hidden
  59362. */
  59363. _occlusionDataStorage: _OcclusionDataStorage;
  59364. /**
  59365. * 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.
  59366. * The default value is -1 which means don't break the query and wait till the result
  59367. * @see https://doc.babylonjs.com/features/occlusionquery
  59368. */
  59369. occlusionRetryCount: number;
  59370. /**
  59371. * 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:
  59372. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59373. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59374. * * 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.
  59375. * @see https://doc.babylonjs.com/features/occlusionquery
  59376. */
  59377. occlusionType: number;
  59378. /**
  59379. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59380. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59381. * * 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.
  59382. * @see https://doc.babylonjs.com/features/occlusionquery
  59383. */
  59384. occlusionQueryAlgorithmType: number;
  59385. /**
  59386. * 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
  59387. * @see https://doc.babylonjs.com/features/occlusionquery
  59388. */
  59389. isOccluded: boolean;
  59390. /**
  59391. * Flag to check the progress status of the query
  59392. * @see https://doc.babylonjs.com/features/occlusionquery
  59393. */
  59394. isOcclusionQueryInProgress: boolean;
  59395. }
  59396. }
  59397. declare module BABYLON {
  59398. /** @hidden */
  59399. export var _forceTransformFeedbackToBundle: boolean;
  59400. interface Engine {
  59401. /**
  59402. * Creates a webGL transform feedback object
  59403. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59404. * @returns the webGL transform feedback object
  59405. */
  59406. createTransformFeedback(): WebGLTransformFeedback;
  59407. /**
  59408. * Delete a webGL transform feedback object
  59409. * @param value defines the webGL transform feedback object to delete
  59410. */
  59411. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59412. /**
  59413. * Bind a webGL transform feedback object to the webgl context
  59414. * @param value defines the webGL transform feedback object to bind
  59415. */
  59416. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59417. /**
  59418. * Begins a transform feedback operation
  59419. * @param usePoints defines if points or triangles must be used
  59420. */
  59421. beginTransformFeedback(usePoints: boolean): void;
  59422. /**
  59423. * Ends a transform feedback operation
  59424. */
  59425. endTransformFeedback(): void;
  59426. /**
  59427. * Specify the varyings to use with transform feedback
  59428. * @param program defines the associated webGL program
  59429. * @param value defines the list of strings representing the varying names
  59430. */
  59431. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59432. /**
  59433. * Bind a webGL buffer for a transform feedback operation
  59434. * @param value defines the webGL buffer to bind
  59435. */
  59436. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59437. }
  59438. }
  59439. declare module BABYLON {
  59440. /**
  59441. * Class used to define an additional view for the engine
  59442. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59443. */
  59444. export class EngineView {
  59445. /** Defines the canvas where to render the view */
  59446. target: HTMLCanvasElement;
  59447. /** Defines an optional camera used to render the view (will use active camera else) */
  59448. camera?: Camera;
  59449. }
  59450. interface Engine {
  59451. /**
  59452. * Gets or sets the HTML element to use for attaching events
  59453. */
  59454. inputElement: Nullable<HTMLElement>;
  59455. /**
  59456. * Gets the current engine view
  59457. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59458. */
  59459. activeView: Nullable<EngineView>;
  59460. /** Gets or sets the list of views */
  59461. views: EngineView[];
  59462. /**
  59463. * Register a new child canvas
  59464. * @param canvas defines the canvas to register
  59465. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59466. * @returns the associated view
  59467. */
  59468. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59469. /**
  59470. * Remove a registered child canvas
  59471. * @param canvas defines the canvas to remove
  59472. * @returns the current engine
  59473. */
  59474. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59475. }
  59476. }
  59477. declare module BABYLON {
  59478. interface Engine {
  59479. /** @hidden */
  59480. _excludedCompressedTextures: string[];
  59481. /** @hidden */
  59482. _textureFormatInUse: string;
  59483. /**
  59484. * Gets the list of texture formats supported
  59485. */
  59486. readonly texturesSupported: Array<string>;
  59487. /**
  59488. * Gets the texture format in use
  59489. */
  59490. readonly textureFormatInUse: Nullable<string>;
  59491. /**
  59492. * Set the compressed texture extensions or file names to skip.
  59493. *
  59494. * @param skippedFiles defines the list of those texture files you want to skip
  59495. * Example: [".dds", ".env", "myfile.png"]
  59496. */
  59497. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59498. /**
  59499. * Set the compressed texture format to use, based on the formats you have, and the formats
  59500. * supported by the hardware / browser.
  59501. *
  59502. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59503. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59504. * to API arguments needed to compressed textures. This puts the burden on the container
  59505. * generator to house the arcane code for determining these for current & future formats.
  59506. *
  59507. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59508. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59509. *
  59510. * Note: The result of this call is not taken into account when a texture is base64.
  59511. *
  59512. * @param formatsAvailable defines the list of those format families you have created
  59513. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59514. *
  59515. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59516. * @returns The extension selected.
  59517. */
  59518. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59519. }
  59520. }
  59521. declare module BABYLON {
  59522. /** @hidden */
  59523. export var rgbdEncodePixelShader: {
  59524. name: string;
  59525. shader: string;
  59526. };
  59527. }
  59528. declare module BABYLON {
  59529. /**
  59530. * Raw texture data and descriptor sufficient for WebGL texture upload
  59531. */
  59532. export interface EnvironmentTextureInfo {
  59533. /**
  59534. * Version of the environment map
  59535. */
  59536. version: number;
  59537. /**
  59538. * Width of image
  59539. */
  59540. width: number;
  59541. /**
  59542. * Irradiance information stored in the file.
  59543. */
  59544. irradiance: any;
  59545. /**
  59546. * Specular information stored in the file.
  59547. */
  59548. specular: any;
  59549. }
  59550. /**
  59551. * Defines One Image in the file. It requires only the position in the file
  59552. * as well as the length.
  59553. */
  59554. interface BufferImageData {
  59555. /**
  59556. * Length of the image data.
  59557. */
  59558. length: number;
  59559. /**
  59560. * Position of the data from the null terminator delimiting the end of the JSON.
  59561. */
  59562. position: number;
  59563. }
  59564. /**
  59565. * Defines the specular data enclosed in the file.
  59566. * This corresponds to the version 1 of the data.
  59567. */
  59568. export interface EnvironmentTextureSpecularInfoV1 {
  59569. /**
  59570. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59571. */
  59572. specularDataPosition?: number;
  59573. /**
  59574. * This contains all the images data needed to reconstruct the cubemap.
  59575. */
  59576. mipmaps: Array<BufferImageData>;
  59577. /**
  59578. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59579. */
  59580. lodGenerationScale: number;
  59581. }
  59582. /**
  59583. * Sets of helpers addressing the serialization and deserialization of environment texture
  59584. * stored in a BabylonJS env file.
  59585. * Those files are usually stored as .env files.
  59586. */
  59587. export class EnvironmentTextureTools {
  59588. /**
  59589. * Magic number identifying the env file.
  59590. */
  59591. private static _MagicBytes;
  59592. /**
  59593. * Gets the environment info from an env file.
  59594. * @param data The array buffer containing the .env bytes.
  59595. * @returns the environment file info (the json header) if successfully parsed.
  59596. */
  59597. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59598. /**
  59599. * Creates an environment texture from a loaded cube texture.
  59600. * @param texture defines the cube texture to convert in env file
  59601. * @return a promise containing the environment data if succesfull.
  59602. */
  59603. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59604. /**
  59605. * Creates a JSON representation of the spherical data.
  59606. * @param texture defines the texture containing the polynomials
  59607. * @return the JSON representation of the spherical info
  59608. */
  59609. private static _CreateEnvTextureIrradiance;
  59610. /**
  59611. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59612. * @param data the image data
  59613. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59614. * @return the views described by info providing access to the underlying buffer
  59615. */
  59616. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59617. /**
  59618. * Uploads the texture info contained in the env file to the GPU.
  59619. * @param texture defines the internal texture to upload to
  59620. * @param data defines the data to load
  59621. * @param info defines the texture info retrieved through the GetEnvInfo method
  59622. * @returns a promise
  59623. */
  59624. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59625. private static _OnImageReadyAsync;
  59626. /**
  59627. * Uploads the levels of image data to the GPU.
  59628. * @param texture defines the internal texture to upload to
  59629. * @param imageData defines the array buffer views of image data [mipmap][face]
  59630. * @returns a promise
  59631. */
  59632. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59633. /**
  59634. * Uploads spherical polynomials information to the texture.
  59635. * @param texture defines the texture we are trying to upload the information to
  59636. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59637. */
  59638. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59639. /** @hidden */
  59640. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59641. }
  59642. }
  59643. declare module BABYLON {
  59644. /**
  59645. * Container for accessors for natively-stored mesh data buffers.
  59646. */
  59647. class NativeDataBuffer extends DataBuffer {
  59648. /**
  59649. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59650. */
  59651. nativeIndexBuffer?: any;
  59652. /**
  59653. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59654. */
  59655. nativeVertexBuffer?: any;
  59656. }
  59657. /** @hidden */
  59658. class NativeTexture extends InternalTexture {
  59659. getInternalTexture(): InternalTexture;
  59660. getViewCount(): number;
  59661. }
  59662. /** @hidden */
  59663. export class NativeEngine extends Engine {
  59664. private readonly _native;
  59665. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59666. private readonly INVALID_HANDLE;
  59667. private _boundBuffersVertexArray;
  59668. private _currentDepthTest;
  59669. getHardwareScalingLevel(): number;
  59670. constructor();
  59671. dispose(): void;
  59672. /**
  59673. * Can be used to override the current requestAnimationFrame requester.
  59674. * @hidden
  59675. */
  59676. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59677. /**
  59678. * Override default engine behavior.
  59679. * @param color
  59680. * @param backBuffer
  59681. * @param depth
  59682. * @param stencil
  59683. */
  59684. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59685. /**
  59686. * Gets host document
  59687. * @returns the host document object
  59688. */
  59689. getHostDocument(): Nullable<Document>;
  59690. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59691. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59692. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59693. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59694. [key: string]: VertexBuffer;
  59695. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59696. bindBuffers(vertexBuffers: {
  59697. [key: string]: VertexBuffer;
  59698. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59699. recordVertexArrayObject(vertexBuffers: {
  59700. [key: string]: VertexBuffer;
  59701. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  59702. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59703. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59704. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59705. /**
  59706. * Draw a list of indexed primitives
  59707. * @param fillMode defines the primitive to use
  59708. * @param indexStart defines the starting index
  59709. * @param indexCount defines the number of index to draw
  59710. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59711. */
  59712. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59713. /**
  59714. * Draw a list of unindexed primitives
  59715. * @param fillMode defines the primitive to use
  59716. * @param verticesStart defines the index of first vertex to draw
  59717. * @param verticesCount defines the count of vertices to draw
  59718. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59719. */
  59720. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59721. createPipelineContext(): IPipelineContext;
  59722. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  59723. /** @hidden */
  59724. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  59725. /** @hidden */
  59726. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  59727. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59728. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59729. protected _setProgram(program: WebGLProgram): void;
  59730. _releaseEffect(effect: Effect): void;
  59731. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  59732. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  59733. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  59734. bindSamplers(effect: Effect): void;
  59735. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  59736. getRenderWidth(useScreen?: boolean): number;
  59737. getRenderHeight(useScreen?: boolean): number;
  59738. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59739. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59740. /**
  59741. * Set the z offset to apply to current rendering
  59742. * @param value defines the offset to apply
  59743. */
  59744. setZOffset(value: number): void;
  59745. /**
  59746. * Gets the current value of the zOffset
  59747. * @returns the current zOffset state
  59748. */
  59749. getZOffset(): number;
  59750. /**
  59751. * Enable or disable depth buffering
  59752. * @param enable defines the state to set
  59753. */
  59754. setDepthBuffer(enable: boolean): void;
  59755. /**
  59756. * Gets a boolean indicating if depth writing is enabled
  59757. * @returns the current depth writing state
  59758. */
  59759. getDepthWrite(): boolean;
  59760. setDepthFunctionToGreater(): void;
  59761. setDepthFunctionToGreaterOrEqual(): void;
  59762. setDepthFunctionToLess(): void;
  59763. setDepthFunctionToLessOrEqual(): void;
  59764. /**
  59765. * Enable or disable depth writing
  59766. * @param enable defines the state to set
  59767. */
  59768. setDepthWrite(enable: boolean): void;
  59769. /**
  59770. * Enable or disable color writing
  59771. * @param enable defines the state to set
  59772. */
  59773. setColorWrite(enable: boolean): void;
  59774. /**
  59775. * Gets a boolean indicating if color writing is enabled
  59776. * @returns the current color writing state
  59777. */
  59778. getColorWrite(): boolean;
  59779. /**
  59780. * Sets alpha constants used by some alpha blending modes
  59781. * @param r defines the red component
  59782. * @param g defines the green component
  59783. * @param b defines the blue component
  59784. * @param a defines the alpha component
  59785. */
  59786. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  59787. /**
  59788. * Sets the current alpha mode
  59789. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  59790. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59791. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59792. */
  59793. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59794. /**
  59795. * Gets the current alpha mode
  59796. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59797. * @returns the current alpha mode
  59798. */
  59799. getAlphaMode(): number;
  59800. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  59801. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59802. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59803. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59804. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59805. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59806. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59807. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59808. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59809. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59810. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59811. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59812. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59813. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59814. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59815. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59816. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59817. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59818. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59819. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59820. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  59821. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  59822. wipeCaches(bruteForce?: boolean): void;
  59823. protected _createTexture(): WebGLTexture;
  59824. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  59825. /**
  59826. * Update the content of a dynamic texture
  59827. * @param texture defines the texture to update
  59828. * @param canvas defines the canvas containing the source
  59829. * @param invertY defines if data must be stored with Y axis inverted
  59830. * @param premulAlpha defines if alpha is stored as premultiplied
  59831. * @param format defines the format of the data
  59832. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59833. */
  59834. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59835. /**
  59836. * Usually called from Texture.ts.
  59837. * Passed information to create a WebGLTexture
  59838. * @param url defines a value which contains one of the following:
  59839. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59840. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59841. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59842. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59843. * @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)
  59844. * @param scene needed for loading to the correct scene
  59845. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59846. * @param onLoad optional callback to be called upon successful completion
  59847. * @param onError optional callback to be called upon failure
  59848. * @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
  59849. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59850. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59851. * @param forcedExtension defines the extension to use to pick the right loader
  59852. * @param mimeType defines an optional mime type
  59853. * @param loaderOptions options to be passed to the loader
  59854. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59855. */
  59856. 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;
  59857. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  59858. _releaseFramebufferObjects(texture: InternalTexture): void;
  59859. /**
  59860. * Creates a cube texture
  59861. * @param rootUrl defines the url where the files to load is located
  59862. * @param scene defines the current scene
  59863. * @param files defines the list of files to load (1 per face)
  59864. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  59865. * @param onLoad defines an optional callback raised when the texture is loaded
  59866. * @param onError defines an optional callback raised if there is an issue to load the texture
  59867. * @param format defines the format of the data
  59868. * @param forcedExtension defines the extension to use to pick the right loader
  59869. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  59870. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59871. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59872. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  59873. * @returns the cube texture as an InternalTexture
  59874. */
  59875. 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;
  59876. createRenderTargetTexture(size: number | {
  59877. width: number;
  59878. height: number;
  59879. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  59880. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59881. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59882. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59883. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  59884. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  59885. /**
  59886. * Updates a dynamic vertex buffer.
  59887. * @param vertexBuffer the vertex buffer to update
  59888. * @param data the data used to update the vertex buffer
  59889. * @param byteOffset the byte offset of the data (optional)
  59890. * @param byteLength the byte length of the data (optional)
  59891. */
  59892. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  59893. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  59894. private _updateAnisotropicLevel;
  59895. private _getAddressMode;
  59896. /** @hidden */
  59897. _bindTexture(channel: number, texture: InternalTexture): void;
  59898. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  59899. releaseEffects(): void;
  59900. /** @hidden */
  59901. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59902. /** @hidden */
  59903. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59904. /** @hidden */
  59905. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59906. /** @hidden */
  59907. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59908. private _getNativeSamplingMode;
  59909. private _getNativeTextureFormat;
  59910. private _getNativeAlphaMode;
  59911. private _getNativeAttribType;
  59912. }
  59913. }
  59914. declare module BABYLON {
  59915. /**
  59916. * Gather the list of clipboard event types as constants.
  59917. */
  59918. export class ClipboardEventTypes {
  59919. /**
  59920. * The clipboard event is fired when a copy command is active (pressed).
  59921. */
  59922. static readonly COPY: number;
  59923. /**
  59924. * The clipboard event is fired when a cut command is active (pressed).
  59925. */
  59926. static readonly CUT: number;
  59927. /**
  59928. * The clipboard event is fired when a paste command is active (pressed).
  59929. */
  59930. static readonly PASTE: number;
  59931. }
  59932. /**
  59933. * This class is used to store clipboard related info for the onClipboardObservable event.
  59934. */
  59935. export class ClipboardInfo {
  59936. /**
  59937. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59938. */
  59939. type: number;
  59940. /**
  59941. * Defines the related dom event
  59942. */
  59943. event: ClipboardEvent;
  59944. /**
  59945. *Creates an instance of ClipboardInfo.
  59946. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  59947. * @param event Defines the related dom event
  59948. */
  59949. constructor(
  59950. /**
  59951. * Defines the type of event (BABYLON.ClipboardEventTypes)
  59952. */
  59953. type: number,
  59954. /**
  59955. * Defines the related dom event
  59956. */
  59957. event: ClipboardEvent);
  59958. /**
  59959. * Get the clipboard event's type from the keycode.
  59960. * @param keyCode Defines the keyCode for the current keyboard event.
  59961. * @return {number}
  59962. */
  59963. static GetTypeFromCharacter(keyCode: number): number;
  59964. }
  59965. }
  59966. declare module BABYLON {
  59967. /**
  59968. * Google Daydream controller
  59969. */
  59970. export class DaydreamController extends WebVRController {
  59971. /**
  59972. * Base Url for the controller model.
  59973. */
  59974. static MODEL_BASE_URL: string;
  59975. /**
  59976. * File name for the controller model.
  59977. */
  59978. static MODEL_FILENAME: string;
  59979. /**
  59980. * Gamepad Id prefix used to identify Daydream Controller.
  59981. */
  59982. static readonly GAMEPAD_ID_PREFIX: string;
  59983. /**
  59984. * Creates a new DaydreamController from a gamepad
  59985. * @param vrGamepad the gamepad that the controller should be created from
  59986. */
  59987. constructor(vrGamepad: any);
  59988. /**
  59989. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59990. * @param scene scene in which to add meshes
  59991. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59992. */
  59993. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  59994. /**
  59995. * Called once for each button that changed state since the last frame
  59996. * @param buttonIdx Which button index changed
  59997. * @param state New state of the button
  59998. * @param changes Which properties on the state changed since last frame
  59999. */
  60000. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60001. }
  60002. }
  60003. declare module BABYLON {
  60004. /**
  60005. * Gear VR Controller
  60006. */
  60007. export class GearVRController extends WebVRController {
  60008. /**
  60009. * Base Url for the controller model.
  60010. */
  60011. static MODEL_BASE_URL: string;
  60012. /**
  60013. * File name for the controller model.
  60014. */
  60015. static MODEL_FILENAME: string;
  60016. /**
  60017. * Gamepad Id prefix used to identify this controller.
  60018. */
  60019. static readonly GAMEPAD_ID_PREFIX: string;
  60020. private readonly _buttonIndexToObservableNameMap;
  60021. /**
  60022. * Creates a new GearVRController from a gamepad
  60023. * @param vrGamepad the gamepad that the controller should be created from
  60024. */
  60025. constructor(vrGamepad: any);
  60026. /**
  60027. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60028. * @param scene scene in which to add meshes
  60029. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60030. */
  60031. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60032. /**
  60033. * Called once for each button that changed state since the last frame
  60034. * @param buttonIdx Which button index changed
  60035. * @param state New state of the button
  60036. * @param changes Which properties on the state changed since last frame
  60037. */
  60038. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60039. }
  60040. }
  60041. declare module BABYLON {
  60042. /**
  60043. * Generic Controller
  60044. */
  60045. export class GenericController extends WebVRController {
  60046. /**
  60047. * Base Url for the controller model.
  60048. */
  60049. static readonly MODEL_BASE_URL: string;
  60050. /**
  60051. * File name for the controller model.
  60052. */
  60053. static readonly MODEL_FILENAME: string;
  60054. /**
  60055. * Creates a new GenericController from a gamepad
  60056. * @param vrGamepad the gamepad that the controller should be created from
  60057. */
  60058. constructor(vrGamepad: any);
  60059. /**
  60060. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60061. * @param scene scene in which to add meshes
  60062. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60063. */
  60064. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60065. /**
  60066. * Called once for each button that changed state since the last frame
  60067. * @param buttonIdx Which button index changed
  60068. * @param state New state of the button
  60069. * @param changes Which properties on the state changed since last frame
  60070. */
  60071. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60072. }
  60073. }
  60074. declare module BABYLON {
  60075. /**
  60076. * Oculus Touch Controller
  60077. */
  60078. export class OculusTouchController extends WebVRController {
  60079. /**
  60080. * Base Url for the controller model.
  60081. */
  60082. static MODEL_BASE_URL: string;
  60083. /**
  60084. * File name for the left controller model.
  60085. */
  60086. static MODEL_LEFT_FILENAME: string;
  60087. /**
  60088. * File name for the right controller model.
  60089. */
  60090. static MODEL_RIGHT_FILENAME: string;
  60091. /**
  60092. * Base Url for the Quest controller model.
  60093. */
  60094. static QUEST_MODEL_BASE_URL: string;
  60095. /**
  60096. * @hidden
  60097. * If the controllers are running on a device that needs the updated Quest controller models
  60098. */
  60099. static _IsQuest: boolean;
  60100. /**
  60101. * Fired when the secondary trigger on this controller is modified
  60102. */
  60103. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60104. /**
  60105. * Fired when the thumb rest on this controller is modified
  60106. */
  60107. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60108. /**
  60109. * Creates a new OculusTouchController from a gamepad
  60110. * @param vrGamepad the gamepad that the controller should be created from
  60111. */
  60112. constructor(vrGamepad: any);
  60113. /**
  60114. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60115. * @param scene scene in which to add meshes
  60116. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60117. */
  60118. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60119. /**
  60120. * Fired when the A button on this controller is modified
  60121. */
  60122. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60123. /**
  60124. * Fired when the B button on this controller is modified
  60125. */
  60126. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60127. /**
  60128. * Fired when the X button on this controller is modified
  60129. */
  60130. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60131. /**
  60132. * Fired when the Y button on this controller is modified
  60133. */
  60134. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60135. /**
  60136. * Called once for each button that changed state since the last frame
  60137. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60138. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60139. * 2) secondary trigger (same)
  60140. * 3) A (right) X (left), touch, pressed = value
  60141. * 4) B / Y
  60142. * 5) thumb rest
  60143. * @param buttonIdx Which button index changed
  60144. * @param state New state of the button
  60145. * @param changes Which properties on the state changed since last frame
  60146. */
  60147. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60148. }
  60149. }
  60150. declare module BABYLON {
  60151. /**
  60152. * Vive Controller
  60153. */
  60154. export class ViveController extends WebVRController {
  60155. /**
  60156. * Base Url for the controller model.
  60157. */
  60158. static MODEL_BASE_URL: string;
  60159. /**
  60160. * File name for the controller model.
  60161. */
  60162. static MODEL_FILENAME: string;
  60163. /**
  60164. * Creates a new ViveController from a gamepad
  60165. * @param vrGamepad the gamepad that the controller should be created from
  60166. */
  60167. constructor(vrGamepad: any);
  60168. /**
  60169. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60170. * @param scene scene in which to add meshes
  60171. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60172. */
  60173. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60174. /**
  60175. * Fired when the left button on this controller is modified
  60176. */
  60177. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60178. /**
  60179. * Fired when the right button on this controller is modified
  60180. */
  60181. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60182. /**
  60183. * Fired when the menu button on this controller is modified
  60184. */
  60185. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60186. /**
  60187. * Called once for each button that changed state since the last frame
  60188. * Vive mapping:
  60189. * 0: touchpad
  60190. * 1: trigger
  60191. * 2: left AND right buttons
  60192. * 3: menu button
  60193. * @param buttonIdx Which button index changed
  60194. * @param state New state of the button
  60195. * @param changes Which properties on the state changed since last frame
  60196. */
  60197. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60198. }
  60199. }
  60200. declare module BABYLON {
  60201. /**
  60202. * Defines the WindowsMotionController object that the state of the windows motion controller
  60203. */
  60204. export class WindowsMotionController extends WebVRController {
  60205. /**
  60206. * The base url used to load the left and right controller models
  60207. */
  60208. static MODEL_BASE_URL: string;
  60209. /**
  60210. * The name of the left controller model file
  60211. */
  60212. static MODEL_LEFT_FILENAME: string;
  60213. /**
  60214. * The name of the right controller model file
  60215. */
  60216. static MODEL_RIGHT_FILENAME: string;
  60217. /**
  60218. * The controller name prefix for this controller type
  60219. */
  60220. static readonly GAMEPAD_ID_PREFIX: string;
  60221. /**
  60222. * The controller id pattern for this controller type
  60223. */
  60224. private static readonly GAMEPAD_ID_PATTERN;
  60225. private _loadedMeshInfo;
  60226. protected readonly _mapping: {
  60227. buttons: string[];
  60228. buttonMeshNames: {
  60229. trigger: string;
  60230. menu: string;
  60231. grip: string;
  60232. thumbstick: string;
  60233. trackpad: string;
  60234. };
  60235. buttonObservableNames: {
  60236. trigger: string;
  60237. menu: string;
  60238. grip: string;
  60239. thumbstick: string;
  60240. trackpad: string;
  60241. };
  60242. axisMeshNames: string[];
  60243. pointingPoseMeshName: string;
  60244. };
  60245. /**
  60246. * Fired when the trackpad on this controller is clicked
  60247. */
  60248. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60249. /**
  60250. * Fired when the trackpad on this controller is modified
  60251. */
  60252. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60253. /**
  60254. * The current x and y values of this controller's trackpad
  60255. */
  60256. trackpad: StickValues;
  60257. /**
  60258. * Creates a new WindowsMotionController from a gamepad
  60259. * @param vrGamepad the gamepad that the controller should be created from
  60260. */
  60261. constructor(vrGamepad: any);
  60262. /**
  60263. * Fired when the trigger on this controller is modified
  60264. */
  60265. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60266. /**
  60267. * Fired when the menu button on this controller is modified
  60268. */
  60269. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60270. /**
  60271. * Fired when the grip button on this controller is modified
  60272. */
  60273. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60274. /**
  60275. * Fired when the thumbstick button on this controller is modified
  60276. */
  60277. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60278. /**
  60279. * Fired when the touchpad button on this controller is modified
  60280. */
  60281. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60282. /**
  60283. * Fired when the touchpad values on this controller are modified
  60284. */
  60285. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60286. protected _updateTrackpad(): void;
  60287. /**
  60288. * Called once per frame by the engine.
  60289. */
  60290. update(): void;
  60291. /**
  60292. * Called once for each button that changed state since the last frame
  60293. * @param buttonIdx Which button index changed
  60294. * @param state New state of the button
  60295. * @param changes Which properties on the state changed since last frame
  60296. */
  60297. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60298. /**
  60299. * Moves the buttons on the controller mesh based on their current state
  60300. * @param buttonName the name of the button to move
  60301. * @param buttonValue the value of the button which determines the buttons new position
  60302. */
  60303. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60304. /**
  60305. * Moves the axis on the controller mesh based on its current state
  60306. * @param axis the index of the axis
  60307. * @param axisValue the value of the axis which determines the meshes new position
  60308. * @hidden
  60309. */
  60310. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60311. /**
  60312. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60313. * @param scene scene in which to add meshes
  60314. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60315. */
  60316. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60317. /**
  60318. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60319. * can be transformed by button presses and axes values, based on this._mapping.
  60320. *
  60321. * @param scene scene in which the meshes exist
  60322. * @param meshes list of meshes that make up the controller model to process
  60323. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60324. */
  60325. private processModel;
  60326. private createMeshInfo;
  60327. /**
  60328. * Gets the ray of the controller in the direction the controller is pointing
  60329. * @param length the length the resulting ray should be
  60330. * @returns a ray in the direction the controller is pointing
  60331. */
  60332. getForwardRay(length?: number): Ray;
  60333. /**
  60334. * Disposes of the controller
  60335. */
  60336. dispose(): void;
  60337. }
  60338. /**
  60339. * This class represents a new windows motion controller in XR.
  60340. */
  60341. export class XRWindowsMotionController extends WindowsMotionController {
  60342. /**
  60343. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60344. */
  60345. protected readonly _mapping: {
  60346. buttons: string[];
  60347. buttonMeshNames: {
  60348. trigger: string;
  60349. menu: string;
  60350. grip: string;
  60351. thumbstick: string;
  60352. trackpad: string;
  60353. };
  60354. buttonObservableNames: {
  60355. trigger: string;
  60356. menu: string;
  60357. grip: string;
  60358. thumbstick: string;
  60359. trackpad: string;
  60360. };
  60361. axisMeshNames: string[];
  60362. pointingPoseMeshName: string;
  60363. };
  60364. /**
  60365. * Construct a new XR-Based windows motion controller
  60366. *
  60367. * @param gamepadInfo the gamepad object from the browser
  60368. */
  60369. constructor(gamepadInfo: any);
  60370. /**
  60371. * holds the thumbstick values (X,Y)
  60372. */
  60373. thumbstickValues: StickValues;
  60374. /**
  60375. * Fired when the thumbstick on this controller is clicked
  60376. */
  60377. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60378. /**
  60379. * Fired when the thumbstick on this controller is modified
  60380. */
  60381. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60382. /**
  60383. * Fired when the touchpad button on this controller is modified
  60384. */
  60385. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60386. /**
  60387. * Fired when the touchpad values on this controller are modified
  60388. */
  60389. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60390. /**
  60391. * Fired when the thumbstick button on this controller is modified
  60392. * here to prevent breaking changes
  60393. */
  60394. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60395. /**
  60396. * updating the thumbstick(!) and not the trackpad.
  60397. * This is named this way due to the difference between WebVR and XR and to avoid
  60398. * changing the parent class.
  60399. */
  60400. protected _updateTrackpad(): void;
  60401. /**
  60402. * Disposes the class with joy
  60403. */
  60404. dispose(): void;
  60405. }
  60406. }
  60407. declare module BABYLON {
  60408. /**
  60409. * A directional light is defined by a direction (what a surprise!).
  60410. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60411. * 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.
  60412. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60413. */
  60414. export class DirectionalLight extends ShadowLight {
  60415. private _shadowFrustumSize;
  60416. /**
  60417. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60418. */
  60419. get shadowFrustumSize(): number;
  60420. /**
  60421. * Specifies a fix frustum size for the shadow generation.
  60422. */
  60423. set shadowFrustumSize(value: number);
  60424. private _shadowOrthoScale;
  60425. /**
  60426. * Gets the shadow projection scale against the optimal computed one.
  60427. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60428. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60429. */
  60430. get shadowOrthoScale(): number;
  60431. /**
  60432. * Sets the shadow projection scale against the optimal computed one.
  60433. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60434. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60435. */
  60436. set shadowOrthoScale(value: number);
  60437. /**
  60438. * Automatically compute the projection matrix to best fit (including all the casters)
  60439. * on each frame.
  60440. */
  60441. autoUpdateExtends: boolean;
  60442. /**
  60443. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60444. * on each frame. autoUpdateExtends must be set to true for this to work
  60445. */
  60446. autoCalcShadowZBounds: boolean;
  60447. private _orthoLeft;
  60448. private _orthoRight;
  60449. private _orthoTop;
  60450. private _orthoBottom;
  60451. /**
  60452. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60453. * The directional light is emitted from everywhere in the given direction.
  60454. * It can cast shadows.
  60455. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60456. * @param name The friendly name of the light
  60457. * @param direction The direction of the light
  60458. * @param scene The scene the light belongs to
  60459. */
  60460. constructor(name: string, direction: Vector3, scene: Scene);
  60461. /**
  60462. * Returns the string "DirectionalLight".
  60463. * @return The class name
  60464. */
  60465. getClassName(): string;
  60466. /**
  60467. * Returns the integer 1.
  60468. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60469. */
  60470. getTypeID(): number;
  60471. /**
  60472. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60473. * Returns the DirectionalLight Shadow projection matrix.
  60474. */
  60475. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60476. /**
  60477. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60478. * Returns the DirectionalLight Shadow projection matrix.
  60479. */
  60480. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60481. /**
  60482. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60483. * Returns the DirectionalLight Shadow projection matrix.
  60484. */
  60485. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60486. protected _buildUniformLayout(): void;
  60487. /**
  60488. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60489. * @param effect The effect to update
  60490. * @param lightIndex The index of the light in the effect to update
  60491. * @returns The directional light
  60492. */
  60493. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60494. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60495. /**
  60496. * Gets the minZ used for shadow according to both the scene and the light.
  60497. *
  60498. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60499. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60500. * @param activeCamera The camera we are returning the min for
  60501. * @returns the depth min z
  60502. */
  60503. getDepthMinZ(activeCamera: Camera): number;
  60504. /**
  60505. * Gets the maxZ used for shadow according to both the scene and the light.
  60506. *
  60507. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60508. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60509. * @param activeCamera The camera we are returning the max for
  60510. * @returns the depth max z
  60511. */
  60512. getDepthMaxZ(activeCamera: Camera): number;
  60513. /**
  60514. * Prepares the list of defines specific to the light type.
  60515. * @param defines the list of defines
  60516. * @param lightIndex defines the index of the light for the effect
  60517. */
  60518. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60519. }
  60520. }
  60521. declare module BABYLON {
  60522. /**
  60523. * Class containing static functions to help procedurally build meshes
  60524. */
  60525. export class HemisphereBuilder {
  60526. /**
  60527. * Creates a hemisphere mesh
  60528. * @param name defines the name of the mesh
  60529. * @param options defines the options used to create the mesh
  60530. * @param scene defines the hosting scene
  60531. * @returns the hemisphere mesh
  60532. */
  60533. static CreateHemisphere(name: string, options: {
  60534. segments?: number;
  60535. diameter?: number;
  60536. sideOrientation?: number;
  60537. }, scene: any): Mesh;
  60538. }
  60539. }
  60540. declare module BABYLON {
  60541. /**
  60542. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60543. * These values define a cone of light starting from the position, emitting toward the direction.
  60544. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60545. * and the exponent defines the speed of the decay of the light with distance (reach).
  60546. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60547. */
  60548. export class SpotLight extends ShadowLight {
  60549. private _angle;
  60550. private _innerAngle;
  60551. private _cosHalfAngle;
  60552. private _lightAngleScale;
  60553. private _lightAngleOffset;
  60554. /**
  60555. * Gets the cone angle of the spot light in Radians.
  60556. */
  60557. get angle(): number;
  60558. /**
  60559. * Sets the cone angle of the spot light in Radians.
  60560. */
  60561. set angle(value: number);
  60562. /**
  60563. * Only used in gltf falloff mode, this defines the angle where
  60564. * the directional falloff will start before cutting at angle which could be seen
  60565. * as outer angle.
  60566. */
  60567. get innerAngle(): number;
  60568. /**
  60569. * Only used in gltf falloff mode, this defines the angle where
  60570. * the directional falloff will start before cutting at angle which could be seen
  60571. * as outer angle.
  60572. */
  60573. set innerAngle(value: number);
  60574. private _shadowAngleScale;
  60575. /**
  60576. * Allows scaling the angle of the light for shadow generation only.
  60577. */
  60578. get shadowAngleScale(): number;
  60579. /**
  60580. * Allows scaling the angle of the light for shadow generation only.
  60581. */
  60582. set shadowAngleScale(value: number);
  60583. /**
  60584. * The light decay speed with the distance from the emission spot.
  60585. */
  60586. exponent: number;
  60587. private _projectionTextureMatrix;
  60588. /**
  60589. * Allows reading the projecton texture
  60590. */
  60591. get projectionTextureMatrix(): Matrix;
  60592. protected _projectionTextureLightNear: number;
  60593. /**
  60594. * Gets the near clip of the Spotlight for texture projection.
  60595. */
  60596. get projectionTextureLightNear(): number;
  60597. /**
  60598. * Sets the near clip of the Spotlight for texture projection.
  60599. */
  60600. set projectionTextureLightNear(value: number);
  60601. protected _projectionTextureLightFar: number;
  60602. /**
  60603. * Gets the far clip of the Spotlight for texture projection.
  60604. */
  60605. get projectionTextureLightFar(): number;
  60606. /**
  60607. * Sets the far clip of the Spotlight for texture projection.
  60608. */
  60609. set projectionTextureLightFar(value: number);
  60610. protected _projectionTextureUpDirection: Vector3;
  60611. /**
  60612. * Gets the Up vector of the Spotlight for texture projection.
  60613. */
  60614. get projectionTextureUpDirection(): Vector3;
  60615. /**
  60616. * Sets the Up vector of the Spotlight for texture projection.
  60617. */
  60618. set projectionTextureUpDirection(value: Vector3);
  60619. private _projectionTexture;
  60620. /**
  60621. * Gets the projection texture of the light.
  60622. */
  60623. get projectionTexture(): Nullable<BaseTexture>;
  60624. /**
  60625. * Sets the projection texture of the light.
  60626. */
  60627. set projectionTexture(value: Nullable<BaseTexture>);
  60628. private static _IsProceduralTexture;
  60629. private static _IsTexture;
  60630. private _projectionTextureViewLightDirty;
  60631. private _projectionTextureProjectionLightDirty;
  60632. private _projectionTextureDirty;
  60633. private _projectionTextureViewTargetVector;
  60634. private _projectionTextureViewLightMatrix;
  60635. private _projectionTextureProjectionLightMatrix;
  60636. private _projectionTextureScalingMatrix;
  60637. /**
  60638. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60639. * It can cast shadows.
  60640. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60641. * @param name The light friendly name
  60642. * @param position The position of the spot light in the scene
  60643. * @param direction The direction of the light in the scene
  60644. * @param angle The cone angle of the light in Radians
  60645. * @param exponent The light decay speed with the distance from the emission spot
  60646. * @param scene The scene the lights belongs to
  60647. */
  60648. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60649. /**
  60650. * Returns the string "SpotLight".
  60651. * @returns the class name
  60652. */
  60653. getClassName(): string;
  60654. /**
  60655. * Returns the integer 2.
  60656. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60657. */
  60658. getTypeID(): number;
  60659. /**
  60660. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60661. */
  60662. protected _setDirection(value: Vector3): void;
  60663. /**
  60664. * Overrides the position setter to recompute the projection texture view light Matrix.
  60665. */
  60666. protected _setPosition(value: Vector3): void;
  60667. /**
  60668. * 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.
  60669. * Returns the SpotLight.
  60670. */
  60671. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60672. protected _computeProjectionTextureViewLightMatrix(): void;
  60673. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60674. /**
  60675. * Main function for light texture projection matrix computing.
  60676. */
  60677. protected _computeProjectionTextureMatrix(): void;
  60678. protected _buildUniformLayout(): void;
  60679. private _computeAngleValues;
  60680. /**
  60681. * Sets the passed Effect "effect" with the Light textures.
  60682. * @param effect The effect to update
  60683. * @param lightIndex The index of the light in the effect to update
  60684. * @returns The light
  60685. */
  60686. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60687. /**
  60688. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60689. * @param effect The effect to update
  60690. * @param lightIndex The index of the light in the effect to update
  60691. * @returns The spot light
  60692. */
  60693. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60694. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60695. /**
  60696. * Disposes the light and the associated resources.
  60697. */
  60698. dispose(): void;
  60699. /**
  60700. * Prepares the list of defines specific to the light type.
  60701. * @param defines the list of defines
  60702. * @param lightIndex defines the index of the light for the effect
  60703. */
  60704. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60705. }
  60706. }
  60707. declare module BABYLON {
  60708. /**
  60709. * Gizmo that enables viewing a light
  60710. */
  60711. export class LightGizmo extends Gizmo {
  60712. private _lightMesh;
  60713. private _material;
  60714. private _cachedPosition;
  60715. private _cachedForward;
  60716. private _attachedMeshParent;
  60717. private _pointerObserver;
  60718. /**
  60719. * Event that fires each time the gizmo is clicked
  60720. */
  60721. onClickedObservable: Observable<Light>;
  60722. /**
  60723. * Creates a LightGizmo
  60724. * @param gizmoLayer The utility layer the gizmo will be added to
  60725. */
  60726. constructor(gizmoLayer?: UtilityLayerRenderer);
  60727. private _light;
  60728. /**
  60729. * The light that the gizmo is attached to
  60730. */
  60731. set light(light: Nullable<Light>);
  60732. get light(): Nullable<Light>;
  60733. /**
  60734. * Gets the material used to render the light gizmo
  60735. */
  60736. get material(): StandardMaterial;
  60737. /**
  60738. * @hidden
  60739. * Updates the gizmo to match the attached mesh's position/rotation
  60740. */
  60741. protected _update(): void;
  60742. private static _Scale;
  60743. /**
  60744. * Creates the lines for a light mesh
  60745. */
  60746. private static _CreateLightLines;
  60747. /**
  60748. * Disposes of the light gizmo
  60749. */
  60750. dispose(): void;
  60751. private static _CreateHemisphericLightMesh;
  60752. private static _CreatePointLightMesh;
  60753. private static _CreateSpotLightMesh;
  60754. private static _CreateDirectionalLightMesh;
  60755. }
  60756. }
  60757. declare module BABYLON {
  60758. /**
  60759. * Gizmo that enables viewing a camera
  60760. */
  60761. export class CameraGizmo extends Gizmo {
  60762. private _cameraMesh;
  60763. private _cameraLinesMesh;
  60764. private _material;
  60765. private _pointerObserver;
  60766. /**
  60767. * Event that fires each time the gizmo is clicked
  60768. */
  60769. onClickedObservable: Observable<Camera>;
  60770. /**
  60771. * Creates a CameraGizmo
  60772. * @param gizmoLayer The utility layer the gizmo will be added to
  60773. */
  60774. constructor(gizmoLayer?: UtilityLayerRenderer);
  60775. private _camera;
  60776. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60777. get displayFrustum(): boolean;
  60778. set displayFrustum(value: boolean);
  60779. /**
  60780. * The camera that the gizmo is attached to
  60781. */
  60782. set camera(camera: Nullable<Camera>);
  60783. get camera(): Nullable<Camera>;
  60784. /**
  60785. * Gets the material used to render the camera gizmo
  60786. */
  60787. get material(): StandardMaterial;
  60788. /**
  60789. * @hidden
  60790. * Updates the gizmo to match the attached mesh's position/rotation
  60791. */
  60792. protected _update(): void;
  60793. private static _Scale;
  60794. private _invProjection;
  60795. /**
  60796. * Disposes of the camera gizmo
  60797. */
  60798. dispose(): void;
  60799. private static _CreateCameraMesh;
  60800. private static _CreateCameraFrustum;
  60801. }
  60802. }
  60803. declare module BABYLON {
  60804. /** @hidden */
  60805. export var backgroundFragmentDeclaration: {
  60806. name: string;
  60807. shader: string;
  60808. };
  60809. }
  60810. declare module BABYLON {
  60811. /** @hidden */
  60812. export var backgroundUboDeclaration: {
  60813. name: string;
  60814. shader: string;
  60815. };
  60816. }
  60817. declare module BABYLON {
  60818. /** @hidden */
  60819. export var backgroundPixelShader: {
  60820. name: string;
  60821. shader: string;
  60822. };
  60823. }
  60824. declare module BABYLON {
  60825. /** @hidden */
  60826. export var backgroundVertexDeclaration: {
  60827. name: string;
  60828. shader: string;
  60829. };
  60830. }
  60831. declare module BABYLON {
  60832. /** @hidden */
  60833. export var backgroundVertexShader: {
  60834. name: string;
  60835. shader: string;
  60836. };
  60837. }
  60838. declare module BABYLON {
  60839. /**
  60840. * Background material used to create an efficient environement around your scene.
  60841. */
  60842. export class BackgroundMaterial extends PushMaterial {
  60843. /**
  60844. * Standard reflectance value at parallel view angle.
  60845. */
  60846. static StandardReflectance0: number;
  60847. /**
  60848. * Standard reflectance value at grazing angle.
  60849. */
  60850. static StandardReflectance90: number;
  60851. protected _primaryColor: Color3;
  60852. /**
  60853. * Key light Color (multiply against the environement texture)
  60854. */
  60855. primaryColor: Color3;
  60856. protected __perceptualColor: Nullable<Color3>;
  60857. /**
  60858. * Experimental Internal Use Only.
  60859. *
  60860. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60861. * This acts as a helper to set the primary color to a more "human friendly" value.
  60862. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60863. * output color as close as possible from the chosen value.
  60864. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60865. * part of lighting setup.)
  60866. */
  60867. get _perceptualColor(): Nullable<Color3>;
  60868. set _perceptualColor(value: Nullable<Color3>);
  60869. protected _primaryColorShadowLevel: float;
  60870. /**
  60871. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60872. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60873. */
  60874. get primaryColorShadowLevel(): float;
  60875. set primaryColorShadowLevel(value: float);
  60876. protected _primaryColorHighlightLevel: float;
  60877. /**
  60878. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60879. * The primary color is used at the level chosen to define what the white area would look.
  60880. */
  60881. get primaryColorHighlightLevel(): float;
  60882. set primaryColorHighlightLevel(value: float);
  60883. protected _reflectionTexture: Nullable<BaseTexture>;
  60884. /**
  60885. * Reflection Texture used in the material.
  60886. * Should be author in a specific way for the best result (refer to the documentation).
  60887. */
  60888. reflectionTexture: Nullable<BaseTexture>;
  60889. protected _reflectionBlur: float;
  60890. /**
  60891. * Reflection Texture level of blur.
  60892. *
  60893. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60894. * texture twice.
  60895. */
  60896. reflectionBlur: float;
  60897. protected _diffuseTexture: Nullable<BaseTexture>;
  60898. /**
  60899. * Diffuse Texture used in the material.
  60900. * Should be author in a specific way for the best result (refer to the documentation).
  60901. */
  60902. diffuseTexture: Nullable<BaseTexture>;
  60903. protected _shadowLights: Nullable<IShadowLight[]>;
  60904. /**
  60905. * Specify the list of lights casting shadow on the material.
  60906. * All scene shadow lights will be included if null.
  60907. */
  60908. shadowLights: Nullable<IShadowLight[]>;
  60909. protected _shadowLevel: float;
  60910. /**
  60911. * Helps adjusting the shadow to a softer level if required.
  60912. * 0 means black shadows and 1 means no shadows.
  60913. */
  60914. shadowLevel: float;
  60915. protected _sceneCenter: Vector3;
  60916. /**
  60917. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60918. * It is usually zero but might be interesting to modify according to your setup.
  60919. */
  60920. sceneCenter: Vector3;
  60921. protected _opacityFresnel: boolean;
  60922. /**
  60923. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60924. * This helps ensuring a nice transition when the camera goes under the ground.
  60925. */
  60926. opacityFresnel: boolean;
  60927. protected _reflectionFresnel: boolean;
  60928. /**
  60929. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60930. * This helps adding a mirror texture on the ground.
  60931. */
  60932. reflectionFresnel: boolean;
  60933. protected _reflectionFalloffDistance: number;
  60934. /**
  60935. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60936. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60937. */
  60938. reflectionFalloffDistance: number;
  60939. protected _reflectionAmount: number;
  60940. /**
  60941. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60942. */
  60943. reflectionAmount: number;
  60944. protected _reflectionReflectance0: number;
  60945. /**
  60946. * This specifies the weight of the reflection at grazing angle.
  60947. */
  60948. reflectionReflectance0: number;
  60949. protected _reflectionReflectance90: number;
  60950. /**
  60951. * This specifies the weight of the reflection at a perpendicular point of view.
  60952. */
  60953. reflectionReflectance90: number;
  60954. /**
  60955. * Sets the reflection reflectance fresnel values according to the default standard
  60956. * empirically know to work well :-)
  60957. */
  60958. set reflectionStandardFresnelWeight(value: number);
  60959. protected _useRGBColor: boolean;
  60960. /**
  60961. * Helps to directly use the maps channels instead of their level.
  60962. */
  60963. useRGBColor: boolean;
  60964. protected _enableNoise: boolean;
  60965. /**
  60966. * This helps reducing the banding effect that could occur on the background.
  60967. */
  60968. enableNoise: boolean;
  60969. /**
  60970. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60971. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60972. * Recommended to be keep at 1.0 except for special cases.
  60973. */
  60974. get fovMultiplier(): number;
  60975. set fovMultiplier(value: number);
  60976. private _fovMultiplier;
  60977. /**
  60978. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60979. */
  60980. useEquirectangularFOV: boolean;
  60981. private _maxSimultaneousLights;
  60982. /**
  60983. * Number of Simultaneous lights allowed on the material.
  60984. */
  60985. maxSimultaneousLights: int;
  60986. private _shadowOnly;
  60987. /**
  60988. * Make the material only render shadows
  60989. */
  60990. shadowOnly: boolean;
  60991. /**
  60992. * Default configuration related to image processing available in the Background Material.
  60993. */
  60994. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60995. /**
  60996. * Keep track of the image processing observer to allow dispose and replace.
  60997. */
  60998. private _imageProcessingObserver;
  60999. /**
  61000. * Attaches a new image processing configuration to the PBR Material.
  61001. * @param configuration (if null the scene configuration will be use)
  61002. */
  61003. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61004. /**
  61005. * Gets the image processing configuration used either in this material.
  61006. */
  61007. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61008. /**
  61009. * Sets the Default image processing configuration used either in the this material.
  61010. *
  61011. * If sets to null, the scene one is in use.
  61012. */
  61013. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61014. /**
  61015. * Gets wether the color curves effect is enabled.
  61016. */
  61017. get cameraColorCurvesEnabled(): boolean;
  61018. /**
  61019. * Sets wether the color curves effect is enabled.
  61020. */
  61021. set cameraColorCurvesEnabled(value: boolean);
  61022. /**
  61023. * Gets wether the color grading effect is enabled.
  61024. */
  61025. get cameraColorGradingEnabled(): boolean;
  61026. /**
  61027. * Gets wether the color grading effect is enabled.
  61028. */
  61029. set cameraColorGradingEnabled(value: boolean);
  61030. /**
  61031. * Gets wether tonemapping is enabled or not.
  61032. */
  61033. get cameraToneMappingEnabled(): boolean;
  61034. /**
  61035. * Sets wether tonemapping is enabled or not
  61036. */
  61037. set cameraToneMappingEnabled(value: boolean);
  61038. /**
  61039. * The camera exposure used on this material.
  61040. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61041. * This corresponds to a photographic exposure.
  61042. */
  61043. get cameraExposure(): float;
  61044. /**
  61045. * The camera exposure used on this material.
  61046. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61047. * This corresponds to a photographic exposure.
  61048. */
  61049. set cameraExposure(value: float);
  61050. /**
  61051. * Gets The camera contrast used on this material.
  61052. */
  61053. get cameraContrast(): float;
  61054. /**
  61055. * Sets The camera contrast used on this material.
  61056. */
  61057. set cameraContrast(value: float);
  61058. /**
  61059. * Gets the Color Grading 2D Lookup Texture.
  61060. */
  61061. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61062. /**
  61063. * Sets the Color Grading 2D Lookup Texture.
  61064. */
  61065. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61066. /**
  61067. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61068. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61069. * 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;
  61070. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61071. */
  61072. get cameraColorCurves(): Nullable<ColorCurves>;
  61073. /**
  61074. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61075. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61076. * 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;
  61077. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61078. */
  61079. set cameraColorCurves(value: Nullable<ColorCurves>);
  61080. /**
  61081. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61082. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61083. */
  61084. switchToBGR: boolean;
  61085. private _renderTargets;
  61086. private _reflectionControls;
  61087. private _white;
  61088. private _primaryShadowColor;
  61089. private _primaryHighlightColor;
  61090. /**
  61091. * Instantiates a Background Material in the given scene
  61092. * @param name The friendly name of the material
  61093. * @param scene The scene to add the material to
  61094. */
  61095. constructor(name: string, scene: Scene);
  61096. /**
  61097. * Gets a boolean indicating that current material needs to register RTT
  61098. */
  61099. get hasRenderTargetTextures(): boolean;
  61100. /**
  61101. * The entire material has been created in order to prevent overdraw.
  61102. * @returns false
  61103. */
  61104. needAlphaTesting(): boolean;
  61105. /**
  61106. * The entire material has been created in order to prevent overdraw.
  61107. * @returns true if blending is enable
  61108. */
  61109. needAlphaBlending(): boolean;
  61110. /**
  61111. * Checks wether the material is ready to be rendered for a given mesh.
  61112. * @param mesh The mesh to render
  61113. * @param subMesh The submesh to check against
  61114. * @param useInstances Specify wether or not the material is used with instances
  61115. * @returns true if all the dependencies are ready (Textures, Effects...)
  61116. */
  61117. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61118. /**
  61119. * Compute the primary color according to the chosen perceptual color.
  61120. */
  61121. private _computePrimaryColorFromPerceptualColor;
  61122. /**
  61123. * Compute the highlights and shadow colors according to their chosen levels.
  61124. */
  61125. private _computePrimaryColors;
  61126. /**
  61127. * Build the uniform buffer used in the material.
  61128. */
  61129. buildUniformLayout(): void;
  61130. /**
  61131. * Unbind the material.
  61132. */
  61133. unbind(): void;
  61134. /**
  61135. * Bind only the world matrix to the material.
  61136. * @param world The world matrix to bind.
  61137. */
  61138. bindOnlyWorldMatrix(world: Matrix): void;
  61139. /**
  61140. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61141. * @param world The world matrix to bind.
  61142. * @param subMesh The submesh to bind for.
  61143. */
  61144. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61145. /**
  61146. * Checks to see if a texture is used in the material.
  61147. * @param texture - Base texture to use.
  61148. * @returns - Boolean specifying if a texture is used in the material.
  61149. */
  61150. hasTexture(texture: BaseTexture): boolean;
  61151. /**
  61152. * Dispose the material.
  61153. * @param forceDisposeEffect Force disposal of the associated effect.
  61154. * @param forceDisposeTextures Force disposal of the associated textures.
  61155. */
  61156. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61157. /**
  61158. * Clones the material.
  61159. * @param name The cloned name.
  61160. * @returns The cloned material.
  61161. */
  61162. clone(name: string): BackgroundMaterial;
  61163. /**
  61164. * Serializes the current material to its JSON representation.
  61165. * @returns The JSON representation.
  61166. */
  61167. serialize(): any;
  61168. /**
  61169. * Gets the class name of the material
  61170. * @returns "BackgroundMaterial"
  61171. */
  61172. getClassName(): string;
  61173. /**
  61174. * Parse a JSON input to create back a background material.
  61175. * @param source The JSON data to parse
  61176. * @param scene The scene to create the parsed material in
  61177. * @param rootUrl The root url of the assets the material depends upon
  61178. * @returns the instantiated BackgroundMaterial.
  61179. */
  61180. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61181. }
  61182. }
  61183. declare module BABYLON {
  61184. /**
  61185. * Represents the different options available during the creation of
  61186. * a Environment helper.
  61187. *
  61188. * This can control the default ground, skybox and image processing setup of your scene.
  61189. */
  61190. export interface IEnvironmentHelperOptions {
  61191. /**
  61192. * Specifies whether or not to create a ground.
  61193. * True by default.
  61194. */
  61195. createGround: boolean;
  61196. /**
  61197. * Specifies the ground size.
  61198. * 15 by default.
  61199. */
  61200. groundSize: number;
  61201. /**
  61202. * The texture used on the ground for the main color.
  61203. * Comes from the BabylonJS CDN by default.
  61204. *
  61205. * Remarks: Can be either a texture or a url.
  61206. */
  61207. groundTexture: string | BaseTexture;
  61208. /**
  61209. * The color mixed in the ground texture by default.
  61210. * BabylonJS clearColor by default.
  61211. */
  61212. groundColor: Color3;
  61213. /**
  61214. * Specifies the ground opacity.
  61215. * 1 by default.
  61216. */
  61217. groundOpacity: number;
  61218. /**
  61219. * Enables the ground to receive shadows.
  61220. * True by default.
  61221. */
  61222. enableGroundShadow: boolean;
  61223. /**
  61224. * Helps preventing the shadow to be fully black on the ground.
  61225. * 0.5 by default.
  61226. */
  61227. groundShadowLevel: number;
  61228. /**
  61229. * Creates a mirror texture attach to the ground.
  61230. * false by default.
  61231. */
  61232. enableGroundMirror: boolean;
  61233. /**
  61234. * Specifies the ground mirror size ratio.
  61235. * 0.3 by default as the default kernel is 64.
  61236. */
  61237. groundMirrorSizeRatio: number;
  61238. /**
  61239. * Specifies the ground mirror blur kernel size.
  61240. * 64 by default.
  61241. */
  61242. groundMirrorBlurKernel: number;
  61243. /**
  61244. * Specifies the ground mirror visibility amount.
  61245. * 1 by default
  61246. */
  61247. groundMirrorAmount: number;
  61248. /**
  61249. * Specifies the ground mirror reflectance weight.
  61250. * This uses the standard weight of the background material to setup the fresnel effect
  61251. * of the mirror.
  61252. * 1 by default.
  61253. */
  61254. groundMirrorFresnelWeight: number;
  61255. /**
  61256. * Specifies the ground mirror Falloff distance.
  61257. * This can helps reducing the size of the reflection.
  61258. * 0 by Default.
  61259. */
  61260. groundMirrorFallOffDistance: number;
  61261. /**
  61262. * Specifies the ground mirror texture type.
  61263. * Unsigned Int by Default.
  61264. */
  61265. groundMirrorTextureType: number;
  61266. /**
  61267. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61268. * the shown objects.
  61269. */
  61270. groundYBias: number;
  61271. /**
  61272. * Specifies whether or not to create a skybox.
  61273. * True by default.
  61274. */
  61275. createSkybox: boolean;
  61276. /**
  61277. * Specifies the skybox size.
  61278. * 20 by default.
  61279. */
  61280. skyboxSize: number;
  61281. /**
  61282. * The texture used on the skybox for the main color.
  61283. * Comes from the BabylonJS CDN by default.
  61284. *
  61285. * Remarks: Can be either a texture or a url.
  61286. */
  61287. skyboxTexture: string | BaseTexture;
  61288. /**
  61289. * The color mixed in the skybox texture by default.
  61290. * BabylonJS clearColor by default.
  61291. */
  61292. skyboxColor: Color3;
  61293. /**
  61294. * The background rotation around the Y axis of the scene.
  61295. * This helps aligning the key lights of your scene with the background.
  61296. * 0 by default.
  61297. */
  61298. backgroundYRotation: number;
  61299. /**
  61300. * Compute automatically the size of the elements to best fit with the scene.
  61301. */
  61302. sizeAuto: boolean;
  61303. /**
  61304. * Default position of the rootMesh if autoSize is not true.
  61305. */
  61306. rootPosition: Vector3;
  61307. /**
  61308. * Sets up the image processing in the scene.
  61309. * true by default.
  61310. */
  61311. setupImageProcessing: boolean;
  61312. /**
  61313. * The texture used as your environment texture in the scene.
  61314. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61315. *
  61316. * Remarks: Can be either a texture or a url.
  61317. */
  61318. environmentTexture: string | BaseTexture;
  61319. /**
  61320. * The value of the exposure to apply to the scene.
  61321. * 0.6 by default if setupImageProcessing is true.
  61322. */
  61323. cameraExposure: number;
  61324. /**
  61325. * The value of the contrast to apply to the scene.
  61326. * 1.6 by default if setupImageProcessing is true.
  61327. */
  61328. cameraContrast: number;
  61329. /**
  61330. * Specifies whether or not tonemapping should be enabled in the scene.
  61331. * true by default if setupImageProcessing is true.
  61332. */
  61333. toneMappingEnabled: boolean;
  61334. }
  61335. /**
  61336. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61337. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61338. * It also helps with the default setup of your imageProcessing configuration.
  61339. */
  61340. export class EnvironmentHelper {
  61341. /**
  61342. * Default ground texture URL.
  61343. */
  61344. private static _groundTextureCDNUrl;
  61345. /**
  61346. * Default skybox texture URL.
  61347. */
  61348. private static _skyboxTextureCDNUrl;
  61349. /**
  61350. * Default environment texture URL.
  61351. */
  61352. private static _environmentTextureCDNUrl;
  61353. /**
  61354. * Creates the default options for the helper.
  61355. */
  61356. private static _getDefaultOptions;
  61357. private _rootMesh;
  61358. /**
  61359. * Gets the root mesh created by the helper.
  61360. */
  61361. get rootMesh(): Mesh;
  61362. private _skybox;
  61363. /**
  61364. * Gets the skybox created by the helper.
  61365. */
  61366. get skybox(): Nullable<Mesh>;
  61367. private _skyboxTexture;
  61368. /**
  61369. * Gets the skybox texture created by the helper.
  61370. */
  61371. get skyboxTexture(): Nullable<BaseTexture>;
  61372. private _skyboxMaterial;
  61373. /**
  61374. * Gets the skybox material created by the helper.
  61375. */
  61376. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61377. private _ground;
  61378. /**
  61379. * Gets the ground mesh created by the helper.
  61380. */
  61381. get ground(): Nullable<Mesh>;
  61382. private _groundTexture;
  61383. /**
  61384. * Gets the ground texture created by the helper.
  61385. */
  61386. get groundTexture(): Nullable<BaseTexture>;
  61387. private _groundMirror;
  61388. /**
  61389. * Gets the ground mirror created by the helper.
  61390. */
  61391. get groundMirror(): Nullable<MirrorTexture>;
  61392. /**
  61393. * Gets the ground mirror render list to helps pushing the meshes
  61394. * you wish in the ground reflection.
  61395. */
  61396. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61397. private _groundMaterial;
  61398. /**
  61399. * Gets the ground material created by the helper.
  61400. */
  61401. get groundMaterial(): Nullable<BackgroundMaterial>;
  61402. /**
  61403. * Stores the creation options.
  61404. */
  61405. private readonly _scene;
  61406. private _options;
  61407. /**
  61408. * This observable will be notified with any error during the creation of the environment,
  61409. * mainly texture creation errors.
  61410. */
  61411. onErrorObservable: Observable<{
  61412. message?: string;
  61413. exception?: any;
  61414. }>;
  61415. /**
  61416. * constructor
  61417. * @param options Defines the options we want to customize the helper
  61418. * @param scene The scene to add the material to
  61419. */
  61420. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61421. /**
  61422. * Updates the background according to the new options
  61423. * @param options
  61424. */
  61425. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61426. /**
  61427. * Sets the primary color of all the available elements.
  61428. * @param color the main color to affect to the ground and the background
  61429. */
  61430. setMainColor(color: Color3): void;
  61431. /**
  61432. * Setup the image processing according to the specified options.
  61433. */
  61434. private _setupImageProcessing;
  61435. /**
  61436. * Setup the environment texture according to the specified options.
  61437. */
  61438. private _setupEnvironmentTexture;
  61439. /**
  61440. * Setup the background according to the specified options.
  61441. */
  61442. private _setupBackground;
  61443. /**
  61444. * Get the scene sizes according to the setup.
  61445. */
  61446. private _getSceneSize;
  61447. /**
  61448. * Setup the ground according to the specified options.
  61449. */
  61450. private _setupGround;
  61451. /**
  61452. * Setup the ground material according to the specified options.
  61453. */
  61454. private _setupGroundMaterial;
  61455. /**
  61456. * Setup the ground diffuse texture according to the specified options.
  61457. */
  61458. private _setupGroundDiffuseTexture;
  61459. /**
  61460. * Setup the ground mirror texture according to the specified options.
  61461. */
  61462. private _setupGroundMirrorTexture;
  61463. /**
  61464. * Setup the ground to receive the mirror texture.
  61465. */
  61466. private _setupMirrorInGroundMaterial;
  61467. /**
  61468. * Setup the skybox according to the specified options.
  61469. */
  61470. private _setupSkybox;
  61471. /**
  61472. * Setup the skybox material according to the specified options.
  61473. */
  61474. private _setupSkyboxMaterial;
  61475. /**
  61476. * Setup the skybox reflection texture according to the specified options.
  61477. */
  61478. private _setupSkyboxReflectionTexture;
  61479. private _errorHandler;
  61480. /**
  61481. * Dispose all the elements created by the Helper.
  61482. */
  61483. dispose(): void;
  61484. }
  61485. }
  61486. declare module BABYLON {
  61487. /**
  61488. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61489. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61490. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61491. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61492. */
  61493. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61494. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61495. /**
  61496. * Define the source as a Monoscopic panoramic 360/180.
  61497. */
  61498. static readonly MODE_MONOSCOPIC: number;
  61499. /**
  61500. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61501. */
  61502. static readonly MODE_TOPBOTTOM: number;
  61503. /**
  61504. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61505. */
  61506. static readonly MODE_SIDEBYSIDE: number;
  61507. private _halfDome;
  61508. private _crossEye;
  61509. protected _useDirectMapping: boolean;
  61510. /**
  61511. * The texture being displayed on the sphere
  61512. */
  61513. protected _texture: T;
  61514. /**
  61515. * Gets the texture being displayed on the sphere
  61516. */
  61517. get texture(): T;
  61518. /**
  61519. * Sets the texture being displayed on the sphere
  61520. */
  61521. set texture(newTexture: T);
  61522. /**
  61523. * The skybox material
  61524. */
  61525. protected _material: BackgroundMaterial;
  61526. /**
  61527. * The surface used for the dome
  61528. */
  61529. protected _mesh: Mesh;
  61530. /**
  61531. * Gets the mesh used for the dome.
  61532. */
  61533. get mesh(): Mesh;
  61534. /**
  61535. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61536. */
  61537. private _halfDomeMask;
  61538. /**
  61539. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61540. * Also see the options.resolution property.
  61541. */
  61542. get fovMultiplier(): number;
  61543. set fovMultiplier(value: number);
  61544. protected _textureMode: number;
  61545. /**
  61546. * Gets or set the current texture mode for the texture. It can be:
  61547. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61548. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61549. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61550. */
  61551. get textureMode(): number;
  61552. /**
  61553. * Sets the current texture mode for the texture. It can be:
  61554. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61555. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61556. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61557. */
  61558. set textureMode(value: number);
  61559. /**
  61560. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61561. */
  61562. get halfDome(): boolean;
  61563. /**
  61564. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61565. */
  61566. set halfDome(enabled: boolean);
  61567. /**
  61568. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61569. */
  61570. set crossEye(enabled: boolean);
  61571. /**
  61572. * Is it a cross-eye texture?
  61573. */
  61574. get crossEye(): boolean;
  61575. /**
  61576. * The background material of this dome.
  61577. */
  61578. get material(): BackgroundMaterial;
  61579. /**
  61580. * Oberserver used in Stereoscopic VR Mode.
  61581. */
  61582. private _onBeforeCameraRenderObserver;
  61583. /**
  61584. * Observable raised when an error occured while loading the 360 image
  61585. */
  61586. onLoadErrorObservable: Observable<string>;
  61587. /**
  61588. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61589. * @param name Element's name, child elements will append suffixes for their own names.
  61590. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61591. * @param options An object containing optional or exposed sub element properties
  61592. */
  61593. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61594. resolution?: number;
  61595. clickToPlay?: boolean;
  61596. autoPlay?: boolean;
  61597. loop?: boolean;
  61598. size?: number;
  61599. poster?: string;
  61600. faceForward?: boolean;
  61601. useDirectMapping?: boolean;
  61602. halfDomeMode?: boolean;
  61603. crossEyeMode?: boolean;
  61604. generateMipMaps?: boolean;
  61605. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61606. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61607. protected _changeTextureMode(value: number): void;
  61608. /**
  61609. * Releases resources associated with this node.
  61610. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61611. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61612. */
  61613. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61614. }
  61615. }
  61616. declare module BABYLON {
  61617. /**
  61618. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61619. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61620. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61621. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61622. */
  61623. export class PhotoDome extends TextureDome<Texture> {
  61624. /**
  61625. * Define the image as a Monoscopic panoramic 360 image.
  61626. */
  61627. static readonly MODE_MONOSCOPIC: number;
  61628. /**
  61629. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61630. */
  61631. static readonly MODE_TOPBOTTOM: number;
  61632. /**
  61633. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61634. */
  61635. static readonly MODE_SIDEBYSIDE: number;
  61636. /**
  61637. * Gets or sets the texture being displayed on the sphere
  61638. */
  61639. get photoTexture(): Texture;
  61640. /**
  61641. * sets the texture being displayed on the sphere
  61642. */
  61643. set photoTexture(value: Texture);
  61644. /**
  61645. * Gets the current video mode for the video. It can be:
  61646. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61647. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61648. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61649. */
  61650. get imageMode(): number;
  61651. /**
  61652. * Sets the current video mode for the video. It can be:
  61653. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61654. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61655. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61656. */
  61657. set imageMode(value: number);
  61658. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61659. }
  61660. }
  61661. declare module BABYLON {
  61662. /**
  61663. * Direct draw surface info
  61664. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61665. */
  61666. export interface DDSInfo {
  61667. /**
  61668. * Width of the texture
  61669. */
  61670. width: number;
  61671. /**
  61672. * Width of the texture
  61673. */
  61674. height: number;
  61675. /**
  61676. * Number of Mipmaps for the texture
  61677. * @see https://en.wikipedia.org/wiki/Mipmap
  61678. */
  61679. mipmapCount: number;
  61680. /**
  61681. * If the textures format is a known fourCC format
  61682. * @see https://www.fourcc.org/
  61683. */
  61684. isFourCC: boolean;
  61685. /**
  61686. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61687. */
  61688. isRGB: boolean;
  61689. /**
  61690. * If the texture is a lumincance format
  61691. */
  61692. isLuminance: boolean;
  61693. /**
  61694. * If this is a cube texture
  61695. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61696. */
  61697. isCube: boolean;
  61698. /**
  61699. * If the texture is a compressed format eg. FOURCC_DXT1
  61700. */
  61701. isCompressed: boolean;
  61702. /**
  61703. * The dxgiFormat of the texture
  61704. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61705. */
  61706. dxgiFormat: number;
  61707. /**
  61708. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61709. */
  61710. textureType: number;
  61711. /**
  61712. * Sphericle polynomial created for the dds texture
  61713. */
  61714. sphericalPolynomial?: SphericalPolynomial;
  61715. }
  61716. /**
  61717. * Class used to provide DDS decompression tools
  61718. */
  61719. export class DDSTools {
  61720. /**
  61721. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61722. */
  61723. static StoreLODInAlphaChannel: boolean;
  61724. /**
  61725. * Gets DDS information from an array buffer
  61726. * @param data defines the array buffer view to read data from
  61727. * @returns the DDS information
  61728. */
  61729. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61730. private static _FloatView;
  61731. private static _Int32View;
  61732. private static _ToHalfFloat;
  61733. private static _FromHalfFloat;
  61734. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61735. private static _GetHalfFloatRGBAArrayBuffer;
  61736. private static _GetFloatRGBAArrayBuffer;
  61737. private static _GetFloatAsUIntRGBAArrayBuffer;
  61738. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61739. private static _GetRGBAArrayBuffer;
  61740. private static _ExtractLongWordOrder;
  61741. private static _GetRGBArrayBuffer;
  61742. private static _GetLuminanceArrayBuffer;
  61743. /**
  61744. * Uploads DDS Levels to a Babylon Texture
  61745. * @hidden
  61746. */
  61747. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61748. }
  61749. interface ThinEngine {
  61750. /**
  61751. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61752. * @param rootUrl defines the url where the file to load is located
  61753. * @param scene defines the current scene
  61754. * @param lodScale defines scale to apply to the mip map selection
  61755. * @param lodOffset defines offset to apply to the mip map selection
  61756. * @param onLoad defines an optional callback raised when the texture is loaded
  61757. * @param onError defines an optional callback raised if there is an issue to load the texture
  61758. * @param format defines the format of the data
  61759. * @param forcedExtension defines the extension to use to pick the right loader
  61760. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61761. * @returns the cube texture as an InternalTexture
  61762. */
  61763. 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;
  61764. }
  61765. }
  61766. declare module BABYLON {
  61767. /**
  61768. * Implementation of the DDS Texture Loader.
  61769. * @hidden
  61770. */
  61771. export class _DDSTextureLoader implements IInternalTextureLoader {
  61772. /**
  61773. * Defines wether the loader supports cascade loading the different faces.
  61774. */
  61775. readonly supportCascades: boolean;
  61776. /**
  61777. * This returns if the loader support the current file information.
  61778. * @param extension defines the file extension of the file being loaded
  61779. * @returns true if the loader can load the specified file
  61780. */
  61781. canLoad(extension: string): boolean;
  61782. /**
  61783. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61784. * @param data contains the texture data
  61785. * @param texture defines the BabylonJS internal texture
  61786. * @param createPolynomials will be true if polynomials have been requested
  61787. * @param onLoad defines the callback to trigger once the texture is ready
  61788. * @param onError defines the callback to trigger in case of error
  61789. */
  61790. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61791. /**
  61792. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61793. * @param data contains the texture data
  61794. * @param texture defines the BabylonJS internal texture
  61795. * @param callback defines the method to call once ready to upload
  61796. */
  61797. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61798. }
  61799. }
  61800. declare module BABYLON {
  61801. /**
  61802. * Implementation of the ENV Texture Loader.
  61803. * @hidden
  61804. */
  61805. export class _ENVTextureLoader implements IInternalTextureLoader {
  61806. /**
  61807. * Defines wether the loader supports cascade loading the different faces.
  61808. */
  61809. readonly supportCascades: boolean;
  61810. /**
  61811. * This returns if the loader support the current file information.
  61812. * @param extension defines the file extension of the file being loaded
  61813. * @returns true if the loader can load the specified file
  61814. */
  61815. canLoad(extension: string): boolean;
  61816. /**
  61817. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61818. * @param data contains the texture data
  61819. * @param texture defines the BabylonJS internal texture
  61820. * @param createPolynomials will be true if polynomials have been requested
  61821. * @param onLoad defines the callback to trigger once the texture is ready
  61822. * @param onError defines the callback to trigger in case of error
  61823. */
  61824. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61825. /**
  61826. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61827. * @param data contains the texture data
  61828. * @param texture defines the BabylonJS internal texture
  61829. * @param callback defines the method to call once ready to upload
  61830. */
  61831. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61832. }
  61833. }
  61834. declare module BABYLON {
  61835. /**
  61836. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61837. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61838. */
  61839. export class KhronosTextureContainer {
  61840. /** contents of the KTX container file */
  61841. data: ArrayBufferView;
  61842. private static HEADER_LEN;
  61843. private static COMPRESSED_2D;
  61844. private static COMPRESSED_3D;
  61845. private static TEX_2D;
  61846. private static TEX_3D;
  61847. /**
  61848. * Gets the openGL type
  61849. */
  61850. glType: number;
  61851. /**
  61852. * Gets the openGL type size
  61853. */
  61854. glTypeSize: number;
  61855. /**
  61856. * Gets the openGL format
  61857. */
  61858. glFormat: number;
  61859. /**
  61860. * Gets the openGL internal format
  61861. */
  61862. glInternalFormat: number;
  61863. /**
  61864. * Gets the base internal format
  61865. */
  61866. glBaseInternalFormat: number;
  61867. /**
  61868. * Gets image width in pixel
  61869. */
  61870. pixelWidth: number;
  61871. /**
  61872. * Gets image height in pixel
  61873. */
  61874. pixelHeight: number;
  61875. /**
  61876. * Gets image depth in pixels
  61877. */
  61878. pixelDepth: number;
  61879. /**
  61880. * Gets the number of array elements
  61881. */
  61882. numberOfArrayElements: number;
  61883. /**
  61884. * Gets the number of faces
  61885. */
  61886. numberOfFaces: number;
  61887. /**
  61888. * Gets the number of mipmap levels
  61889. */
  61890. numberOfMipmapLevels: number;
  61891. /**
  61892. * Gets the bytes of key value data
  61893. */
  61894. bytesOfKeyValueData: number;
  61895. /**
  61896. * Gets the load type
  61897. */
  61898. loadType: number;
  61899. /**
  61900. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61901. */
  61902. isInvalid: boolean;
  61903. /**
  61904. * Creates a new KhronosTextureContainer
  61905. * @param data contents of the KTX container file
  61906. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61907. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61908. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61909. */
  61910. constructor(
  61911. /** contents of the KTX container file */
  61912. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61913. /**
  61914. * Uploads KTX content to a Babylon Texture.
  61915. * It is assumed that the texture has already been created & is currently bound
  61916. * @hidden
  61917. */
  61918. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61919. private _upload2DCompressedLevels;
  61920. /**
  61921. * Checks if the given data starts with a KTX file identifier.
  61922. * @param data the data to check
  61923. * @returns true if the data is a KTX file or false otherwise
  61924. */
  61925. static IsValid(data: ArrayBufferView): boolean;
  61926. }
  61927. }
  61928. declare module BABYLON {
  61929. /**
  61930. * Helper class to push actions to a pool of workers.
  61931. */
  61932. export class WorkerPool implements IDisposable {
  61933. private _workerInfos;
  61934. private _pendingActions;
  61935. /**
  61936. * Constructor
  61937. * @param workers Array of workers to use for actions
  61938. */
  61939. constructor(workers: Array<Worker>);
  61940. /**
  61941. * Terminates all workers and clears any pending actions.
  61942. */
  61943. dispose(): void;
  61944. /**
  61945. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61946. * pended until a worker has completed its action.
  61947. * @param action The action to perform. Call onComplete when the action is complete.
  61948. */
  61949. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61950. private _execute;
  61951. }
  61952. }
  61953. declare module BABYLON {
  61954. /**
  61955. * Class for loading KTX2 files
  61956. */
  61957. export class KhronosTextureContainer2 {
  61958. private static _WorkerPoolPromise?;
  61959. private static _Initialized;
  61960. private static _Ktx2Decoder;
  61961. /**
  61962. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61963. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61964. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61965. * Urls you can change:
  61966. * URLConfig.jsDecoderModule
  61967. * URLConfig.wasmUASTCToASTC
  61968. * URLConfig.wasmUASTCToBC7
  61969. * URLConfig.wasmUASTCToRGBA_UNORM
  61970. * URLConfig.wasmUASTCToRGBA_SRGB
  61971. * URLConfig.jsMSCTranscoder
  61972. * URLConfig.wasmMSCTranscoder
  61973. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  61974. */
  61975. static URLConfig: {
  61976. jsDecoderModule: string;
  61977. wasmUASTCToASTC: null;
  61978. wasmUASTCToBC7: null;
  61979. wasmUASTCToRGBA_UNORM: null;
  61980. wasmUASTCToRGBA_SRGB: null;
  61981. jsMSCTranscoder: null;
  61982. wasmMSCTranscoder: null;
  61983. };
  61984. /**
  61985. * Default number of workers used to handle data decoding
  61986. */
  61987. static DefaultNumWorkers: number;
  61988. private static GetDefaultNumWorkers;
  61989. private _engine;
  61990. private static _CreateWorkerPool;
  61991. /**
  61992. * Constructor
  61993. * @param engine The engine to use
  61994. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61995. */
  61996. constructor(engine: ThinEngine, numWorkers?: number);
  61997. /** @hidden */
  61998. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  61999. /**
  62000. * Stop all async operations and release resources.
  62001. */
  62002. dispose(): void;
  62003. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62004. /**
  62005. * Checks if the given data starts with a KTX2 file identifier.
  62006. * @param data the data to check
  62007. * @returns true if the data is a KTX2 file or false otherwise
  62008. */
  62009. static IsValid(data: ArrayBufferView): boolean;
  62010. }
  62011. }
  62012. declare module BABYLON {
  62013. /**
  62014. * Implementation of the KTX Texture Loader.
  62015. * @hidden
  62016. */
  62017. export class _KTXTextureLoader implements IInternalTextureLoader {
  62018. /**
  62019. * Defines wether the loader supports cascade loading the different faces.
  62020. */
  62021. readonly supportCascades: boolean;
  62022. /**
  62023. * This returns if the loader support the current file information.
  62024. * @param extension defines the file extension of the file being loaded
  62025. * @param mimeType defines the optional mime type of the file being loaded
  62026. * @returns true if the loader can load the specified file
  62027. */
  62028. canLoad(extension: string, mimeType?: string): boolean;
  62029. /**
  62030. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62031. * @param data contains the texture data
  62032. * @param texture defines the BabylonJS internal texture
  62033. * @param createPolynomials will be true if polynomials have been requested
  62034. * @param onLoad defines the callback to trigger once the texture is ready
  62035. * @param onError defines the callback to trigger in case of error
  62036. */
  62037. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62038. /**
  62039. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62040. * @param data contains the texture data
  62041. * @param texture defines the BabylonJS internal texture
  62042. * @param callback defines the method to call once ready to upload
  62043. */
  62044. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62045. }
  62046. }
  62047. declare module BABYLON {
  62048. /** @hidden */
  62049. export var _forceSceneHelpersToBundle: boolean;
  62050. interface Scene {
  62051. /**
  62052. * Creates a default light for the scene.
  62053. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62054. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62055. */
  62056. createDefaultLight(replace?: boolean): void;
  62057. /**
  62058. * Creates a default camera for the scene.
  62059. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62060. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62061. * @param replace has default false, when true replaces the active camera in the scene
  62062. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62063. */
  62064. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62065. /**
  62066. * Creates a default camera and a default light.
  62067. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62068. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62069. * @param replace has the default false, when true replaces the active camera/light in the scene
  62070. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62071. */
  62072. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62073. /**
  62074. * Creates a new sky box
  62075. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62076. * @param environmentTexture defines the texture to use as environment texture
  62077. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62078. * @param scale defines the overall scale of the skybox
  62079. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62080. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62081. * @returns a new mesh holding the sky box
  62082. */
  62083. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62084. /**
  62085. * Creates a new environment
  62086. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62087. * @param options defines the options you can use to configure the environment
  62088. * @returns the new EnvironmentHelper
  62089. */
  62090. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62091. /**
  62092. * Creates a new VREXperienceHelper
  62093. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62094. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62095. * @returns a new VREXperienceHelper
  62096. */
  62097. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62098. /**
  62099. * Creates a new WebXRDefaultExperience
  62100. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62101. * @param options experience options
  62102. * @returns a promise for a new WebXRDefaultExperience
  62103. */
  62104. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62105. }
  62106. }
  62107. declare module BABYLON {
  62108. /**
  62109. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62110. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62111. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62112. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62113. */
  62114. export class VideoDome extends TextureDome<VideoTexture> {
  62115. /**
  62116. * Define the video source as a Monoscopic panoramic 360 video.
  62117. */
  62118. static readonly MODE_MONOSCOPIC: number;
  62119. /**
  62120. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62121. */
  62122. static readonly MODE_TOPBOTTOM: number;
  62123. /**
  62124. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62125. */
  62126. static readonly MODE_SIDEBYSIDE: number;
  62127. /**
  62128. * Get the video texture associated with this video dome
  62129. */
  62130. get videoTexture(): VideoTexture;
  62131. /**
  62132. * Get the video mode of this dome
  62133. */
  62134. get videoMode(): number;
  62135. /**
  62136. * Set the video mode of this dome.
  62137. * @see textureMode
  62138. */
  62139. set videoMode(value: number);
  62140. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62141. }
  62142. }
  62143. declare module BABYLON {
  62144. /**
  62145. * This class can be used to get instrumentation data from a Babylon engine
  62146. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62147. */
  62148. export class EngineInstrumentation implements IDisposable {
  62149. /**
  62150. * Define the instrumented engine.
  62151. */
  62152. engine: Engine;
  62153. private _captureGPUFrameTime;
  62154. private _gpuFrameTimeToken;
  62155. private _gpuFrameTime;
  62156. private _captureShaderCompilationTime;
  62157. private _shaderCompilationTime;
  62158. private _onBeginFrameObserver;
  62159. private _onEndFrameObserver;
  62160. private _onBeforeShaderCompilationObserver;
  62161. private _onAfterShaderCompilationObserver;
  62162. /**
  62163. * Gets the perf counter used for GPU frame time
  62164. */
  62165. get gpuFrameTimeCounter(): PerfCounter;
  62166. /**
  62167. * Gets the GPU frame time capture status
  62168. */
  62169. get captureGPUFrameTime(): boolean;
  62170. /**
  62171. * Enable or disable the GPU frame time capture
  62172. */
  62173. set captureGPUFrameTime(value: boolean);
  62174. /**
  62175. * Gets the perf counter used for shader compilation time
  62176. */
  62177. get shaderCompilationTimeCounter(): PerfCounter;
  62178. /**
  62179. * Gets the shader compilation time capture status
  62180. */
  62181. get captureShaderCompilationTime(): boolean;
  62182. /**
  62183. * Enable or disable the shader compilation time capture
  62184. */
  62185. set captureShaderCompilationTime(value: boolean);
  62186. /**
  62187. * Instantiates a new engine instrumentation.
  62188. * This class can be used to get instrumentation data from a Babylon engine
  62189. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62190. * @param engine Defines the engine to instrument
  62191. */
  62192. constructor(
  62193. /**
  62194. * Define the instrumented engine.
  62195. */
  62196. engine: Engine);
  62197. /**
  62198. * Dispose and release associated resources.
  62199. */
  62200. dispose(): void;
  62201. }
  62202. }
  62203. declare module BABYLON {
  62204. /**
  62205. * This class can be used to get instrumentation data from a Babylon engine
  62206. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62207. */
  62208. export class SceneInstrumentation implements IDisposable {
  62209. /**
  62210. * Defines the scene to instrument
  62211. */
  62212. scene: Scene;
  62213. private _captureActiveMeshesEvaluationTime;
  62214. private _activeMeshesEvaluationTime;
  62215. private _captureRenderTargetsRenderTime;
  62216. private _renderTargetsRenderTime;
  62217. private _captureFrameTime;
  62218. private _frameTime;
  62219. private _captureRenderTime;
  62220. private _renderTime;
  62221. private _captureInterFrameTime;
  62222. private _interFrameTime;
  62223. private _captureParticlesRenderTime;
  62224. private _particlesRenderTime;
  62225. private _captureSpritesRenderTime;
  62226. private _spritesRenderTime;
  62227. private _capturePhysicsTime;
  62228. private _physicsTime;
  62229. private _captureAnimationsTime;
  62230. private _animationsTime;
  62231. private _captureCameraRenderTime;
  62232. private _cameraRenderTime;
  62233. private _onBeforeActiveMeshesEvaluationObserver;
  62234. private _onAfterActiveMeshesEvaluationObserver;
  62235. private _onBeforeRenderTargetsRenderObserver;
  62236. private _onAfterRenderTargetsRenderObserver;
  62237. private _onAfterRenderObserver;
  62238. private _onBeforeDrawPhaseObserver;
  62239. private _onAfterDrawPhaseObserver;
  62240. private _onBeforeAnimationsObserver;
  62241. private _onBeforeParticlesRenderingObserver;
  62242. private _onAfterParticlesRenderingObserver;
  62243. private _onBeforeSpritesRenderingObserver;
  62244. private _onAfterSpritesRenderingObserver;
  62245. private _onBeforePhysicsObserver;
  62246. private _onAfterPhysicsObserver;
  62247. private _onAfterAnimationsObserver;
  62248. private _onBeforeCameraRenderObserver;
  62249. private _onAfterCameraRenderObserver;
  62250. /**
  62251. * Gets the perf counter used for active meshes evaluation time
  62252. */
  62253. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62254. /**
  62255. * Gets the active meshes evaluation time capture status
  62256. */
  62257. get captureActiveMeshesEvaluationTime(): boolean;
  62258. /**
  62259. * Enable or disable the active meshes evaluation time capture
  62260. */
  62261. set captureActiveMeshesEvaluationTime(value: boolean);
  62262. /**
  62263. * Gets the perf counter used for render targets render time
  62264. */
  62265. get renderTargetsRenderTimeCounter(): PerfCounter;
  62266. /**
  62267. * Gets the render targets render time capture status
  62268. */
  62269. get captureRenderTargetsRenderTime(): boolean;
  62270. /**
  62271. * Enable or disable the render targets render time capture
  62272. */
  62273. set captureRenderTargetsRenderTime(value: boolean);
  62274. /**
  62275. * Gets the perf counter used for particles render time
  62276. */
  62277. get particlesRenderTimeCounter(): PerfCounter;
  62278. /**
  62279. * Gets the particles render time capture status
  62280. */
  62281. get captureParticlesRenderTime(): boolean;
  62282. /**
  62283. * Enable or disable the particles render time capture
  62284. */
  62285. set captureParticlesRenderTime(value: boolean);
  62286. /**
  62287. * Gets the perf counter used for sprites render time
  62288. */
  62289. get spritesRenderTimeCounter(): PerfCounter;
  62290. /**
  62291. * Gets the sprites render time capture status
  62292. */
  62293. get captureSpritesRenderTime(): boolean;
  62294. /**
  62295. * Enable or disable the sprites render time capture
  62296. */
  62297. set captureSpritesRenderTime(value: boolean);
  62298. /**
  62299. * Gets the perf counter used for physics time
  62300. */
  62301. get physicsTimeCounter(): PerfCounter;
  62302. /**
  62303. * Gets the physics time capture status
  62304. */
  62305. get capturePhysicsTime(): boolean;
  62306. /**
  62307. * Enable or disable the physics time capture
  62308. */
  62309. set capturePhysicsTime(value: boolean);
  62310. /**
  62311. * Gets the perf counter used for animations time
  62312. */
  62313. get animationsTimeCounter(): PerfCounter;
  62314. /**
  62315. * Gets the animations time capture status
  62316. */
  62317. get captureAnimationsTime(): boolean;
  62318. /**
  62319. * Enable or disable the animations time capture
  62320. */
  62321. set captureAnimationsTime(value: boolean);
  62322. /**
  62323. * Gets the perf counter used for frame time capture
  62324. */
  62325. get frameTimeCounter(): PerfCounter;
  62326. /**
  62327. * Gets the frame time capture status
  62328. */
  62329. get captureFrameTime(): boolean;
  62330. /**
  62331. * Enable or disable the frame time capture
  62332. */
  62333. set captureFrameTime(value: boolean);
  62334. /**
  62335. * Gets the perf counter used for inter-frames time capture
  62336. */
  62337. get interFrameTimeCounter(): PerfCounter;
  62338. /**
  62339. * Gets the inter-frames time capture status
  62340. */
  62341. get captureInterFrameTime(): boolean;
  62342. /**
  62343. * Enable or disable the inter-frames time capture
  62344. */
  62345. set captureInterFrameTime(value: boolean);
  62346. /**
  62347. * Gets the perf counter used for render time capture
  62348. */
  62349. get renderTimeCounter(): PerfCounter;
  62350. /**
  62351. * Gets the render time capture status
  62352. */
  62353. get captureRenderTime(): boolean;
  62354. /**
  62355. * Enable or disable the render time capture
  62356. */
  62357. set captureRenderTime(value: boolean);
  62358. /**
  62359. * Gets the perf counter used for camera render time capture
  62360. */
  62361. get cameraRenderTimeCounter(): PerfCounter;
  62362. /**
  62363. * Gets the camera render time capture status
  62364. */
  62365. get captureCameraRenderTime(): boolean;
  62366. /**
  62367. * Enable or disable the camera render time capture
  62368. */
  62369. set captureCameraRenderTime(value: boolean);
  62370. /**
  62371. * Gets the perf counter used for draw calls
  62372. */
  62373. get drawCallsCounter(): PerfCounter;
  62374. /**
  62375. * Instantiates a new scene instrumentation.
  62376. * This class can be used to get instrumentation data from a Babylon engine
  62377. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62378. * @param scene Defines the scene to instrument
  62379. */
  62380. constructor(
  62381. /**
  62382. * Defines the scene to instrument
  62383. */
  62384. scene: Scene);
  62385. /**
  62386. * Dispose and release associated resources.
  62387. */
  62388. dispose(): void;
  62389. }
  62390. }
  62391. declare module BABYLON {
  62392. /** @hidden */
  62393. export var glowMapGenerationPixelShader: {
  62394. name: string;
  62395. shader: string;
  62396. };
  62397. }
  62398. declare module BABYLON {
  62399. /** @hidden */
  62400. export var glowMapGenerationVertexShader: {
  62401. name: string;
  62402. shader: string;
  62403. };
  62404. }
  62405. declare module BABYLON {
  62406. /**
  62407. * Effect layer options. This helps customizing the behaviour
  62408. * of the effect layer.
  62409. */
  62410. export interface IEffectLayerOptions {
  62411. /**
  62412. * Multiplication factor apply to the canvas size to compute the render target size
  62413. * used to generated the objects (the smaller the faster).
  62414. */
  62415. mainTextureRatio: number;
  62416. /**
  62417. * Enforces a fixed size texture to ensure effect stability across devices.
  62418. */
  62419. mainTextureFixedSize?: number;
  62420. /**
  62421. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62422. */
  62423. alphaBlendingMode: number;
  62424. /**
  62425. * The camera attached to the layer.
  62426. */
  62427. camera: Nullable<Camera>;
  62428. /**
  62429. * The rendering group to draw the layer in.
  62430. */
  62431. renderingGroupId: number;
  62432. }
  62433. /**
  62434. * The effect layer Helps adding post process effect blended with the main pass.
  62435. *
  62436. * This can be for instance use to generate glow or higlight effects on the scene.
  62437. *
  62438. * The effect layer class can not be used directly and is intented to inherited from to be
  62439. * customized per effects.
  62440. */
  62441. export abstract class EffectLayer {
  62442. private _vertexBuffers;
  62443. private _indexBuffer;
  62444. private _cachedDefines;
  62445. private _effectLayerMapGenerationEffect;
  62446. private _effectLayerOptions;
  62447. private _mergeEffect;
  62448. protected _scene: Scene;
  62449. protected _engine: Engine;
  62450. protected _maxSize: number;
  62451. protected _mainTextureDesiredSize: ISize;
  62452. protected _mainTexture: RenderTargetTexture;
  62453. protected _shouldRender: boolean;
  62454. protected _postProcesses: PostProcess[];
  62455. protected _textures: BaseTexture[];
  62456. protected _emissiveTextureAndColor: {
  62457. texture: Nullable<BaseTexture>;
  62458. color: Color4;
  62459. };
  62460. /**
  62461. * The name of the layer
  62462. */
  62463. name: string;
  62464. /**
  62465. * The clear color of the texture used to generate the glow map.
  62466. */
  62467. neutralColor: Color4;
  62468. /**
  62469. * Specifies whether the highlight layer is enabled or not.
  62470. */
  62471. isEnabled: boolean;
  62472. /**
  62473. * Gets the camera attached to the layer.
  62474. */
  62475. get camera(): Nullable<Camera>;
  62476. /**
  62477. * Gets the rendering group id the layer should render in.
  62478. */
  62479. get renderingGroupId(): number;
  62480. set renderingGroupId(renderingGroupId: number);
  62481. /**
  62482. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62483. */
  62484. disableBoundingBoxesFromEffectLayer: boolean;
  62485. /**
  62486. * An event triggered when the effect layer has been disposed.
  62487. */
  62488. onDisposeObservable: Observable<EffectLayer>;
  62489. /**
  62490. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62491. */
  62492. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62493. /**
  62494. * An event triggered when the generated texture is being merged in the scene.
  62495. */
  62496. onBeforeComposeObservable: Observable<EffectLayer>;
  62497. /**
  62498. * An event triggered when the mesh is rendered into the effect render target.
  62499. */
  62500. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62501. /**
  62502. * An event triggered after the mesh has been rendered into the effect render target.
  62503. */
  62504. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62505. /**
  62506. * An event triggered when the generated texture has been merged in the scene.
  62507. */
  62508. onAfterComposeObservable: Observable<EffectLayer>;
  62509. /**
  62510. * An event triggered when the efffect layer changes its size.
  62511. */
  62512. onSizeChangedObservable: Observable<EffectLayer>;
  62513. /** @hidden */
  62514. static _SceneComponentInitialization: (scene: Scene) => void;
  62515. /**
  62516. * Instantiates a new effect Layer and references it in the scene.
  62517. * @param name The name of the layer
  62518. * @param scene The scene to use the layer in
  62519. */
  62520. constructor(
  62521. /** The Friendly of the effect in the scene */
  62522. name: string, scene: Scene);
  62523. /**
  62524. * Get the effect name of the layer.
  62525. * @return The effect name
  62526. */
  62527. abstract getEffectName(): string;
  62528. /**
  62529. * Checks for the readiness of the element composing the layer.
  62530. * @param subMesh the mesh to check for
  62531. * @param useInstances specify whether or not to use instances to render the mesh
  62532. * @return true if ready otherwise, false
  62533. */
  62534. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62535. /**
  62536. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62537. * @returns true if the effect requires stencil during the main canvas render pass.
  62538. */
  62539. abstract needStencil(): boolean;
  62540. /**
  62541. * Create the merge effect. This is the shader use to blit the information back
  62542. * to the main canvas at the end of the scene rendering.
  62543. * @returns The effect containing the shader used to merge the effect on the main canvas
  62544. */
  62545. protected abstract _createMergeEffect(): Effect;
  62546. /**
  62547. * Creates the render target textures and post processes used in the effect layer.
  62548. */
  62549. protected abstract _createTextureAndPostProcesses(): void;
  62550. /**
  62551. * Implementation specific of rendering the generating effect on the main canvas.
  62552. * @param effect The effect used to render through
  62553. */
  62554. protected abstract _internalRender(effect: Effect): void;
  62555. /**
  62556. * Sets the required values for both the emissive texture and and the main color.
  62557. */
  62558. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62559. /**
  62560. * Free any resources and references associated to a mesh.
  62561. * Internal use
  62562. * @param mesh The mesh to free.
  62563. */
  62564. abstract _disposeMesh(mesh: Mesh): void;
  62565. /**
  62566. * Serializes this layer (Glow or Highlight for example)
  62567. * @returns a serialized layer object
  62568. */
  62569. abstract serialize?(): any;
  62570. /**
  62571. * Initializes the effect layer with the required options.
  62572. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62573. */
  62574. protected _init(options: Partial<IEffectLayerOptions>): void;
  62575. /**
  62576. * Generates the index buffer of the full screen quad blending to the main canvas.
  62577. */
  62578. private _generateIndexBuffer;
  62579. /**
  62580. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62581. */
  62582. private _generateVertexBuffer;
  62583. /**
  62584. * Sets the main texture desired size which is the closest power of two
  62585. * of the engine canvas size.
  62586. */
  62587. private _setMainTextureSize;
  62588. /**
  62589. * Creates the main texture for the effect layer.
  62590. */
  62591. protected _createMainTexture(): void;
  62592. /**
  62593. * Adds specific effects defines.
  62594. * @param defines The defines to add specifics to.
  62595. */
  62596. protected _addCustomEffectDefines(defines: string[]): void;
  62597. /**
  62598. * Checks for the readiness of the element composing the layer.
  62599. * @param subMesh the mesh to check for
  62600. * @param useInstances specify whether or not to use instances to render the mesh
  62601. * @param emissiveTexture the associated emissive texture used to generate the glow
  62602. * @return true if ready otherwise, false
  62603. */
  62604. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62605. /**
  62606. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62607. */
  62608. render(): void;
  62609. /**
  62610. * Determine if a given mesh will be used in the current effect.
  62611. * @param mesh mesh to test
  62612. * @returns true if the mesh will be used
  62613. */
  62614. hasMesh(mesh: AbstractMesh): boolean;
  62615. /**
  62616. * Returns true if the layer contains information to display, otherwise false.
  62617. * @returns true if the glow layer should be rendered
  62618. */
  62619. shouldRender(): boolean;
  62620. /**
  62621. * Returns true if the mesh should render, otherwise false.
  62622. * @param mesh The mesh to render
  62623. * @returns true if it should render otherwise false
  62624. */
  62625. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62626. /**
  62627. * Returns true if the mesh can be rendered, otherwise false.
  62628. * @param mesh The mesh to render
  62629. * @param material The material used on the mesh
  62630. * @returns true if it can be rendered otherwise false
  62631. */
  62632. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62633. /**
  62634. * Returns true if the mesh should render, otherwise false.
  62635. * @param mesh The mesh to render
  62636. * @returns true if it should render otherwise false
  62637. */
  62638. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62639. /**
  62640. * Renders the submesh passed in parameter to the generation map.
  62641. */
  62642. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62643. /**
  62644. * Defines whether the current material of the mesh should be use to render the effect.
  62645. * @param mesh defines the current mesh to render
  62646. */
  62647. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62648. /**
  62649. * Rebuild the required buffers.
  62650. * @hidden Internal use only.
  62651. */
  62652. _rebuild(): void;
  62653. /**
  62654. * Dispose only the render target textures and post process.
  62655. */
  62656. private _disposeTextureAndPostProcesses;
  62657. /**
  62658. * Dispose the highlight layer and free resources.
  62659. */
  62660. dispose(): void;
  62661. /**
  62662. * Gets the class name of the effect layer
  62663. * @returns the string with the class name of the effect layer
  62664. */
  62665. getClassName(): string;
  62666. /**
  62667. * Creates an effect layer from parsed effect layer data
  62668. * @param parsedEffectLayer defines effect layer data
  62669. * @param scene defines the current scene
  62670. * @param rootUrl defines the root URL containing the effect layer information
  62671. * @returns a parsed effect Layer
  62672. */
  62673. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62674. }
  62675. }
  62676. declare module BABYLON {
  62677. interface AbstractScene {
  62678. /**
  62679. * The list of effect layers (highlights/glow) added to the scene
  62680. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62681. * @see https://doc.babylonjs.com/how_to/glow_layer
  62682. */
  62683. effectLayers: Array<EffectLayer>;
  62684. /**
  62685. * Removes the given effect layer from this scene.
  62686. * @param toRemove defines the effect layer to remove
  62687. * @returns the index of the removed effect layer
  62688. */
  62689. removeEffectLayer(toRemove: EffectLayer): number;
  62690. /**
  62691. * Adds the given effect layer to this scene
  62692. * @param newEffectLayer defines the effect layer to add
  62693. */
  62694. addEffectLayer(newEffectLayer: EffectLayer): void;
  62695. }
  62696. /**
  62697. * Defines the layer scene component responsible to manage any effect layers
  62698. * in a given scene.
  62699. */
  62700. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62701. /**
  62702. * The component name helpfull to identify the component in the list of scene components.
  62703. */
  62704. readonly name: string;
  62705. /**
  62706. * The scene the component belongs to.
  62707. */
  62708. scene: Scene;
  62709. private _engine;
  62710. private _renderEffects;
  62711. private _needStencil;
  62712. private _previousStencilState;
  62713. /**
  62714. * Creates a new instance of the component for the given scene
  62715. * @param scene Defines the scene to register the component in
  62716. */
  62717. constructor(scene: Scene);
  62718. /**
  62719. * Registers the component in a given scene
  62720. */
  62721. register(): void;
  62722. /**
  62723. * Rebuilds the elements related to this component in case of
  62724. * context lost for instance.
  62725. */
  62726. rebuild(): void;
  62727. /**
  62728. * Serializes the component data to the specified json object
  62729. * @param serializationObject The object to serialize to
  62730. */
  62731. serialize(serializationObject: any): void;
  62732. /**
  62733. * Adds all the elements from the container to the scene
  62734. * @param container the container holding the elements
  62735. */
  62736. addFromContainer(container: AbstractScene): void;
  62737. /**
  62738. * Removes all the elements in the container from the scene
  62739. * @param container contains the elements to remove
  62740. * @param dispose if the removed element should be disposed (default: false)
  62741. */
  62742. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62743. /**
  62744. * Disposes the component and the associated ressources.
  62745. */
  62746. dispose(): void;
  62747. private _isReadyForMesh;
  62748. private _renderMainTexture;
  62749. private _setStencil;
  62750. private _setStencilBack;
  62751. private _draw;
  62752. private _drawCamera;
  62753. private _drawRenderingGroup;
  62754. }
  62755. }
  62756. declare module BABYLON {
  62757. /** @hidden */
  62758. export var glowMapMergePixelShader: {
  62759. name: string;
  62760. shader: string;
  62761. };
  62762. }
  62763. declare module BABYLON {
  62764. /** @hidden */
  62765. export var glowMapMergeVertexShader: {
  62766. name: string;
  62767. shader: string;
  62768. };
  62769. }
  62770. declare module BABYLON {
  62771. interface AbstractScene {
  62772. /**
  62773. * Return a the first highlight layer of the scene with a given name.
  62774. * @param name The name of the highlight layer to look for.
  62775. * @return The highlight layer if found otherwise null.
  62776. */
  62777. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62778. }
  62779. /**
  62780. * Glow layer options. This helps customizing the behaviour
  62781. * of the glow layer.
  62782. */
  62783. export interface IGlowLayerOptions {
  62784. /**
  62785. * Multiplication factor apply to the canvas size to compute the render target size
  62786. * used to generated the glowing objects (the smaller the faster).
  62787. */
  62788. mainTextureRatio: number;
  62789. /**
  62790. * Enforces a fixed size texture to ensure resize independant blur.
  62791. */
  62792. mainTextureFixedSize?: number;
  62793. /**
  62794. * How big is the kernel of the blur texture.
  62795. */
  62796. blurKernelSize: number;
  62797. /**
  62798. * The camera attached to the layer.
  62799. */
  62800. camera: Nullable<Camera>;
  62801. /**
  62802. * Enable MSAA by chosing the number of samples.
  62803. */
  62804. mainTextureSamples?: number;
  62805. /**
  62806. * The rendering group to draw the layer in.
  62807. */
  62808. renderingGroupId: number;
  62809. }
  62810. /**
  62811. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62812. *
  62813. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62814. *
  62815. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62816. */
  62817. export class GlowLayer extends EffectLayer {
  62818. /**
  62819. * Effect Name of the layer.
  62820. */
  62821. static readonly EffectName: string;
  62822. /**
  62823. * The default blur kernel size used for the glow.
  62824. */
  62825. static DefaultBlurKernelSize: number;
  62826. /**
  62827. * The default texture size ratio used for the glow.
  62828. */
  62829. static DefaultTextureRatio: number;
  62830. /**
  62831. * Sets the kernel size of the blur.
  62832. */
  62833. set blurKernelSize(value: number);
  62834. /**
  62835. * Gets the kernel size of the blur.
  62836. */
  62837. get blurKernelSize(): number;
  62838. /**
  62839. * Sets the glow intensity.
  62840. */
  62841. set intensity(value: number);
  62842. /**
  62843. * Gets the glow intensity.
  62844. */
  62845. get intensity(): number;
  62846. private _options;
  62847. private _intensity;
  62848. private _horizontalBlurPostprocess1;
  62849. private _verticalBlurPostprocess1;
  62850. private _horizontalBlurPostprocess2;
  62851. private _verticalBlurPostprocess2;
  62852. private _blurTexture1;
  62853. private _blurTexture2;
  62854. private _postProcesses1;
  62855. private _postProcesses2;
  62856. private _includedOnlyMeshes;
  62857. private _excludedMeshes;
  62858. private _meshesUsingTheirOwnMaterials;
  62859. /**
  62860. * Callback used to let the user override the color selection on a per mesh basis
  62861. */
  62862. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62863. /**
  62864. * Callback used to let the user override the texture selection on a per mesh basis
  62865. */
  62866. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62867. /**
  62868. * Instantiates a new glow Layer and references it to the scene.
  62869. * @param name The name of the layer
  62870. * @param scene The scene to use the layer in
  62871. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62872. */
  62873. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62874. /**
  62875. * Get the effect name of the layer.
  62876. * @return The effect name
  62877. */
  62878. getEffectName(): string;
  62879. /**
  62880. * Create the merge effect. This is the shader use to blit the information back
  62881. * to the main canvas at the end of the scene rendering.
  62882. */
  62883. protected _createMergeEffect(): Effect;
  62884. /**
  62885. * Creates the render target textures and post processes used in the glow layer.
  62886. */
  62887. protected _createTextureAndPostProcesses(): void;
  62888. /**
  62889. * Checks for the readiness of the element composing the layer.
  62890. * @param subMesh the mesh to check for
  62891. * @param useInstances specify wether or not to use instances to render the mesh
  62892. * @param emissiveTexture the associated emissive texture used to generate the glow
  62893. * @return true if ready otherwise, false
  62894. */
  62895. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62896. /**
  62897. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62898. */
  62899. needStencil(): boolean;
  62900. /**
  62901. * Returns true if the mesh can be rendered, otherwise false.
  62902. * @param mesh The mesh to render
  62903. * @param material The material used on the mesh
  62904. * @returns true if it can be rendered otherwise false
  62905. */
  62906. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62907. /**
  62908. * Implementation specific of rendering the generating effect on the main canvas.
  62909. * @param effect The effect used to render through
  62910. */
  62911. protected _internalRender(effect: Effect): void;
  62912. /**
  62913. * Sets the required values for both the emissive texture and and the main color.
  62914. */
  62915. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62916. /**
  62917. * Returns true if the mesh should render, otherwise false.
  62918. * @param mesh The mesh to render
  62919. * @returns true if it should render otherwise false
  62920. */
  62921. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62922. /**
  62923. * Adds specific effects defines.
  62924. * @param defines The defines to add specifics to.
  62925. */
  62926. protected _addCustomEffectDefines(defines: string[]): void;
  62927. /**
  62928. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62929. * @param mesh The mesh to exclude from the glow layer
  62930. */
  62931. addExcludedMesh(mesh: Mesh): void;
  62932. /**
  62933. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62934. * @param mesh The mesh to remove
  62935. */
  62936. removeExcludedMesh(mesh: Mesh): void;
  62937. /**
  62938. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62939. * @param mesh The mesh to include in the glow layer
  62940. */
  62941. addIncludedOnlyMesh(mesh: Mesh): void;
  62942. /**
  62943. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62944. * @param mesh The mesh to remove
  62945. */
  62946. removeIncludedOnlyMesh(mesh: Mesh): void;
  62947. /**
  62948. * Determine if a given mesh will be used in the glow layer
  62949. * @param mesh The mesh to test
  62950. * @returns true if the mesh will be highlighted by the current glow layer
  62951. */
  62952. hasMesh(mesh: AbstractMesh): boolean;
  62953. /**
  62954. * Defines whether the current material of the mesh should be use to render the effect.
  62955. * @param mesh defines the current mesh to render
  62956. */
  62957. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62958. /**
  62959. * Add a mesh to be rendered through its own material and not with emissive only.
  62960. * @param mesh The mesh for which we need to use its material
  62961. */
  62962. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62963. /**
  62964. * Remove a mesh from being rendered through its own material and not with emissive only.
  62965. * @param mesh The mesh for which we need to not use its material
  62966. */
  62967. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62968. /**
  62969. * Free any resources and references associated to a mesh.
  62970. * Internal use
  62971. * @param mesh The mesh to free.
  62972. * @hidden
  62973. */
  62974. _disposeMesh(mesh: Mesh): void;
  62975. /**
  62976. * Gets the class name of the effect layer
  62977. * @returns the string with the class name of the effect layer
  62978. */
  62979. getClassName(): string;
  62980. /**
  62981. * Serializes this glow layer
  62982. * @returns a serialized glow layer object
  62983. */
  62984. serialize(): any;
  62985. /**
  62986. * Creates a Glow Layer from parsed glow layer data
  62987. * @param parsedGlowLayer defines glow layer data
  62988. * @param scene defines the current scene
  62989. * @param rootUrl defines the root URL containing the glow layer information
  62990. * @returns a parsed Glow Layer
  62991. */
  62992. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62993. }
  62994. }
  62995. declare module BABYLON {
  62996. /** @hidden */
  62997. export var glowBlurPostProcessPixelShader: {
  62998. name: string;
  62999. shader: string;
  63000. };
  63001. }
  63002. declare module BABYLON {
  63003. interface AbstractScene {
  63004. /**
  63005. * Return a the first highlight layer of the scene with a given name.
  63006. * @param name The name of the highlight layer to look for.
  63007. * @return The highlight layer if found otherwise null.
  63008. */
  63009. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63010. }
  63011. /**
  63012. * Highlight layer options. This helps customizing the behaviour
  63013. * of the highlight layer.
  63014. */
  63015. export interface IHighlightLayerOptions {
  63016. /**
  63017. * Multiplication factor apply to the canvas size to compute the render target size
  63018. * used to generated the glowing objects (the smaller the faster).
  63019. */
  63020. mainTextureRatio: number;
  63021. /**
  63022. * Enforces a fixed size texture to ensure resize independant blur.
  63023. */
  63024. mainTextureFixedSize?: number;
  63025. /**
  63026. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63027. * of the picture to blur (the smaller the faster).
  63028. */
  63029. blurTextureSizeRatio: number;
  63030. /**
  63031. * How big in texel of the blur texture is the vertical blur.
  63032. */
  63033. blurVerticalSize: number;
  63034. /**
  63035. * How big in texel of the blur texture is the horizontal blur.
  63036. */
  63037. blurHorizontalSize: number;
  63038. /**
  63039. * Alpha blending mode used to apply the blur. Default is combine.
  63040. */
  63041. alphaBlendingMode: number;
  63042. /**
  63043. * The camera attached to the layer.
  63044. */
  63045. camera: Nullable<Camera>;
  63046. /**
  63047. * Should we display highlight as a solid stroke?
  63048. */
  63049. isStroke?: boolean;
  63050. /**
  63051. * The rendering group to draw the layer in.
  63052. */
  63053. renderingGroupId: number;
  63054. }
  63055. /**
  63056. * The highlight layer Helps adding a glow effect around a mesh.
  63057. *
  63058. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63059. * glowy meshes to your scene.
  63060. *
  63061. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63062. */
  63063. export class HighlightLayer extends EffectLayer {
  63064. name: string;
  63065. /**
  63066. * Effect Name of the highlight layer.
  63067. */
  63068. static readonly EffectName: string;
  63069. /**
  63070. * The neutral color used during the preparation of the glow effect.
  63071. * This is black by default as the blend operation is a blend operation.
  63072. */
  63073. static NeutralColor: Color4;
  63074. /**
  63075. * Stencil value used for glowing meshes.
  63076. */
  63077. static GlowingMeshStencilReference: number;
  63078. /**
  63079. * Stencil value used for the other meshes in the scene.
  63080. */
  63081. static NormalMeshStencilReference: number;
  63082. /**
  63083. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63084. */
  63085. innerGlow: boolean;
  63086. /**
  63087. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63088. */
  63089. outerGlow: boolean;
  63090. /**
  63091. * Specifies the horizontal size of the blur.
  63092. */
  63093. set blurHorizontalSize(value: number);
  63094. /**
  63095. * Specifies the vertical size of the blur.
  63096. */
  63097. set blurVerticalSize(value: number);
  63098. /**
  63099. * Gets the horizontal size of the blur.
  63100. */
  63101. get blurHorizontalSize(): number;
  63102. /**
  63103. * Gets the vertical size of the blur.
  63104. */
  63105. get blurVerticalSize(): number;
  63106. /**
  63107. * An event triggered when the highlight layer is being blurred.
  63108. */
  63109. onBeforeBlurObservable: Observable<HighlightLayer>;
  63110. /**
  63111. * An event triggered when the highlight layer has been blurred.
  63112. */
  63113. onAfterBlurObservable: Observable<HighlightLayer>;
  63114. private _instanceGlowingMeshStencilReference;
  63115. private _options;
  63116. private _downSamplePostprocess;
  63117. private _horizontalBlurPostprocess;
  63118. private _verticalBlurPostprocess;
  63119. private _blurTexture;
  63120. private _meshes;
  63121. private _excludedMeshes;
  63122. /**
  63123. * Instantiates a new highlight Layer and references it to the scene..
  63124. * @param name The name of the layer
  63125. * @param scene The scene to use the layer in
  63126. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63127. */
  63128. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63129. /**
  63130. * Get the effect name of the layer.
  63131. * @return The effect name
  63132. */
  63133. getEffectName(): string;
  63134. /**
  63135. * Create the merge effect. This is the shader use to blit the information back
  63136. * to the main canvas at the end of the scene rendering.
  63137. */
  63138. protected _createMergeEffect(): Effect;
  63139. /**
  63140. * Creates the render target textures and post processes used in the highlight layer.
  63141. */
  63142. protected _createTextureAndPostProcesses(): void;
  63143. /**
  63144. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63145. */
  63146. needStencil(): boolean;
  63147. /**
  63148. * Checks for the readiness of the element composing the layer.
  63149. * @param subMesh the mesh to check for
  63150. * @param useInstances specify wether or not to use instances to render the mesh
  63151. * @param emissiveTexture the associated emissive texture used to generate the glow
  63152. * @return true if ready otherwise, false
  63153. */
  63154. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63155. /**
  63156. * Implementation specific of rendering the generating effect on the main canvas.
  63157. * @param effect The effect used to render through
  63158. */
  63159. protected _internalRender(effect: Effect): void;
  63160. /**
  63161. * Returns true if the layer contains information to display, otherwise false.
  63162. */
  63163. shouldRender(): boolean;
  63164. /**
  63165. * Returns true if the mesh should render, otherwise false.
  63166. * @param mesh The mesh to render
  63167. * @returns true if it should render otherwise false
  63168. */
  63169. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63170. /**
  63171. * Returns true if the mesh can be rendered, otherwise false.
  63172. * @param mesh The mesh to render
  63173. * @param material The material used on the mesh
  63174. * @returns true if it can be rendered otherwise false
  63175. */
  63176. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63177. /**
  63178. * Adds specific effects defines.
  63179. * @param defines The defines to add specifics to.
  63180. */
  63181. protected _addCustomEffectDefines(defines: string[]): void;
  63182. /**
  63183. * Sets the required values for both the emissive texture and and the main color.
  63184. */
  63185. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63186. /**
  63187. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63188. * @param mesh The mesh to exclude from the highlight layer
  63189. */
  63190. addExcludedMesh(mesh: Mesh): void;
  63191. /**
  63192. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63193. * @param mesh The mesh to highlight
  63194. */
  63195. removeExcludedMesh(mesh: Mesh): void;
  63196. /**
  63197. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63198. * @param mesh mesh to test
  63199. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63200. */
  63201. hasMesh(mesh: AbstractMesh): boolean;
  63202. /**
  63203. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63204. * @param mesh The mesh to highlight
  63205. * @param color The color of the highlight
  63206. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63207. */
  63208. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63209. /**
  63210. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63211. * @param mesh The mesh to highlight
  63212. */
  63213. removeMesh(mesh: Mesh): void;
  63214. /**
  63215. * Remove all the meshes currently referenced in the highlight layer
  63216. */
  63217. removeAllMeshes(): void;
  63218. /**
  63219. * Force the stencil to the normal expected value for none glowing parts
  63220. */
  63221. private _defaultStencilReference;
  63222. /**
  63223. * Free any resources and references associated to a mesh.
  63224. * Internal use
  63225. * @param mesh The mesh to free.
  63226. * @hidden
  63227. */
  63228. _disposeMesh(mesh: Mesh): void;
  63229. /**
  63230. * Dispose the highlight layer and free resources.
  63231. */
  63232. dispose(): void;
  63233. /**
  63234. * Gets the class name of the effect layer
  63235. * @returns the string with the class name of the effect layer
  63236. */
  63237. getClassName(): string;
  63238. /**
  63239. * Serializes this Highlight layer
  63240. * @returns a serialized Highlight layer object
  63241. */
  63242. serialize(): any;
  63243. /**
  63244. * Creates a Highlight layer from parsed Highlight layer data
  63245. * @param parsedHightlightLayer defines the Highlight layer data
  63246. * @param scene defines the current scene
  63247. * @param rootUrl defines the root URL containing the Highlight layer information
  63248. * @returns a parsed Highlight layer
  63249. */
  63250. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63251. }
  63252. }
  63253. declare module BABYLON {
  63254. interface AbstractScene {
  63255. /**
  63256. * The list of layers (background and foreground) of the scene
  63257. */
  63258. layers: Array<Layer>;
  63259. }
  63260. /**
  63261. * Defines the layer scene component responsible to manage any layers
  63262. * in a given scene.
  63263. */
  63264. export class LayerSceneComponent implements ISceneComponent {
  63265. /**
  63266. * The component name helpfull to identify the component in the list of scene components.
  63267. */
  63268. readonly name: string;
  63269. /**
  63270. * The scene the component belongs to.
  63271. */
  63272. scene: Scene;
  63273. private _engine;
  63274. /**
  63275. * Creates a new instance of the component for the given scene
  63276. * @param scene Defines the scene to register the component in
  63277. */
  63278. constructor(scene: Scene);
  63279. /**
  63280. * Registers the component in a given scene
  63281. */
  63282. register(): void;
  63283. /**
  63284. * Rebuilds the elements related to this component in case of
  63285. * context lost for instance.
  63286. */
  63287. rebuild(): void;
  63288. /**
  63289. * Disposes the component and the associated ressources.
  63290. */
  63291. dispose(): void;
  63292. private _draw;
  63293. private _drawCameraPredicate;
  63294. private _drawCameraBackground;
  63295. private _drawCameraForeground;
  63296. private _drawRenderTargetPredicate;
  63297. private _drawRenderTargetBackground;
  63298. private _drawRenderTargetForeground;
  63299. /**
  63300. * Adds all the elements from the container to the scene
  63301. * @param container the container holding the elements
  63302. */
  63303. addFromContainer(container: AbstractScene): void;
  63304. /**
  63305. * Removes all the elements in the container from the scene
  63306. * @param container contains the elements to remove
  63307. * @param dispose if the removed element should be disposed (default: false)
  63308. */
  63309. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63310. }
  63311. }
  63312. declare module BABYLON {
  63313. /** @hidden */
  63314. export var layerPixelShader: {
  63315. name: string;
  63316. shader: string;
  63317. };
  63318. }
  63319. declare module BABYLON {
  63320. /** @hidden */
  63321. export var layerVertexShader: {
  63322. name: string;
  63323. shader: string;
  63324. };
  63325. }
  63326. declare module BABYLON {
  63327. /**
  63328. * This represents a full screen 2d layer.
  63329. * This can be useful to display a picture in the background of your scene for instance.
  63330. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63331. */
  63332. export class Layer {
  63333. /**
  63334. * Define the name of the layer.
  63335. */
  63336. name: string;
  63337. /**
  63338. * Define the texture the layer should display.
  63339. */
  63340. texture: Nullable<Texture>;
  63341. /**
  63342. * Is the layer in background or foreground.
  63343. */
  63344. isBackground: boolean;
  63345. /**
  63346. * Define the color of the layer (instead of texture).
  63347. */
  63348. color: Color4;
  63349. /**
  63350. * Define the scale of the layer in order to zoom in out of the texture.
  63351. */
  63352. scale: Vector2;
  63353. /**
  63354. * Define an offset for the layer in order to shift the texture.
  63355. */
  63356. offset: Vector2;
  63357. /**
  63358. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63359. */
  63360. alphaBlendingMode: number;
  63361. /**
  63362. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63363. * Alpha test will not mix with the background color in case of transparency.
  63364. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63365. */
  63366. alphaTest: boolean;
  63367. /**
  63368. * Define a mask to restrict the layer to only some of the scene cameras.
  63369. */
  63370. layerMask: number;
  63371. /**
  63372. * Define the list of render target the layer is visible into.
  63373. */
  63374. renderTargetTextures: RenderTargetTexture[];
  63375. /**
  63376. * Define if the layer is only used in renderTarget or if it also
  63377. * renders in the main frame buffer of the canvas.
  63378. */
  63379. renderOnlyInRenderTargetTextures: boolean;
  63380. private _scene;
  63381. private _vertexBuffers;
  63382. private _indexBuffer;
  63383. private _effect;
  63384. private _previousDefines;
  63385. /**
  63386. * An event triggered when the layer is disposed.
  63387. */
  63388. onDisposeObservable: Observable<Layer>;
  63389. private _onDisposeObserver;
  63390. /**
  63391. * Back compatibility with callback before the onDisposeObservable existed.
  63392. * The set callback will be triggered when the layer has been disposed.
  63393. */
  63394. set onDispose(callback: () => void);
  63395. /**
  63396. * An event triggered before rendering the scene
  63397. */
  63398. onBeforeRenderObservable: Observable<Layer>;
  63399. private _onBeforeRenderObserver;
  63400. /**
  63401. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63402. * The set callback will be triggered just before rendering the layer.
  63403. */
  63404. set onBeforeRender(callback: () => void);
  63405. /**
  63406. * An event triggered after rendering the scene
  63407. */
  63408. onAfterRenderObservable: Observable<Layer>;
  63409. private _onAfterRenderObserver;
  63410. /**
  63411. * Back compatibility with callback before the onAfterRenderObservable existed.
  63412. * The set callback will be triggered just after rendering the layer.
  63413. */
  63414. set onAfterRender(callback: () => void);
  63415. /**
  63416. * Instantiates a new layer.
  63417. * This represents a full screen 2d layer.
  63418. * This can be useful to display a picture in the background of your scene for instance.
  63419. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63420. * @param name Define the name of the layer in the scene
  63421. * @param imgUrl Define the url of the texture to display in the layer
  63422. * @param scene Define the scene the layer belongs to
  63423. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63424. * @param color Defines a color for the layer
  63425. */
  63426. constructor(
  63427. /**
  63428. * Define the name of the layer.
  63429. */
  63430. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63431. private _createIndexBuffer;
  63432. /** @hidden */
  63433. _rebuild(): void;
  63434. /**
  63435. * Renders the layer in the scene.
  63436. */
  63437. render(): void;
  63438. /**
  63439. * Disposes and releases the associated ressources.
  63440. */
  63441. dispose(): void;
  63442. }
  63443. }
  63444. declare module BABYLON {
  63445. /** @hidden */
  63446. export var lensFlarePixelShader: {
  63447. name: string;
  63448. shader: string;
  63449. };
  63450. }
  63451. declare module BABYLON {
  63452. /** @hidden */
  63453. export var lensFlareVertexShader: {
  63454. name: string;
  63455. shader: string;
  63456. };
  63457. }
  63458. declare module BABYLON {
  63459. /**
  63460. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63461. * It is usually composed of several `lensFlare`.
  63462. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63463. */
  63464. export class LensFlareSystem {
  63465. /**
  63466. * Define the name of the lens flare system
  63467. */
  63468. name: string;
  63469. /**
  63470. * List of lens flares used in this system.
  63471. */
  63472. lensFlares: LensFlare[];
  63473. /**
  63474. * Define a limit from the border the lens flare can be visible.
  63475. */
  63476. borderLimit: number;
  63477. /**
  63478. * Define a viewport border we do not want to see the lens flare in.
  63479. */
  63480. viewportBorder: number;
  63481. /**
  63482. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63483. */
  63484. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63485. /**
  63486. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63487. */
  63488. layerMask: number;
  63489. /**
  63490. * Define the id of the lens flare system in the scene.
  63491. * (equal to name by default)
  63492. */
  63493. id: string;
  63494. private _scene;
  63495. private _emitter;
  63496. private _vertexBuffers;
  63497. private _indexBuffer;
  63498. private _effect;
  63499. private _positionX;
  63500. private _positionY;
  63501. private _isEnabled;
  63502. /** @hidden */
  63503. static _SceneComponentInitialization: (scene: Scene) => void;
  63504. /**
  63505. * Instantiates a lens flare system.
  63506. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63507. * It is usually composed of several `lensFlare`.
  63508. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63509. * @param name Define the name of the lens flare system in the scene
  63510. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63511. * @param scene Define the scene the lens flare system belongs to
  63512. */
  63513. constructor(
  63514. /**
  63515. * Define the name of the lens flare system
  63516. */
  63517. name: string, emitter: any, scene: Scene);
  63518. /**
  63519. * Define if the lens flare system is enabled.
  63520. */
  63521. get isEnabled(): boolean;
  63522. set isEnabled(value: boolean);
  63523. /**
  63524. * Get the scene the effects belongs to.
  63525. * @returns the scene holding the lens flare system
  63526. */
  63527. getScene(): Scene;
  63528. /**
  63529. * Get the emitter of the lens flare system.
  63530. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63531. * @returns the emitter of the lens flare system
  63532. */
  63533. getEmitter(): any;
  63534. /**
  63535. * Set the emitter of the lens flare system.
  63536. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63537. * @param newEmitter Define the new emitter of the system
  63538. */
  63539. setEmitter(newEmitter: any): void;
  63540. /**
  63541. * Get the lens flare system emitter position.
  63542. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63543. * @returns the position
  63544. */
  63545. getEmitterPosition(): Vector3;
  63546. /**
  63547. * @hidden
  63548. */
  63549. computeEffectivePosition(globalViewport: Viewport): boolean;
  63550. /** @hidden */
  63551. _isVisible(): boolean;
  63552. /**
  63553. * @hidden
  63554. */
  63555. render(): boolean;
  63556. /**
  63557. * Dispose and release the lens flare with its associated resources.
  63558. */
  63559. dispose(): void;
  63560. /**
  63561. * Parse a lens flare system from a JSON repressentation
  63562. * @param parsedLensFlareSystem Define the JSON to parse
  63563. * @param scene Define the scene the parsed system should be instantiated in
  63564. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63565. * @returns the parsed system
  63566. */
  63567. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63568. /**
  63569. * Serialize the current Lens Flare System into a JSON representation.
  63570. * @returns the serialized JSON
  63571. */
  63572. serialize(): any;
  63573. }
  63574. }
  63575. declare module BABYLON {
  63576. /**
  63577. * This represents one of the lens effect in a `lensFlareSystem`.
  63578. * It controls one of the indiviual texture used in the effect.
  63579. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63580. */
  63581. export class LensFlare {
  63582. /**
  63583. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63584. */
  63585. size: number;
  63586. /**
  63587. * 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.
  63588. */
  63589. position: number;
  63590. /**
  63591. * Define the lens color.
  63592. */
  63593. color: Color3;
  63594. /**
  63595. * Define the lens texture.
  63596. */
  63597. texture: Nullable<Texture>;
  63598. /**
  63599. * Define the alpha mode to render this particular lens.
  63600. */
  63601. alphaMode: number;
  63602. private _system;
  63603. /**
  63604. * Creates a new Lens Flare.
  63605. * This represents one of the lens effect in a `lensFlareSystem`.
  63606. * It controls one of the indiviual texture used in the effect.
  63607. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63608. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63609. * @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.
  63610. * @param color Define the lens color
  63611. * @param imgUrl Define the lens texture url
  63612. * @param system Define the `lensFlareSystem` this flare is part of
  63613. * @returns The newly created Lens Flare
  63614. */
  63615. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63616. /**
  63617. * Instantiates a new Lens Flare.
  63618. * This represents one of the lens effect in a `lensFlareSystem`.
  63619. * It controls one of the indiviual texture used in the effect.
  63620. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63621. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63622. * @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.
  63623. * @param color Define the lens color
  63624. * @param imgUrl Define the lens texture url
  63625. * @param system Define the `lensFlareSystem` this flare is part of
  63626. */
  63627. constructor(
  63628. /**
  63629. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63630. */
  63631. size: number,
  63632. /**
  63633. * 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.
  63634. */
  63635. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63636. /**
  63637. * Dispose and release the lens flare with its associated resources.
  63638. */
  63639. dispose(): void;
  63640. }
  63641. }
  63642. declare module BABYLON {
  63643. interface AbstractScene {
  63644. /**
  63645. * The list of lens flare system added to the scene
  63646. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63647. */
  63648. lensFlareSystems: Array<LensFlareSystem>;
  63649. /**
  63650. * Removes the given lens flare system from this scene.
  63651. * @param toRemove The lens flare system to remove
  63652. * @returns The index of the removed lens flare system
  63653. */
  63654. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63655. /**
  63656. * Adds the given lens flare system to this scene
  63657. * @param newLensFlareSystem The lens flare system to add
  63658. */
  63659. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63660. /**
  63661. * Gets a lens flare system using its name
  63662. * @param name defines the name to look for
  63663. * @returns the lens flare system or null if not found
  63664. */
  63665. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63666. /**
  63667. * Gets a lens flare system using its id
  63668. * @param id defines the id to look for
  63669. * @returns the lens flare system or null if not found
  63670. */
  63671. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63672. }
  63673. /**
  63674. * Defines the lens flare scene component responsible to manage any lens flares
  63675. * in a given scene.
  63676. */
  63677. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63678. /**
  63679. * The component name helpfull to identify the component in the list of scene components.
  63680. */
  63681. readonly name: string;
  63682. /**
  63683. * The scene the component belongs to.
  63684. */
  63685. scene: Scene;
  63686. /**
  63687. * Creates a new instance of the component for the given scene
  63688. * @param scene Defines the scene to register the component in
  63689. */
  63690. constructor(scene: Scene);
  63691. /**
  63692. * Registers the component in a given scene
  63693. */
  63694. register(): void;
  63695. /**
  63696. * Rebuilds the elements related to this component in case of
  63697. * context lost for instance.
  63698. */
  63699. rebuild(): void;
  63700. /**
  63701. * Adds all the elements from the container to the scene
  63702. * @param container the container holding the elements
  63703. */
  63704. addFromContainer(container: AbstractScene): void;
  63705. /**
  63706. * Removes all the elements in the container from the scene
  63707. * @param container contains the elements to remove
  63708. * @param dispose if the removed element should be disposed (default: false)
  63709. */
  63710. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63711. /**
  63712. * Serializes the component data to the specified json object
  63713. * @param serializationObject The object to serialize to
  63714. */
  63715. serialize(serializationObject: any): void;
  63716. /**
  63717. * Disposes the component and the associated ressources.
  63718. */
  63719. dispose(): void;
  63720. private _draw;
  63721. }
  63722. }
  63723. declare module BABYLON {
  63724. /** @hidden */
  63725. export var depthPixelShader: {
  63726. name: string;
  63727. shader: string;
  63728. };
  63729. }
  63730. declare module BABYLON {
  63731. /** @hidden */
  63732. export var depthVertexShader: {
  63733. name: string;
  63734. shader: string;
  63735. };
  63736. }
  63737. declare module BABYLON {
  63738. /**
  63739. * This represents a depth renderer in Babylon.
  63740. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63741. */
  63742. export class DepthRenderer {
  63743. private _scene;
  63744. private _depthMap;
  63745. private _effect;
  63746. private readonly _storeNonLinearDepth;
  63747. private readonly _clearColor;
  63748. /** Get if the depth renderer is using packed depth or not */
  63749. readonly isPacked: boolean;
  63750. private _cachedDefines;
  63751. private _camera;
  63752. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63753. enabled: boolean;
  63754. /**
  63755. * Specifiess that the depth renderer will only be used within
  63756. * the camera it is created for.
  63757. * This can help forcing its rendering during the camera processing.
  63758. */
  63759. useOnlyInActiveCamera: boolean;
  63760. /** @hidden */
  63761. static _SceneComponentInitialization: (scene: Scene) => void;
  63762. /**
  63763. * Instantiates a depth renderer
  63764. * @param scene The scene the renderer belongs to
  63765. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63766. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63767. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63768. */
  63769. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63770. /**
  63771. * Creates the depth rendering effect and checks if the effect is ready.
  63772. * @param subMesh The submesh to be used to render the depth map of
  63773. * @param useInstances If multiple world instances should be used
  63774. * @returns if the depth renderer is ready to render the depth map
  63775. */
  63776. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63777. /**
  63778. * Gets the texture which the depth map will be written to.
  63779. * @returns The depth map texture
  63780. */
  63781. getDepthMap(): RenderTargetTexture;
  63782. /**
  63783. * Disposes of the depth renderer.
  63784. */
  63785. dispose(): void;
  63786. }
  63787. }
  63788. declare module BABYLON {
  63789. /** @hidden */
  63790. export var minmaxReduxPixelShader: {
  63791. name: string;
  63792. shader: string;
  63793. };
  63794. }
  63795. declare module BABYLON {
  63796. /**
  63797. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63798. * and maximum values from all values of the texture.
  63799. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63800. * The source values are read from the red channel of the texture.
  63801. */
  63802. export class MinMaxReducer {
  63803. /**
  63804. * Observable triggered when the computation has been performed
  63805. */
  63806. onAfterReductionPerformed: Observable<{
  63807. min: number;
  63808. max: number;
  63809. }>;
  63810. protected _camera: Camera;
  63811. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63812. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63813. protected _postProcessManager: PostProcessManager;
  63814. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63815. protected _forceFullscreenViewport: boolean;
  63816. /**
  63817. * Creates a min/max reducer
  63818. * @param camera The camera to use for the post processes
  63819. */
  63820. constructor(camera: Camera);
  63821. /**
  63822. * Gets the texture used to read the values from.
  63823. */
  63824. get sourceTexture(): Nullable<RenderTargetTexture>;
  63825. /**
  63826. * Sets the source texture to read the values from.
  63827. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63828. * because in such textures '1' value must not be taken into account to compute the maximum
  63829. * as this value is used to clear the texture.
  63830. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63831. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63832. * @param depthRedux Indicates if the texture is a depth texture or not
  63833. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63834. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63835. */
  63836. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63837. /**
  63838. * Defines the refresh rate of the computation.
  63839. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63840. */
  63841. get refreshRate(): number;
  63842. set refreshRate(value: number);
  63843. protected _activated: boolean;
  63844. /**
  63845. * Gets the activation status of the reducer
  63846. */
  63847. get activated(): boolean;
  63848. /**
  63849. * Activates the reduction computation.
  63850. * When activated, the observers registered in onAfterReductionPerformed are
  63851. * called after the compuation is performed
  63852. */
  63853. activate(): void;
  63854. /**
  63855. * Deactivates the reduction computation.
  63856. */
  63857. deactivate(): void;
  63858. /**
  63859. * Disposes the min/max reducer
  63860. * @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.
  63861. */
  63862. dispose(disposeAll?: boolean): void;
  63863. }
  63864. }
  63865. declare module BABYLON {
  63866. /**
  63867. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63868. */
  63869. export class DepthReducer extends MinMaxReducer {
  63870. private _depthRenderer;
  63871. private _depthRendererId;
  63872. /**
  63873. * Gets the depth renderer used for the computation.
  63874. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63875. */
  63876. get depthRenderer(): Nullable<DepthRenderer>;
  63877. /**
  63878. * Creates a depth reducer
  63879. * @param camera The camera used to render the depth texture
  63880. */
  63881. constructor(camera: Camera);
  63882. /**
  63883. * Sets the depth renderer to use to generate the depth map
  63884. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63885. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63886. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63887. */
  63888. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63889. /** @hidden */
  63890. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63891. /**
  63892. * Activates the reduction computation.
  63893. * When activated, the observers registered in onAfterReductionPerformed are
  63894. * called after the compuation is performed
  63895. */
  63896. activate(): void;
  63897. /**
  63898. * Deactivates the reduction computation.
  63899. */
  63900. deactivate(): void;
  63901. /**
  63902. * Disposes the depth reducer
  63903. * @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.
  63904. */
  63905. dispose(disposeAll?: boolean): void;
  63906. }
  63907. }
  63908. declare module BABYLON {
  63909. /**
  63910. * A CSM implementation allowing casting shadows on large scenes.
  63911. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63912. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63913. */
  63914. export class CascadedShadowGenerator extends ShadowGenerator {
  63915. private static readonly frustumCornersNDCSpace;
  63916. /**
  63917. * Name of the CSM class
  63918. */
  63919. static CLASSNAME: string;
  63920. /**
  63921. * Defines the default number of cascades used by the CSM.
  63922. */
  63923. static readonly DEFAULT_CASCADES_COUNT: number;
  63924. /**
  63925. * Defines the minimum number of cascades used by the CSM.
  63926. */
  63927. static readonly MIN_CASCADES_COUNT: number;
  63928. /**
  63929. * Defines the maximum number of cascades used by the CSM.
  63930. */
  63931. static readonly MAX_CASCADES_COUNT: number;
  63932. protected _validateFilter(filter: number): number;
  63933. /**
  63934. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63935. */
  63936. penumbraDarkness: number;
  63937. private _numCascades;
  63938. /**
  63939. * Gets or set the number of cascades used by the CSM.
  63940. */
  63941. get numCascades(): number;
  63942. set numCascades(value: number);
  63943. /**
  63944. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63945. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63946. */
  63947. stabilizeCascades: boolean;
  63948. private _freezeShadowCastersBoundingInfo;
  63949. private _freezeShadowCastersBoundingInfoObservable;
  63950. /**
  63951. * Enables or disables the shadow casters bounding info computation.
  63952. * If your shadow casters don't move, you can disable this feature.
  63953. * If it is enabled, the bounding box computation is done every frame.
  63954. */
  63955. get freezeShadowCastersBoundingInfo(): boolean;
  63956. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63957. private _scbiMin;
  63958. private _scbiMax;
  63959. protected _computeShadowCastersBoundingInfo(): void;
  63960. protected _shadowCastersBoundingInfo: BoundingInfo;
  63961. /**
  63962. * Gets or sets the shadow casters bounding info.
  63963. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63964. * so that the system won't overwrite the bounds you provide
  63965. */
  63966. get shadowCastersBoundingInfo(): BoundingInfo;
  63967. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63968. protected _breaksAreDirty: boolean;
  63969. protected _minDistance: number;
  63970. protected _maxDistance: number;
  63971. /**
  63972. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63973. *
  63974. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63975. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63976. * @param min minimal distance for the breaks (default to 0.)
  63977. * @param max maximal distance for the breaks (default to 1.)
  63978. */
  63979. setMinMaxDistance(min: number, max: number): void;
  63980. /** Gets the minimal distance used in the cascade break computation */
  63981. get minDistance(): number;
  63982. /** Gets the maximal distance used in the cascade break computation */
  63983. get maxDistance(): number;
  63984. /**
  63985. * Gets the class name of that object
  63986. * @returns "CascadedShadowGenerator"
  63987. */
  63988. getClassName(): string;
  63989. private _cascadeMinExtents;
  63990. private _cascadeMaxExtents;
  63991. /**
  63992. * Gets a cascade minimum extents
  63993. * @param cascadeIndex index of the cascade
  63994. * @returns the minimum cascade extents
  63995. */
  63996. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63997. /**
  63998. * Gets a cascade maximum extents
  63999. * @param cascadeIndex index of the cascade
  64000. * @returns the maximum cascade extents
  64001. */
  64002. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64003. private _cascades;
  64004. private _currentLayer;
  64005. private _viewSpaceFrustumsZ;
  64006. private _viewMatrices;
  64007. private _projectionMatrices;
  64008. private _transformMatrices;
  64009. private _transformMatricesAsArray;
  64010. private _frustumLengths;
  64011. private _lightSizeUVCorrection;
  64012. private _depthCorrection;
  64013. private _frustumCornersWorldSpace;
  64014. private _frustumCenter;
  64015. private _shadowCameraPos;
  64016. private _shadowMaxZ;
  64017. /**
  64018. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64019. * It defaults to camera.maxZ
  64020. */
  64021. get shadowMaxZ(): number;
  64022. /**
  64023. * Sets the shadow max z distance.
  64024. */
  64025. set shadowMaxZ(value: number);
  64026. protected _debug: boolean;
  64027. /**
  64028. * Gets or sets the debug flag.
  64029. * When enabled, the cascades are materialized by different colors on the screen.
  64030. */
  64031. get debug(): boolean;
  64032. set debug(dbg: boolean);
  64033. private _depthClamp;
  64034. /**
  64035. * Gets or sets the depth clamping value.
  64036. *
  64037. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64038. * to account for the shadow casters far away.
  64039. *
  64040. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64041. */
  64042. get depthClamp(): boolean;
  64043. set depthClamp(value: boolean);
  64044. private _cascadeBlendPercentage;
  64045. /**
  64046. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64047. * It defaults to 0.1 (10% blending).
  64048. */
  64049. get cascadeBlendPercentage(): number;
  64050. set cascadeBlendPercentage(value: number);
  64051. private _lambda;
  64052. /**
  64053. * Gets or set the lambda parameter.
  64054. * This parameter is used to split the camera frustum and create the cascades.
  64055. * 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.
  64056. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64057. */
  64058. get lambda(): number;
  64059. set lambda(value: number);
  64060. /**
  64061. * Gets the view matrix corresponding to a given cascade
  64062. * @param cascadeNum cascade to retrieve the view matrix from
  64063. * @returns the cascade view matrix
  64064. */
  64065. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64066. /**
  64067. * Gets the projection matrix corresponding to a given cascade
  64068. * @param cascadeNum cascade to retrieve the projection matrix from
  64069. * @returns the cascade projection matrix
  64070. */
  64071. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64072. /**
  64073. * Gets the transformation matrix corresponding to a given cascade
  64074. * @param cascadeNum cascade to retrieve the transformation matrix from
  64075. * @returns the cascade transformation matrix
  64076. */
  64077. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64078. private _depthRenderer;
  64079. /**
  64080. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64081. *
  64082. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64083. *
  64084. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64085. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64086. * @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
  64087. */
  64088. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64089. private _depthReducer;
  64090. private _autoCalcDepthBounds;
  64091. /**
  64092. * Gets or sets the autoCalcDepthBounds property.
  64093. *
  64094. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64095. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64096. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64097. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64098. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64099. */
  64100. get autoCalcDepthBounds(): boolean;
  64101. set autoCalcDepthBounds(value: boolean);
  64102. /**
  64103. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64104. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64105. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64106. * for setting the refresh rate on the renderer yourself!
  64107. */
  64108. get autoCalcDepthBoundsRefreshRate(): number;
  64109. set autoCalcDepthBoundsRefreshRate(value: number);
  64110. /**
  64111. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64112. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64113. * you change the camera near/far planes!
  64114. */
  64115. splitFrustum(): void;
  64116. private _splitFrustum;
  64117. private _computeMatrices;
  64118. private _computeFrustumInWorldSpace;
  64119. private _computeCascadeFrustum;
  64120. /**
  64121. * Support test.
  64122. */
  64123. static get IsSupported(): boolean;
  64124. /** @hidden */
  64125. static _SceneComponentInitialization: (scene: Scene) => void;
  64126. /**
  64127. * Creates a Cascaded Shadow Generator object.
  64128. * A ShadowGenerator is the required tool to use the shadows.
  64129. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64130. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64131. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64132. * @param light The directional light object generating the shadows.
  64133. * @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.
  64134. */
  64135. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64136. protected _initializeGenerator(): void;
  64137. protected _createTargetRenderTexture(): void;
  64138. protected _initializeShadowMap(): void;
  64139. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64140. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64141. /**
  64142. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64143. * @param defines Defines of the material we want to update
  64144. * @param lightIndex Index of the light in the enabled light list of the material
  64145. */
  64146. prepareDefines(defines: any, lightIndex: number): void;
  64147. /**
  64148. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64149. * defined in the generator but impacting the effect).
  64150. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64151. * @param effect The effect we are binfing the information for
  64152. */
  64153. bindShadowLight(lightIndex: string, effect: Effect): void;
  64154. /**
  64155. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64156. * (eq to view projection * shadow projection matrices)
  64157. * @returns The transform matrix used to create the shadow map
  64158. */
  64159. getTransformMatrix(): Matrix;
  64160. /**
  64161. * Disposes the ShadowGenerator.
  64162. * Returns nothing.
  64163. */
  64164. dispose(): void;
  64165. /**
  64166. * Serializes the shadow generator setup to a json object.
  64167. * @returns The serialized JSON object
  64168. */
  64169. serialize(): any;
  64170. /**
  64171. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64172. * @param parsedShadowGenerator The JSON object to parse
  64173. * @param scene The scene to create the shadow map for
  64174. * @returns The parsed shadow generator
  64175. */
  64176. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64177. }
  64178. }
  64179. declare module BABYLON {
  64180. /**
  64181. * Defines the shadow generator component responsible to manage any shadow generators
  64182. * in a given scene.
  64183. */
  64184. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64185. /**
  64186. * The component name helpfull to identify the component in the list of scene components.
  64187. */
  64188. readonly name: string;
  64189. /**
  64190. * The scene the component belongs to.
  64191. */
  64192. scene: Scene;
  64193. /**
  64194. * Creates a new instance of the component for the given scene
  64195. * @param scene Defines the scene to register the component in
  64196. */
  64197. constructor(scene: Scene);
  64198. /**
  64199. * Registers the component in a given scene
  64200. */
  64201. register(): void;
  64202. /**
  64203. * Rebuilds the elements related to this component in case of
  64204. * context lost for instance.
  64205. */
  64206. rebuild(): void;
  64207. /**
  64208. * Serializes the component data to the specified json object
  64209. * @param serializationObject The object to serialize to
  64210. */
  64211. serialize(serializationObject: any): void;
  64212. /**
  64213. * Adds all the elements from the container to the scene
  64214. * @param container the container holding the elements
  64215. */
  64216. addFromContainer(container: AbstractScene): void;
  64217. /**
  64218. * Removes all the elements in the container from the scene
  64219. * @param container contains the elements to remove
  64220. * @param dispose if the removed element should be disposed (default: false)
  64221. */
  64222. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64223. /**
  64224. * Rebuilds the elements related to this component in case of
  64225. * context lost for instance.
  64226. */
  64227. dispose(): void;
  64228. private _gatherRenderTargets;
  64229. }
  64230. }
  64231. declare module BABYLON {
  64232. /**
  64233. * A point light is a light defined by an unique point in world space.
  64234. * The light is emitted in every direction from this point.
  64235. * A good example of a point light is a standard light bulb.
  64236. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64237. */
  64238. export class PointLight extends ShadowLight {
  64239. private _shadowAngle;
  64240. /**
  64241. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64242. * This specifies what angle the shadow will use to be created.
  64243. *
  64244. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64245. */
  64246. get shadowAngle(): number;
  64247. /**
  64248. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64249. * This specifies what angle the shadow will use to be created.
  64250. *
  64251. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64252. */
  64253. set shadowAngle(value: number);
  64254. /**
  64255. * Gets the direction if it has been set.
  64256. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64257. */
  64258. get direction(): Vector3;
  64259. /**
  64260. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64261. */
  64262. set direction(value: Vector3);
  64263. /**
  64264. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64265. * A PointLight emits the light in every direction.
  64266. * It can cast shadows.
  64267. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64268. * ```javascript
  64269. * var pointLight = new PointLight("pl", camera.position, scene);
  64270. * ```
  64271. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64272. * @param name The light friendly name
  64273. * @param position The position of the point light in the scene
  64274. * @param scene The scene the lights belongs to
  64275. */
  64276. constructor(name: string, position: Vector3, scene: Scene);
  64277. /**
  64278. * Returns the string "PointLight"
  64279. * @returns the class name
  64280. */
  64281. getClassName(): string;
  64282. /**
  64283. * Returns the integer 0.
  64284. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64285. */
  64286. getTypeID(): number;
  64287. /**
  64288. * Specifies wether or not the shadowmap should be a cube texture.
  64289. * @returns true if the shadowmap needs to be a cube texture.
  64290. */
  64291. needCube(): boolean;
  64292. /**
  64293. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64294. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64295. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64296. */
  64297. getShadowDirection(faceIndex?: number): Vector3;
  64298. /**
  64299. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64300. * - fov = PI / 2
  64301. * - aspect ratio : 1.0
  64302. * - z-near and far equal to the active camera minZ and maxZ.
  64303. * Returns the PointLight.
  64304. */
  64305. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64306. protected _buildUniformLayout(): void;
  64307. /**
  64308. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64309. * @param effect The effect to update
  64310. * @param lightIndex The index of the light in the effect to update
  64311. * @returns The point light
  64312. */
  64313. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64314. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64315. /**
  64316. * Prepares the list of defines specific to the light type.
  64317. * @param defines the list of defines
  64318. * @param lightIndex defines the index of the light for the effect
  64319. */
  64320. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64321. }
  64322. }
  64323. declare module BABYLON {
  64324. /**
  64325. * Header information of HDR texture files.
  64326. */
  64327. export interface HDRInfo {
  64328. /**
  64329. * The height of the texture in pixels.
  64330. */
  64331. height: number;
  64332. /**
  64333. * The width of the texture in pixels.
  64334. */
  64335. width: number;
  64336. /**
  64337. * The index of the beginning of the data in the binary file.
  64338. */
  64339. dataPosition: number;
  64340. }
  64341. /**
  64342. * This groups tools to convert HDR texture to native colors array.
  64343. */
  64344. export class HDRTools {
  64345. private static Ldexp;
  64346. private static Rgbe2float;
  64347. private static readStringLine;
  64348. /**
  64349. * Reads header information from an RGBE texture stored in a native array.
  64350. * More information on this format are available here:
  64351. * https://en.wikipedia.org/wiki/RGBE_image_format
  64352. *
  64353. * @param uint8array The binary file stored in native array.
  64354. * @return The header information.
  64355. */
  64356. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64357. /**
  64358. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64359. * This RGBE texture needs to store the information as a panorama.
  64360. *
  64361. * More information on this format are available here:
  64362. * https://en.wikipedia.org/wiki/RGBE_image_format
  64363. *
  64364. * @param buffer The binary file stored in an array buffer.
  64365. * @param size The expected size of the extracted cubemap.
  64366. * @return The Cube Map information.
  64367. */
  64368. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64369. /**
  64370. * Returns the pixels data extracted from an RGBE texture.
  64371. * This pixels will be stored left to right up to down in the R G B order in one array.
  64372. *
  64373. * More information on this format are available here:
  64374. * https://en.wikipedia.org/wiki/RGBE_image_format
  64375. *
  64376. * @param uint8array The binary file stored in an array buffer.
  64377. * @param hdrInfo The header information of the file.
  64378. * @return The pixels data in RGB right to left up to down order.
  64379. */
  64380. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64381. private static RGBE_ReadPixels_RLE;
  64382. private static RGBE_ReadPixels_NOT_RLE;
  64383. }
  64384. }
  64385. declare module BABYLON {
  64386. /**
  64387. * Effect Render Options
  64388. */
  64389. export interface IEffectRendererOptions {
  64390. /**
  64391. * Defines the vertices positions.
  64392. */
  64393. positions?: number[];
  64394. /**
  64395. * Defines the indices.
  64396. */
  64397. indices?: number[];
  64398. }
  64399. /**
  64400. * Helper class to render one or more effects.
  64401. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64402. */
  64403. export class EffectRenderer {
  64404. private engine;
  64405. private static _DefaultOptions;
  64406. private _vertexBuffers;
  64407. private _indexBuffer;
  64408. private _fullscreenViewport;
  64409. /**
  64410. * Creates an effect renderer
  64411. * @param engine the engine to use for rendering
  64412. * @param options defines the options of the effect renderer
  64413. */
  64414. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64415. /**
  64416. * Sets the current viewport in normalized coordinates 0-1
  64417. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64418. */
  64419. setViewport(viewport?: Viewport): void;
  64420. /**
  64421. * Binds the embedded attributes buffer to the effect.
  64422. * @param effect Defines the effect to bind the attributes for
  64423. */
  64424. bindBuffers(effect: Effect): void;
  64425. /**
  64426. * Sets the current effect wrapper to use during draw.
  64427. * The effect needs to be ready before calling this api.
  64428. * This also sets the default full screen position attribute.
  64429. * @param effectWrapper Defines the effect to draw with
  64430. */
  64431. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64432. /**
  64433. * Restores engine states
  64434. */
  64435. restoreStates(): void;
  64436. /**
  64437. * Draws a full screen quad.
  64438. */
  64439. draw(): void;
  64440. private isRenderTargetTexture;
  64441. /**
  64442. * renders one or more effects to a specified texture
  64443. * @param effectWrapper the effect to renderer
  64444. * @param outputTexture texture to draw to, if null it will render to the screen.
  64445. */
  64446. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64447. /**
  64448. * Disposes of the effect renderer
  64449. */
  64450. dispose(): void;
  64451. }
  64452. /**
  64453. * Options to create an EffectWrapper
  64454. */
  64455. interface EffectWrapperCreationOptions {
  64456. /**
  64457. * Engine to use to create the effect
  64458. */
  64459. engine: ThinEngine;
  64460. /**
  64461. * Fragment shader for the effect
  64462. */
  64463. fragmentShader: string;
  64464. /**
  64465. * Use the shader store instead of direct source code
  64466. */
  64467. useShaderStore?: boolean;
  64468. /**
  64469. * Vertex shader for the effect
  64470. */
  64471. vertexShader?: string;
  64472. /**
  64473. * Attributes to use in the shader
  64474. */
  64475. attributeNames?: Array<string>;
  64476. /**
  64477. * Uniforms to use in the shader
  64478. */
  64479. uniformNames?: Array<string>;
  64480. /**
  64481. * Texture sampler names to use in the shader
  64482. */
  64483. samplerNames?: Array<string>;
  64484. /**
  64485. * Defines to use in the shader
  64486. */
  64487. defines?: Array<string>;
  64488. /**
  64489. * Callback when effect is compiled
  64490. */
  64491. onCompiled?: Nullable<(effect: Effect) => void>;
  64492. /**
  64493. * The friendly name of the effect displayed in Spector.
  64494. */
  64495. name?: string;
  64496. }
  64497. /**
  64498. * Wraps an effect to be used for rendering
  64499. */
  64500. export class EffectWrapper {
  64501. /**
  64502. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64503. */
  64504. onApplyObservable: Observable<{}>;
  64505. /**
  64506. * The underlying effect
  64507. */
  64508. effect: Effect;
  64509. /**
  64510. * Creates an effect to be renderer
  64511. * @param creationOptions options to create the effect
  64512. */
  64513. constructor(creationOptions: EffectWrapperCreationOptions);
  64514. /**
  64515. * Disposes of the effect wrapper
  64516. */
  64517. dispose(): void;
  64518. }
  64519. }
  64520. declare module BABYLON {
  64521. /** @hidden */
  64522. export var hdrFilteringVertexShader: {
  64523. name: string;
  64524. shader: string;
  64525. };
  64526. }
  64527. declare module BABYLON {
  64528. /** @hidden */
  64529. export var hdrFilteringPixelShader: {
  64530. name: string;
  64531. shader: string;
  64532. };
  64533. }
  64534. declare module BABYLON {
  64535. /**
  64536. * Options for texture filtering
  64537. */
  64538. interface IHDRFilteringOptions {
  64539. /**
  64540. * Scales pixel intensity for the input HDR map.
  64541. */
  64542. hdrScale?: number;
  64543. /**
  64544. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64545. */
  64546. quality?: number;
  64547. }
  64548. /**
  64549. * Filters HDR maps to get correct renderings of PBR reflections
  64550. */
  64551. export class HDRFiltering {
  64552. private _engine;
  64553. private _effectRenderer;
  64554. private _effectWrapper;
  64555. private _lodGenerationOffset;
  64556. private _lodGenerationScale;
  64557. /**
  64558. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64559. * you care about baking speed.
  64560. */
  64561. quality: number;
  64562. /**
  64563. * Scales pixel intensity for the input HDR map.
  64564. */
  64565. hdrScale: number;
  64566. /**
  64567. * Instantiates HDR filter for reflection maps
  64568. *
  64569. * @param engine Thin engine
  64570. * @param options Options
  64571. */
  64572. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64573. private _createRenderTarget;
  64574. private _prefilterInternal;
  64575. private _createEffect;
  64576. /**
  64577. * Get a value indicating if the filter is ready to be used
  64578. * @param texture Texture to filter
  64579. * @returns true if the filter is ready
  64580. */
  64581. isReady(texture: BaseTexture): boolean;
  64582. /**
  64583. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64584. * Prefiltering will be invoked at the end of next rendering pass.
  64585. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64586. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64587. * @param texture Texture to filter
  64588. * @param onFinished Callback when filtering is done
  64589. * @return Promise called when prefiltering is done
  64590. */
  64591. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  64592. }
  64593. }
  64594. declare module BABYLON {
  64595. /**
  64596. * This represents a texture coming from an HDR input.
  64597. *
  64598. * The only supported format is currently panorama picture stored in RGBE format.
  64599. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64600. */
  64601. export class HDRCubeTexture extends BaseTexture {
  64602. private static _facesMapping;
  64603. private _generateHarmonics;
  64604. private _noMipmap;
  64605. private _prefilterOnLoad;
  64606. private _textureMatrix;
  64607. private _size;
  64608. private _onLoad;
  64609. private _onError;
  64610. /**
  64611. * The texture URL.
  64612. */
  64613. url: string;
  64614. protected _isBlocking: boolean;
  64615. /**
  64616. * Sets wether or not the texture is blocking during loading.
  64617. */
  64618. set isBlocking(value: boolean);
  64619. /**
  64620. * Gets wether or not the texture is blocking during loading.
  64621. */
  64622. get isBlocking(): boolean;
  64623. protected _rotationY: number;
  64624. /**
  64625. * Sets texture matrix rotation angle around Y axis in radians.
  64626. */
  64627. set rotationY(value: number);
  64628. /**
  64629. * Gets texture matrix rotation angle around Y axis radians.
  64630. */
  64631. get rotationY(): number;
  64632. /**
  64633. * Gets or sets the center of the bounding box associated with the cube texture
  64634. * It must define where the camera used to render the texture was set
  64635. */
  64636. boundingBoxPosition: Vector3;
  64637. private _boundingBoxSize;
  64638. /**
  64639. * Gets or sets the size of the bounding box associated with the cube texture
  64640. * When defined, the cubemap will switch to local mode
  64641. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64642. * @example https://www.babylonjs-playground.com/#RNASML
  64643. */
  64644. set boundingBoxSize(value: Vector3);
  64645. get boundingBoxSize(): Vector3;
  64646. /**
  64647. * Instantiates an HDRTexture from the following parameters.
  64648. *
  64649. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64650. * @param sceneOrEngine The scene or engine the texture will be used in
  64651. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64652. * @param noMipmap Forces to not generate the mipmap if true
  64653. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64654. * @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)
  64655. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64656. */
  64657. 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>);
  64658. /**
  64659. * Get the current class name of the texture useful for serialization or dynamic coding.
  64660. * @returns "HDRCubeTexture"
  64661. */
  64662. getClassName(): string;
  64663. /**
  64664. * Occurs when the file is raw .hdr file.
  64665. */
  64666. private loadTexture;
  64667. clone(): HDRCubeTexture;
  64668. delayLoad(): void;
  64669. /**
  64670. * Get the texture reflection matrix used to rotate/transform the reflection.
  64671. * @returns the reflection matrix
  64672. */
  64673. getReflectionTextureMatrix(): Matrix;
  64674. /**
  64675. * Set the texture reflection matrix used to rotate/transform the reflection.
  64676. * @param value Define the reflection matrix to set
  64677. */
  64678. setReflectionTextureMatrix(value: Matrix): void;
  64679. /**
  64680. * Parses a JSON representation of an HDR Texture in order to create the texture
  64681. * @param parsedTexture Define the JSON representation
  64682. * @param scene Define the scene the texture should be created in
  64683. * @param rootUrl Define the root url in case we need to load relative dependencies
  64684. * @returns the newly created texture after parsing
  64685. */
  64686. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64687. serialize(): any;
  64688. }
  64689. }
  64690. declare module BABYLON {
  64691. /**
  64692. * Class used to control physics engine
  64693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64694. */
  64695. export class PhysicsEngine implements IPhysicsEngine {
  64696. private _physicsPlugin;
  64697. /**
  64698. * Global value used to control the smallest number supported by the simulation
  64699. */
  64700. static Epsilon: number;
  64701. private _impostors;
  64702. private _joints;
  64703. private _subTimeStep;
  64704. /**
  64705. * Gets the gravity vector used by the simulation
  64706. */
  64707. gravity: Vector3;
  64708. /**
  64709. * Factory used to create the default physics plugin.
  64710. * @returns The default physics plugin
  64711. */
  64712. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64713. /**
  64714. * Creates a new Physics Engine
  64715. * @param gravity defines the gravity vector used by the simulation
  64716. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64717. */
  64718. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64719. /**
  64720. * Sets the gravity vector used by the simulation
  64721. * @param gravity defines the gravity vector to use
  64722. */
  64723. setGravity(gravity: Vector3): void;
  64724. /**
  64725. * Set the time step of the physics engine.
  64726. * Default is 1/60.
  64727. * To slow it down, enter 1/600 for example.
  64728. * To speed it up, 1/30
  64729. * @param newTimeStep defines the new timestep to apply to this world.
  64730. */
  64731. setTimeStep(newTimeStep?: number): void;
  64732. /**
  64733. * Get the time step of the physics engine.
  64734. * @returns the current time step
  64735. */
  64736. getTimeStep(): number;
  64737. /**
  64738. * Set the sub time step of the physics engine.
  64739. * Default is 0 meaning there is no sub steps
  64740. * To increase physics resolution precision, set a small value (like 1 ms)
  64741. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64742. */
  64743. setSubTimeStep(subTimeStep?: number): void;
  64744. /**
  64745. * Get the sub time step of the physics engine.
  64746. * @returns the current sub time step
  64747. */
  64748. getSubTimeStep(): number;
  64749. /**
  64750. * Release all resources
  64751. */
  64752. dispose(): void;
  64753. /**
  64754. * Gets the name of the current physics plugin
  64755. * @returns the name of the plugin
  64756. */
  64757. getPhysicsPluginName(): string;
  64758. /**
  64759. * Adding a new impostor for the impostor tracking.
  64760. * This will be done by the impostor itself.
  64761. * @param impostor the impostor to add
  64762. */
  64763. addImpostor(impostor: PhysicsImpostor): void;
  64764. /**
  64765. * Remove an impostor from the engine.
  64766. * This impostor and its mesh will not longer be updated by the physics engine.
  64767. * @param impostor the impostor to remove
  64768. */
  64769. removeImpostor(impostor: PhysicsImpostor): void;
  64770. /**
  64771. * Add a joint to the physics engine
  64772. * @param mainImpostor defines the main impostor to which the joint is added.
  64773. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64774. * @param joint defines the joint that will connect both impostors.
  64775. */
  64776. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64777. /**
  64778. * Removes a joint from the simulation
  64779. * @param mainImpostor defines the impostor used with the joint
  64780. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64781. * @param joint defines the joint to remove
  64782. */
  64783. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64784. /**
  64785. * Called by the scene. No need to call it.
  64786. * @param delta defines the timespam between frames
  64787. */
  64788. _step(delta: number): void;
  64789. /**
  64790. * Gets the current plugin used to run the simulation
  64791. * @returns current plugin
  64792. */
  64793. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64794. /**
  64795. * Gets the list of physic impostors
  64796. * @returns an array of PhysicsImpostor
  64797. */
  64798. getImpostors(): Array<PhysicsImpostor>;
  64799. /**
  64800. * Gets the impostor for a physics enabled object
  64801. * @param object defines the object impersonated by the impostor
  64802. * @returns the PhysicsImpostor or null if not found
  64803. */
  64804. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64805. /**
  64806. * Gets the impostor for a physics body object
  64807. * @param body defines physics body used by the impostor
  64808. * @returns the PhysicsImpostor or null if not found
  64809. */
  64810. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64811. /**
  64812. * Does a raycast in the physics world
  64813. * @param from when should the ray start?
  64814. * @param to when should the ray end?
  64815. * @returns PhysicsRaycastResult
  64816. */
  64817. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64818. }
  64819. }
  64820. declare module BABYLON {
  64821. /** @hidden */
  64822. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64823. private _useDeltaForWorldStep;
  64824. world: any;
  64825. name: string;
  64826. private _physicsMaterials;
  64827. private _fixedTimeStep;
  64828. private _cannonRaycastResult;
  64829. private _raycastResult;
  64830. private _physicsBodysToRemoveAfterStep;
  64831. private _firstFrame;
  64832. BJSCANNON: any;
  64833. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64834. setGravity(gravity: Vector3): void;
  64835. setTimeStep(timeStep: number): void;
  64836. getTimeStep(): number;
  64837. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64838. private _removeMarkedPhysicsBodiesFromWorld;
  64839. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64840. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64841. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64842. private _processChildMeshes;
  64843. removePhysicsBody(impostor: PhysicsImpostor): void;
  64844. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64845. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64846. private _addMaterial;
  64847. private _checkWithEpsilon;
  64848. private _createShape;
  64849. private _createHeightmap;
  64850. private _minus90X;
  64851. private _plus90X;
  64852. private _tmpPosition;
  64853. private _tmpDeltaPosition;
  64854. private _tmpUnityRotation;
  64855. private _updatePhysicsBodyTransformation;
  64856. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64857. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64858. isSupported(): boolean;
  64859. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64860. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64861. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64862. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64863. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64864. getBodyMass(impostor: PhysicsImpostor): number;
  64865. getBodyFriction(impostor: PhysicsImpostor): number;
  64866. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64867. getBodyRestitution(impostor: PhysicsImpostor): number;
  64868. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64869. sleepBody(impostor: PhysicsImpostor): void;
  64870. wakeUpBody(impostor: PhysicsImpostor): void;
  64871. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64872. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64873. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64874. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64875. getRadius(impostor: PhysicsImpostor): number;
  64876. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64877. dispose(): void;
  64878. private _extendNamespace;
  64879. /**
  64880. * Does a raycast in the physics world
  64881. * @param from when should the ray start?
  64882. * @param to when should the ray end?
  64883. * @returns PhysicsRaycastResult
  64884. */
  64885. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64886. }
  64887. }
  64888. declare module BABYLON {
  64889. /** @hidden */
  64890. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64891. private _useDeltaForWorldStep;
  64892. world: any;
  64893. name: string;
  64894. BJSOIMO: any;
  64895. private _raycastResult;
  64896. private _fixedTimeStep;
  64897. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64898. setGravity(gravity: Vector3): void;
  64899. setTimeStep(timeStep: number): void;
  64900. getTimeStep(): number;
  64901. private _tmpImpostorsArray;
  64902. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64903. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64904. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64905. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64906. private _tmpPositionVector;
  64907. removePhysicsBody(impostor: PhysicsImpostor): void;
  64908. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64909. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64910. isSupported(): boolean;
  64911. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64912. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64913. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64914. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64915. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64916. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64917. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64918. getBodyMass(impostor: PhysicsImpostor): number;
  64919. getBodyFriction(impostor: PhysicsImpostor): number;
  64920. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64921. getBodyRestitution(impostor: PhysicsImpostor): number;
  64922. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64923. sleepBody(impostor: PhysicsImpostor): void;
  64924. wakeUpBody(impostor: PhysicsImpostor): void;
  64925. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64926. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64927. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64928. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64929. getRadius(impostor: PhysicsImpostor): number;
  64930. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64931. dispose(): void;
  64932. /**
  64933. * Does a raycast in the physics world
  64934. * @param from when should the ray start?
  64935. * @param to when should the ray end?
  64936. * @returns PhysicsRaycastResult
  64937. */
  64938. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64939. }
  64940. }
  64941. declare module BABYLON {
  64942. /**
  64943. * AmmoJS Physics plugin
  64944. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64945. * @see https://github.com/kripken/ammo.js/
  64946. */
  64947. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64948. private _useDeltaForWorldStep;
  64949. /**
  64950. * Reference to the Ammo library
  64951. */
  64952. bjsAMMO: any;
  64953. /**
  64954. * Created ammoJS world which physics bodies are added to
  64955. */
  64956. world: any;
  64957. /**
  64958. * Name of the plugin
  64959. */
  64960. name: string;
  64961. private _timeStep;
  64962. private _fixedTimeStep;
  64963. private _maxSteps;
  64964. private _tmpQuaternion;
  64965. private _tmpAmmoTransform;
  64966. private _tmpAmmoQuaternion;
  64967. private _tmpAmmoConcreteContactResultCallback;
  64968. private _collisionConfiguration;
  64969. private _dispatcher;
  64970. private _overlappingPairCache;
  64971. private _solver;
  64972. private _softBodySolver;
  64973. private _tmpAmmoVectorA;
  64974. private _tmpAmmoVectorB;
  64975. private _tmpAmmoVectorC;
  64976. private _tmpAmmoVectorD;
  64977. private _tmpContactCallbackResult;
  64978. private _tmpAmmoVectorRCA;
  64979. private _tmpAmmoVectorRCB;
  64980. private _raycastResult;
  64981. private _tmpContactPoint;
  64982. private static readonly DISABLE_COLLISION_FLAG;
  64983. private static readonly KINEMATIC_FLAG;
  64984. private static readonly DISABLE_DEACTIVATION_FLAG;
  64985. /**
  64986. * Initializes the ammoJS plugin
  64987. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64988. * @param ammoInjection can be used to inject your own ammo reference
  64989. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64990. */
  64991. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64992. /**
  64993. * Sets the gravity of the physics world (m/(s^2))
  64994. * @param gravity Gravity to set
  64995. */
  64996. setGravity(gravity: Vector3): void;
  64997. /**
  64998. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64999. * @param timeStep timestep to use in seconds
  65000. */
  65001. setTimeStep(timeStep: number): void;
  65002. /**
  65003. * 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)
  65004. * @param fixedTimeStep fixedTimeStep to use in seconds
  65005. */
  65006. setFixedTimeStep(fixedTimeStep: number): void;
  65007. /**
  65008. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65009. * @param maxSteps the maximum number of steps by the physics engine per frame
  65010. */
  65011. setMaxSteps(maxSteps: number): void;
  65012. /**
  65013. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65014. * @returns the current timestep in seconds
  65015. */
  65016. getTimeStep(): number;
  65017. /**
  65018. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65019. */
  65020. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65021. private _isImpostorInContact;
  65022. private _isImpostorPairInContact;
  65023. private _stepSimulation;
  65024. /**
  65025. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65026. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65027. * After the step the babylon meshes are set to the position of the physics imposters
  65028. * @param delta amount of time to step forward
  65029. * @param impostors array of imposters to update before/after the step
  65030. */
  65031. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65032. /**
  65033. * Update babylon mesh to match physics world object
  65034. * @param impostor imposter to match
  65035. */
  65036. private _afterSoftStep;
  65037. /**
  65038. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65039. * @param impostor imposter to match
  65040. */
  65041. private _ropeStep;
  65042. /**
  65043. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65044. * @param impostor imposter to match
  65045. */
  65046. private _softbodyOrClothStep;
  65047. private _tmpMatrix;
  65048. /**
  65049. * Applies an impulse on the imposter
  65050. * @param impostor imposter to apply impulse to
  65051. * @param force amount of force to be applied to the imposter
  65052. * @param contactPoint the location to apply the impulse on the imposter
  65053. */
  65054. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65055. /**
  65056. * Applies a force on the imposter
  65057. * @param impostor imposter to apply force
  65058. * @param force amount of force to be applied to the imposter
  65059. * @param contactPoint the location to apply the force on the imposter
  65060. */
  65061. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65062. /**
  65063. * Creates a physics body using the plugin
  65064. * @param impostor the imposter to create the physics body on
  65065. */
  65066. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65067. /**
  65068. * Removes the physics body from the imposter and disposes of the body's memory
  65069. * @param impostor imposter to remove the physics body from
  65070. */
  65071. removePhysicsBody(impostor: PhysicsImpostor): void;
  65072. /**
  65073. * Generates a joint
  65074. * @param impostorJoint the imposter joint to create the joint with
  65075. */
  65076. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65077. /**
  65078. * Removes a joint
  65079. * @param impostorJoint the imposter joint to remove the joint from
  65080. */
  65081. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65082. private _addMeshVerts;
  65083. /**
  65084. * Initialise the soft body vertices to match its object's (mesh) vertices
  65085. * Softbody vertices (nodes) are in world space and to match this
  65086. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65087. * @param impostor to create the softbody for
  65088. */
  65089. private _softVertexData;
  65090. /**
  65091. * Create an impostor's soft body
  65092. * @param impostor to create the softbody for
  65093. */
  65094. private _createSoftbody;
  65095. /**
  65096. * Create cloth for an impostor
  65097. * @param impostor to create the softbody for
  65098. */
  65099. private _createCloth;
  65100. /**
  65101. * Create rope for an impostor
  65102. * @param impostor to create the softbody for
  65103. */
  65104. private _createRope;
  65105. /**
  65106. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65107. * @param impostor to create the custom physics shape for
  65108. */
  65109. private _createCustom;
  65110. private _addHullVerts;
  65111. private _createShape;
  65112. /**
  65113. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65114. * @param impostor imposter containing the physics body and babylon object
  65115. */
  65116. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65117. /**
  65118. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65119. * @param impostor imposter containing the physics body and babylon object
  65120. * @param newPosition new position
  65121. * @param newRotation new rotation
  65122. */
  65123. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65124. /**
  65125. * If this plugin is supported
  65126. * @returns true if its supported
  65127. */
  65128. isSupported(): boolean;
  65129. /**
  65130. * Sets the linear velocity of the physics body
  65131. * @param impostor imposter to set the velocity on
  65132. * @param velocity velocity to set
  65133. */
  65134. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65135. /**
  65136. * Sets the angular velocity of the physics body
  65137. * @param impostor imposter to set the velocity on
  65138. * @param velocity velocity to set
  65139. */
  65140. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65141. /**
  65142. * gets the linear velocity
  65143. * @param impostor imposter to get linear velocity from
  65144. * @returns linear velocity
  65145. */
  65146. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65147. /**
  65148. * gets the angular velocity
  65149. * @param impostor imposter to get angular velocity from
  65150. * @returns angular velocity
  65151. */
  65152. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65153. /**
  65154. * Sets the mass of physics body
  65155. * @param impostor imposter to set the mass on
  65156. * @param mass mass to set
  65157. */
  65158. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65159. /**
  65160. * Gets the mass of the physics body
  65161. * @param impostor imposter to get the mass from
  65162. * @returns mass
  65163. */
  65164. getBodyMass(impostor: PhysicsImpostor): number;
  65165. /**
  65166. * Gets friction of the impostor
  65167. * @param impostor impostor to get friction from
  65168. * @returns friction value
  65169. */
  65170. getBodyFriction(impostor: PhysicsImpostor): number;
  65171. /**
  65172. * Sets friction of the impostor
  65173. * @param impostor impostor to set friction on
  65174. * @param friction friction value
  65175. */
  65176. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65177. /**
  65178. * Gets restitution of the impostor
  65179. * @param impostor impostor to get restitution from
  65180. * @returns restitution value
  65181. */
  65182. getBodyRestitution(impostor: PhysicsImpostor): number;
  65183. /**
  65184. * Sets resitution of the impostor
  65185. * @param impostor impostor to set resitution on
  65186. * @param restitution resitution value
  65187. */
  65188. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65189. /**
  65190. * Gets pressure inside the impostor
  65191. * @param impostor impostor to get pressure from
  65192. * @returns pressure value
  65193. */
  65194. getBodyPressure(impostor: PhysicsImpostor): number;
  65195. /**
  65196. * Sets pressure inside a soft body impostor
  65197. * Cloth and rope must remain 0 pressure
  65198. * @param impostor impostor to set pressure on
  65199. * @param pressure pressure value
  65200. */
  65201. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65202. /**
  65203. * Gets stiffness of the impostor
  65204. * @param impostor impostor to get stiffness from
  65205. * @returns pressure value
  65206. */
  65207. getBodyStiffness(impostor: PhysicsImpostor): number;
  65208. /**
  65209. * Sets stiffness of the impostor
  65210. * @param impostor impostor to set stiffness on
  65211. * @param stiffness stiffness value from 0 to 1
  65212. */
  65213. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65214. /**
  65215. * Gets velocityIterations of the impostor
  65216. * @param impostor impostor to get velocity iterations from
  65217. * @returns velocityIterations value
  65218. */
  65219. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65220. /**
  65221. * Sets velocityIterations of the impostor
  65222. * @param impostor impostor to set velocity iterations on
  65223. * @param velocityIterations velocityIterations value
  65224. */
  65225. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65226. /**
  65227. * Gets positionIterations of the impostor
  65228. * @param impostor impostor to get position iterations from
  65229. * @returns positionIterations value
  65230. */
  65231. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65232. /**
  65233. * Sets positionIterations of the impostor
  65234. * @param impostor impostor to set position on
  65235. * @param positionIterations positionIterations value
  65236. */
  65237. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65238. /**
  65239. * Append an anchor to a cloth object
  65240. * @param impostor is the cloth impostor to add anchor to
  65241. * @param otherImpostor is the rigid impostor to anchor to
  65242. * @param width ratio across width from 0 to 1
  65243. * @param height ratio up height from 0 to 1
  65244. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65245. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65246. */
  65247. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65248. /**
  65249. * Append an hook to a rope object
  65250. * @param impostor is the rope impostor to add hook to
  65251. * @param otherImpostor is the rigid impostor to hook to
  65252. * @param length ratio along the rope from 0 to 1
  65253. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65254. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65255. */
  65256. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65257. /**
  65258. * Sleeps the physics body and stops it from being active
  65259. * @param impostor impostor to sleep
  65260. */
  65261. sleepBody(impostor: PhysicsImpostor): void;
  65262. /**
  65263. * Activates the physics body
  65264. * @param impostor impostor to activate
  65265. */
  65266. wakeUpBody(impostor: PhysicsImpostor): void;
  65267. /**
  65268. * Updates the distance parameters of the joint
  65269. * @param joint joint to update
  65270. * @param maxDistance maximum distance of the joint
  65271. * @param minDistance minimum distance of the joint
  65272. */
  65273. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65274. /**
  65275. * Sets a motor on the joint
  65276. * @param joint joint to set motor on
  65277. * @param speed speed of the motor
  65278. * @param maxForce maximum force of the motor
  65279. * @param motorIndex index of the motor
  65280. */
  65281. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65282. /**
  65283. * Sets the motors limit
  65284. * @param joint joint to set limit on
  65285. * @param upperLimit upper limit
  65286. * @param lowerLimit lower limit
  65287. */
  65288. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65289. /**
  65290. * Syncs the position and rotation of a mesh with the impostor
  65291. * @param mesh mesh to sync
  65292. * @param impostor impostor to update the mesh with
  65293. */
  65294. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65295. /**
  65296. * Gets the radius of the impostor
  65297. * @param impostor impostor to get radius from
  65298. * @returns the radius
  65299. */
  65300. getRadius(impostor: PhysicsImpostor): number;
  65301. /**
  65302. * Gets the box size of the impostor
  65303. * @param impostor impostor to get box size from
  65304. * @param result the resulting box size
  65305. */
  65306. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65307. /**
  65308. * Disposes of the impostor
  65309. */
  65310. dispose(): void;
  65311. /**
  65312. * Does a raycast in the physics world
  65313. * @param from when should the ray start?
  65314. * @param to when should the ray end?
  65315. * @returns PhysicsRaycastResult
  65316. */
  65317. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65318. }
  65319. }
  65320. declare module BABYLON {
  65321. interface AbstractScene {
  65322. /**
  65323. * The list of reflection probes added to the scene
  65324. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65325. */
  65326. reflectionProbes: Array<ReflectionProbe>;
  65327. /**
  65328. * Removes the given reflection probe from this scene.
  65329. * @param toRemove The reflection probe to remove
  65330. * @returns The index of the removed reflection probe
  65331. */
  65332. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65333. /**
  65334. * Adds the given reflection probe to this scene.
  65335. * @param newReflectionProbe The reflection probe to add
  65336. */
  65337. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65338. }
  65339. /**
  65340. * Class used to generate realtime reflection / refraction cube textures
  65341. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65342. */
  65343. export class ReflectionProbe {
  65344. /** defines the name of the probe */
  65345. name: string;
  65346. private _scene;
  65347. private _renderTargetTexture;
  65348. private _projectionMatrix;
  65349. private _viewMatrix;
  65350. private _target;
  65351. private _add;
  65352. private _attachedMesh;
  65353. private _invertYAxis;
  65354. /** Gets or sets probe position (center of the cube map) */
  65355. position: Vector3;
  65356. /**
  65357. * Creates a new reflection probe
  65358. * @param name defines the name of the probe
  65359. * @param size defines the texture resolution (for each face)
  65360. * @param scene defines the hosting scene
  65361. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65362. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65363. */
  65364. constructor(
  65365. /** defines the name of the probe */
  65366. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65367. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65368. get samples(): number;
  65369. set samples(value: number);
  65370. /** Gets or sets the refresh rate to use (on every frame by default) */
  65371. get refreshRate(): number;
  65372. set refreshRate(value: number);
  65373. /**
  65374. * Gets the hosting scene
  65375. * @returns a Scene
  65376. */
  65377. getScene(): Scene;
  65378. /** Gets the internal CubeTexture used to render to */
  65379. get cubeTexture(): RenderTargetTexture;
  65380. /** Gets the list of meshes to render */
  65381. get renderList(): Nullable<AbstractMesh[]>;
  65382. /**
  65383. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65384. * @param mesh defines the mesh to attach to
  65385. */
  65386. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65387. /**
  65388. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65389. * @param renderingGroupId The rendering group id corresponding to its index
  65390. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65391. */
  65392. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65393. /**
  65394. * Clean all associated resources
  65395. */
  65396. dispose(): void;
  65397. /**
  65398. * Converts the reflection probe information to a readable string for debug purpose.
  65399. * @param fullDetails Supports for multiple levels of logging within scene loading
  65400. * @returns the human readable reflection probe info
  65401. */
  65402. toString(fullDetails?: boolean): string;
  65403. /**
  65404. * Get the class name of the relfection probe.
  65405. * @returns "ReflectionProbe"
  65406. */
  65407. getClassName(): string;
  65408. /**
  65409. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65410. * @returns The JSON representation of the texture
  65411. */
  65412. serialize(): any;
  65413. /**
  65414. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65415. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65416. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65417. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65418. * @returns The parsed reflection probe if successful
  65419. */
  65420. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65421. }
  65422. }
  65423. declare module BABYLON {
  65424. /** @hidden */
  65425. export var _BabylonLoaderRegistered: boolean;
  65426. /**
  65427. * Helps setting up some configuration for the babylon file loader.
  65428. */
  65429. export class BabylonFileLoaderConfiguration {
  65430. /**
  65431. * The loader does not allow injecting custom physix engine into the plugins.
  65432. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65433. * So you could set this variable to your engine import to make it work.
  65434. */
  65435. static LoaderInjectedPhysicsEngine: any;
  65436. }
  65437. }
  65438. declare module BABYLON {
  65439. /**
  65440. * A material to use for fast depth-only rendering.
  65441. */
  65442. export class OcclusionMaterial extends ShaderMaterial {
  65443. constructor(name: string, scene: Scene);
  65444. }
  65445. }
  65446. declare module BABYLON {
  65447. /**
  65448. * The Physically based simple base material of BJS.
  65449. *
  65450. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65451. * It is used as the base class for both the specGloss and metalRough conventions.
  65452. */
  65453. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65454. /**
  65455. * Number of Simultaneous lights allowed on the material.
  65456. */
  65457. maxSimultaneousLights: number;
  65458. /**
  65459. * If sets to true, disables all the lights affecting the material.
  65460. */
  65461. disableLighting: boolean;
  65462. /**
  65463. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65464. */
  65465. environmentTexture: BaseTexture;
  65466. /**
  65467. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65468. */
  65469. invertNormalMapX: boolean;
  65470. /**
  65471. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65472. */
  65473. invertNormalMapY: boolean;
  65474. /**
  65475. * Normal map used in the model.
  65476. */
  65477. normalTexture: BaseTexture;
  65478. /**
  65479. * Emissivie color used to self-illuminate the model.
  65480. */
  65481. emissiveColor: Color3;
  65482. /**
  65483. * Emissivie texture used to self-illuminate the model.
  65484. */
  65485. emissiveTexture: BaseTexture;
  65486. /**
  65487. * Occlusion Channel Strenght.
  65488. */
  65489. occlusionStrength: number;
  65490. /**
  65491. * Occlusion Texture of the material (adding extra occlusion effects).
  65492. */
  65493. occlusionTexture: BaseTexture;
  65494. /**
  65495. * Defines the alpha limits in alpha test mode.
  65496. */
  65497. alphaCutOff: number;
  65498. /**
  65499. * Gets the current double sided mode.
  65500. */
  65501. get doubleSided(): boolean;
  65502. /**
  65503. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65504. */
  65505. set doubleSided(value: boolean);
  65506. /**
  65507. * Stores the pre-calculated light information of a mesh in a texture.
  65508. */
  65509. lightmapTexture: BaseTexture;
  65510. /**
  65511. * If true, the light map contains occlusion information instead of lighting info.
  65512. */
  65513. useLightmapAsShadowmap: boolean;
  65514. /**
  65515. * Instantiates a new PBRMaterial instance.
  65516. *
  65517. * @param name The material name
  65518. * @param scene The scene the material will be use in.
  65519. */
  65520. constructor(name: string, scene: Scene);
  65521. getClassName(): string;
  65522. }
  65523. }
  65524. declare module BABYLON {
  65525. /**
  65526. * The PBR material of BJS following the metal roughness convention.
  65527. *
  65528. * This fits to the PBR convention in the GLTF definition:
  65529. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65530. */
  65531. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65532. /**
  65533. * The base color has two different interpretations depending on the value of metalness.
  65534. * When the material is a metal, the base color is the specific measured reflectance value
  65535. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65536. * of the material.
  65537. */
  65538. baseColor: Color3;
  65539. /**
  65540. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65541. * well as opacity information in the alpha channel.
  65542. */
  65543. baseTexture: BaseTexture;
  65544. /**
  65545. * Specifies the metallic scalar value of the material.
  65546. * Can also be used to scale the metalness values of the metallic texture.
  65547. */
  65548. metallic: number;
  65549. /**
  65550. * Specifies the roughness scalar value of the material.
  65551. * Can also be used to scale the roughness values of the metallic texture.
  65552. */
  65553. roughness: number;
  65554. /**
  65555. * Texture containing both the metallic value in the B channel and the
  65556. * roughness value in the G channel to keep better precision.
  65557. */
  65558. metallicRoughnessTexture: BaseTexture;
  65559. /**
  65560. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65561. *
  65562. * @param name The material name
  65563. * @param scene The scene the material will be use in.
  65564. */
  65565. constructor(name: string, scene: Scene);
  65566. /**
  65567. * Return the currrent class name of the material.
  65568. */
  65569. getClassName(): string;
  65570. /**
  65571. * Makes a duplicate of the current material.
  65572. * @param name - name to use for the new material.
  65573. */
  65574. clone(name: string): PBRMetallicRoughnessMaterial;
  65575. /**
  65576. * Serialize the material to a parsable JSON object.
  65577. */
  65578. serialize(): any;
  65579. /**
  65580. * Parses a JSON object correponding to the serialize function.
  65581. */
  65582. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65583. }
  65584. }
  65585. declare module BABYLON {
  65586. /**
  65587. * The PBR material of BJS following the specular glossiness convention.
  65588. *
  65589. * This fits to the PBR convention in the GLTF definition:
  65590. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65591. */
  65592. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65593. /**
  65594. * Specifies the diffuse color of the material.
  65595. */
  65596. diffuseColor: Color3;
  65597. /**
  65598. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65599. * channel.
  65600. */
  65601. diffuseTexture: BaseTexture;
  65602. /**
  65603. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65604. */
  65605. specularColor: Color3;
  65606. /**
  65607. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65608. */
  65609. glossiness: number;
  65610. /**
  65611. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65612. */
  65613. specularGlossinessTexture: BaseTexture;
  65614. /**
  65615. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  65616. */
  65617. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  65618. /**
  65619. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65620. *
  65621. * @param name The material name
  65622. * @param scene The scene the material will be use in.
  65623. */
  65624. constructor(name: string, scene: Scene);
  65625. /**
  65626. * Return the currrent class name of the material.
  65627. */
  65628. getClassName(): string;
  65629. /**
  65630. * Makes a duplicate of the current material.
  65631. * @param name - name to use for the new material.
  65632. */
  65633. clone(name: string): PBRSpecularGlossinessMaterial;
  65634. /**
  65635. * Serialize the material to a parsable JSON object.
  65636. */
  65637. serialize(): any;
  65638. /**
  65639. * Parses a JSON object correponding to the serialize function.
  65640. */
  65641. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65642. }
  65643. }
  65644. declare module BABYLON {
  65645. /**
  65646. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65647. * It can help converting any input color in a desired output one. This can then be used to create effects
  65648. * from sepia, black and white to sixties or futuristic rendering...
  65649. *
  65650. * The only supported format is currently 3dl.
  65651. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65652. */
  65653. export class ColorGradingTexture extends BaseTexture {
  65654. /**
  65655. * The texture URL.
  65656. */
  65657. url: string;
  65658. /**
  65659. * Empty line regex stored for GC.
  65660. */
  65661. private static _noneEmptyLineRegex;
  65662. private _textureMatrix;
  65663. private _onLoad;
  65664. /**
  65665. * Instantiates a ColorGradingTexture from the following parameters.
  65666. *
  65667. * @param url The location of the color gradind data (currently only supporting 3dl)
  65668. * @param sceneOrEngine The scene or engine the texture will be used in
  65669. * @param onLoad defines a callback triggered when the texture has been loaded
  65670. */
  65671. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65672. /**
  65673. * Fires the onload event from the constructor if requested.
  65674. */
  65675. private _triggerOnLoad;
  65676. /**
  65677. * Returns the texture matrix used in most of the material.
  65678. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65679. */
  65680. getTextureMatrix(): Matrix;
  65681. /**
  65682. * Occurs when the file being loaded is a .3dl LUT file.
  65683. */
  65684. private load3dlTexture;
  65685. /**
  65686. * Starts the loading process of the texture.
  65687. */
  65688. private loadTexture;
  65689. /**
  65690. * Clones the color gradind texture.
  65691. */
  65692. clone(): ColorGradingTexture;
  65693. /**
  65694. * Called during delayed load for textures.
  65695. */
  65696. delayLoad(): void;
  65697. /**
  65698. * Parses a color grading texture serialized by Babylon.
  65699. * @param parsedTexture The texture information being parsedTexture
  65700. * @param scene The scene to load the texture in
  65701. * @param rootUrl The root url of the data assets to load
  65702. * @return A color gradind texture
  65703. */
  65704. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65705. /**
  65706. * Serializes the LUT texture to json format.
  65707. */
  65708. serialize(): any;
  65709. }
  65710. }
  65711. declare module BABYLON {
  65712. /**
  65713. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65714. */
  65715. export class EquiRectangularCubeTexture extends BaseTexture {
  65716. /** The six faces of the cube. */
  65717. private static _FacesMapping;
  65718. private _noMipmap;
  65719. private _onLoad;
  65720. private _onError;
  65721. /** The size of the cubemap. */
  65722. private _size;
  65723. /** The buffer of the image. */
  65724. private _buffer;
  65725. /** The width of the input image. */
  65726. private _width;
  65727. /** The height of the input image. */
  65728. private _height;
  65729. /** The URL to the image. */
  65730. url: string;
  65731. /**
  65732. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65733. * @param url The location of the image
  65734. * @param scene The scene the texture will be used in
  65735. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65736. * @param noMipmap Forces to not generate the mipmap if true
  65737. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65738. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65739. * @param onLoad — defines a callback called when texture is loaded
  65740. * @param onError — defines a callback called if there is an error
  65741. */
  65742. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65743. /**
  65744. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65745. */
  65746. private loadImage;
  65747. /**
  65748. * Convert the image buffer into a cubemap and create a CubeTexture.
  65749. */
  65750. private loadTexture;
  65751. /**
  65752. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65753. * @param buffer The ArrayBuffer that should be converted.
  65754. * @returns The buffer as Float32Array.
  65755. */
  65756. private getFloat32ArrayFromArrayBuffer;
  65757. /**
  65758. * Get the current class name of the texture useful for serialization or dynamic coding.
  65759. * @returns "EquiRectangularCubeTexture"
  65760. */
  65761. getClassName(): string;
  65762. /**
  65763. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65764. * @returns A clone of the current EquiRectangularCubeTexture.
  65765. */
  65766. clone(): EquiRectangularCubeTexture;
  65767. }
  65768. }
  65769. declare module BABYLON {
  65770. /**
  65771. * Defines the options related to the creation of an HtmlElementTexture
  65772. */
  65773. export interface IHtmlElementTextureOptions {
  65774. /**
  65775. * Defines wether mip maps should be created or not.
  65776. */
  65777. generateMipMaps?: boolean;
  65778. /**
  65779. * Defines the sampling mode of the texture.
  65780. */
  65781. samplingMode?: number;
  65782. /**
  65783. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65784. */
  65785. engine: Nullable<ThinEngine>;
  65786. /**
  65787. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65788. */
  65789. scene: Nullable<Scene>;
  65790. }
  65791. /**
  65792. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65793. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65794. * is automatically managed.
  65795. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65796. * in your application.
  65797. *
  65798. * As the update is not automatic, you need to call them manually.
  65799. */
  65800. export class HtmlElementTexture extends BaseTexture {
  65801. /**
  65802. * The texture URL.
  65803. */
  65804. element: HTMLVideoElement | HTMLCanvasElement;
  65805. private static readonly DefaultOptions;
  65806. private _textureMatrix;
  65807. private _isVideo;
  65808. private _generateMipMaps;
  65809. private _samplingMode;
  65810. /**
  65811. * Instantiates a HtmlElementTexture from the following parameters.
  65812. *
  65813. * @param name Defines the name of the texture
  65814. * @param element Defines the video or canvas the texture is filled with
  65815. * @param options Defines the other none mandatory texture creation options
  65816. */
  65817. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65818. private _createInternalTexture;
  65819. /**
  65820. * Returns the texture matrix used in most of the material.
  65821. */
  65822. getTextureMatrix(): Matrix;
  65823. /**
  65824. * Updates the content of the texture.
  65825. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65826. */
  65827. update(invertY?: Nullable<boolean>): void;
  65828. }
  65829. }
  65830. declare module BABYLON {
  65831. /**
  65832. * Based on jsTGALoader - Javascript loader for TGA file
  65833. * By Vincent Thibault
  65834. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65835. */
  65836. export class TGATools {
  65837. private static _TYPE_INDEXED;
  65838. private static _TYPE_RGB;
  65839. private static _TYPE_GREY;
  65840. private static _TYPE_RLE_INDEXED;
  65841. private static _TYPE_RLE_RGB;
  65842. private static _TYPE_RLE_GREY;
  65843. private static _ORIGIN_MASK;
  65844. private static _ORIGIN_SHIFT;
  65845. private static _ORIGIN_BL;
  65846. private static _ORIGIN_BR;
  65847. private static _ORIGIN_UL;
  65848. private static _ORIGIN_UR;
  65849. /**
  65850. * Gets the header of a TGA file
  65851. * @param data defines the TGA data
  65852. * @returns the header
  65853. */
  65854. static GetTGAHeader(data: Uint8Array): any;
  65855. /**
  65856. * Uploads TGA content to a Babylon Texture
  65857. * @hidden
  65858. */
  65859. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65860. /** @hidden */
  65861. 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;
  65862. /** @hidden */
  65863. 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;
  65864. /** @hidden */
  65865. 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;
  65866. /** @hidden */
  65867. 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;
  65868. /** @hidden */
  65869. 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;
  65870. /** @hidden */
  65871. 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;
  65872. }
  65873. }
  65874. declare module BABYLON {
  65875. /**
  65876. * Implementation of the TGA Texture Loader.
  65877. * @hidden
  65878. */
  65879. export class _TGATextureLoader implements IInternalTextureLoader {
  65880. /**
  65881. * Defines wether the loader supports cascade loading the different faces.
  65882. */
  65883. readonly supportCascades: boolean;
  65884. /**
  65885. * This returns if the loader support the current file information.
  65886. * @param extension defines the file extension of the file being loaded
  65887. * @returns true if the loader can load the specified file
  65888. */
  65889. canLoad(extension: string): boolean;
  65890. /**
  65891. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65892. * @param data contains the texture data
  65893. * @param texture defines the BabylonJS internal texture
  65894. * @param createPolynomials will be true if polynomials have been requested
  65895. * @param onLoad defines the callback to trigger once the texture is ready
  65896. * @param onError defines the callback to trigger in case of error
  65897. */
  65898. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65899. /**
  65900. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65901. * @param data contains the texture data
  65902. * @param texture defines the BabylonJS internal texture
  65903. * @param callback defines the method to call once ready to upload
  65904. */
  65905. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65906. }
  65907. }
  65908. declare module BABYLON {
  65909. /**
  65910. * Info about the .basis files
  65911. */
  65912. class BasisFileInfo {
  65913. /**
  65914. * If the file has alpha
  65915. */
  65916. hasAlpha: boolean;
  65917. /**
  65918. * Info about each image of the basis file
  65919. */
  65920. images: Array<{
  65921. levels: Array<{
  65922. width: number;
  65923. height: number;
  65924. transcodedPixels: ArrayBufferView;
  65925. }>;
  65926. }>;
  65927. }
  65928. /**
  65929. * Result of transcoding a basis file
  65930. */
  65931. class TranscodeResult {
  65932. /**
  65933. * Info about the .basis file
  65934. */
  65935. fileInfo: BasisFileInfo;
  65936. /**
  65937. * Format to use when loading the file
  65938. */
  65939. format: number;
  65940. }
  65941. /**
  65942. * Configuration options for the Basis transcoder
  65943. */
  65944. export class BasisTranscodeConfiguration {
  65945. /**
  65946. * Supported compression formats used to determine the supported output format of the transcoder
  65947. */
  65948. supportedCompressionFormats?: {
  65949. /**
  65950. * etc1 compression format
  65951. */
  65952. etc1?: boolean;
  65953. /**
  65954. * s3tc compression format
  65955. */
  65956. s3tc?: boolean;
  65957. /**
  65958. * pvrtc compression format
  65959. */
  65960. pvrtc?: boolean;
  65961. /**
  65962. * etc2 compression format
  65963. */
  65964. etc2?: boolean;
  65965. };
  65966. /**
  65967. * If mipmap levels should be loaded for transcoded images (Default: true)
  65968. */
  65969. loadMipmapLevels?: boolean;
  65970. /**
  65971. * Index of a single image to load (Default: all images)
  65972. */
  65973. loadSingleImage?: number;
  65974. }
  65975. /**
  65976. * Used to load .Basis files
  65977. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65978. */
  65979. export class BasisTools {
  65980. private static _IgnoreSupportedFormats;
  65981. /**
  65982. * URL to use when loading the basis transcoder
  65983. */
  65984. static JSModuleURL: string;
  65985. /**
  65986. * URL to use when loading the wasm module for the transcoder
  65987. */
  65988. static WasmModuleURL: string;
  65989. /**
  65990. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65991. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65992. * @returns internal format corresponding to the Basis format
  65993. */
  65994. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65995. private static _WorkerPromise;
  65996. private static _Worker;
  65997. private static _actionId;
  65998. private static _CreateWorkerAsync;
  65999. /**
  66000. * Transcodes a loaded image file to compressed pixel data
  66001. * @param data image data to transcode
  66002. * @param config configuration options for the transcoding
  66003. * @returns a promise resulting in the transcoded image
  66004. */
  66005. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66006. /**
  66007. * Loads a texture from the transcode result
  66008. * @param texture texture load to
  66009. * @param transcodeResult the result of transcoding the basis file to load from
  66010. */
  66011. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66012. }
  66013. }
  66014. declare module BABYLON {
  66015. /**
  66016. * Loader for .basis file format
  66017. */
  66018. export class _BasisTextureLoader implements IInternalTextureLoader {
  66019. /**
  66020. * Defines whether the loader supports cascade loading the different faces.
  66021. */
  66022. readonly supportCascades: boolean;
  66023. /**
  66024. * This returns if the loader support the current file information.
  66025. * @param extension defines the file extension of the file being loaded
  66026. * @returns true if the loader can load the specified file
  66027. */
  66028. canLoad(extension: string): boolean;
  66029. /**
  66030. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66031. * @param data contains the texture data
  66032. * @param texture defines the BabylonJS internal texture
  66033. * @param createPolynomials will be true if polynomials have been requested
  66034. * @param onLoad defines the callback to trigger once the texture is ready
  66035. * @param onError defines the callback to trigger in case of error
  66036. */
  66037. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66038. /**
  66039. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66040. * @param data contains the texture data
  66041. * @param texture defines the BabylonJS internal texture
  66042. * @param callback defines the method to call once ready to upload
  66043. */
  66044. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66045. }
  66046. }
  66047. declare module BABYLON {
  66048. /**
  66049. * Defines the basic options interface of a TexturePacker Frame
  66050. */
  66051. export interface ITexturePackerFrame {
  66052. /**
  66053. * The frame ID
  66054. */
  66055. id: number;
  66056. /**
  66057. * The frames Scale
  66058. */
  66059. scale: Vector2;
  66060. /**
  66061. * The Frames offset
  66062. */
  66063. offset: Vector2;
  66064. }
  66065. /**
  66066. * This is a support class for frame Data on texture packer sets.
  66067. */
  66068. export class TexturePackerFrame implements ITexturePackerFrame {
  66069. /**
  66070. * The frame ID
  66071. */
  66072. id: number;
  66073. /**
  66074. * The frames Scale
  66075. */
  66076. scale: Vector2;
  66077. /**
  66078. * The Frames offset
  66079. */
  66080. offset: Vector2;
  66081. /**
  66082. * Initializes a texture package frame.
  66083. * @param id The numerical frame identifier
  66084. * @param scale Scalar Vector2 for UV frame
  66085. * @param offset Vector2 for the frame position in UV units.
  66086. * @returns TexturePackerFrame
  66087. */
  66088. constructor(id: number, scale: Vector2, offset: Vector2);
  66089. }
  66090. }
  66091. declare module BABYLON {
  66092. /**
  66093. * Defines the basic options interface of a TexturePacker
  66094. */
  66095. export interface ITexturePackerOptions {
  66096. /**
  66097. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66098. */
  66099. map?: string[];
  66100. /**
  66101. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66102. */
  66103. uvsIn?: string;
  66104. /**
  66105. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66106. */
  66107. uvsOut?: string;
  66108. /**
  66109. * number representing the layout style. Defaults to LAYOUT_STRIP
  66110. */
  66111. layout?: number;
  66112. /**
  66113. * number of columns if using custom column count layout(2). This defaults to 4.
  66114. */
  66115. colnum?: number;
  66116. /**
  66117. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66118. */
  66119. updateInputMeshes?: boolean;
  66120. /**
  66121. * boolean flag to dispose all the source textures. Defaults to true.
  66122. */
  66123. disposeSources?: boolean;
  66124. /**
  66125. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66126. */
  66127. fillBlanks?: boolean;
  66128. /**
  66129. * string value representing the context fill style color. Defaults to 'black'.
  66130. */
  66131. customFillColor?: string;
  66132. /**
  66133. * Width and Height Value of each Frame in the TexturePacker Sets
  66134. */
  66135. frameSize?: number;
  66136. /**
  66137. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66138. */
  66139. paddingRatio?: number;
  66140. /**
  66141. * Number that declares the fill method for the padding gutter.
  66142. */
  66143. paddingMode?: number;
  66144. /**
  66145. * If in SUBUV_COLOR padding mode what color to use.
  66146. */
  66147. paddingColor?: Color3 | Color4;
  66148. }
  66149. /**
  66150. * Defines the basic interface of a TexturePacker JSON File
  66151. */
  66152. export interface ITexturePackerJSON {
  66153. /**
  66154. * The frame ID
  66155. */
  66156. name: string;
  66157. /**
  66158. * The base64 channel data
  66159. */
  66160. sets: any;
  66161. /**
  66162. * The options of the Packer
  66163. */
  66164. options: ITexturePackerOptions;
  66165. /**
  66166. * The frame data of the Packer
  66167. */
  66168. frames: Array<number>;
  66169. }
  66170. /**
  66171. * This is a support class that generates a series of packed texture sets.
  66172. * @see https://doc.babylonjs.com/babylon101/materials
  66173. */
  66174. export class TexturePacker {
  66175. /** Packer Layout Constant 0 */
  66176. static readonly LAYOUT_STRIP: number;
  66177. /** Packer Layout Constant 1 */
  66178. static readonly LAYOUT_POWER2: number;
  66179. /** Packer Layout Constant 2 */
  66180. static readonly LAYOUT_COLNUM: number;
  66181. /** Packer Layout Constant 0 */
  66182. static readonly SUBUV_WRAP: number;
  66183. /** Packer Layout Constant 1 */
  66184. static readonly SUBUV_EXTEND: number;
  66185. /** Packer Layout Constant 2 */
  66186. static readonly SUBUV_COLOR: number;
  66187. /** The Name of the Texture Package */
  66188. name: string;
  66189. /** The scene scope of the TexturePacker */
  66190. scene: Scene;
  66191. /** The Meshes to target */
  66192. meshes: AbstractMesh[];
  66193. /** Arguments passed with the Constructor */
  66194. options: ITexturePackerOptions;
  66195. /** The promise that is started upon initialization */
  66196. promise: Nullable<Promise<TexturePacker | string>>;
  66197. /** The Container object for the channel sets that are generated */
  66198. sets: object;
  66199. /** The Container array for the frames that are generated */
  66200. frames: TexturePackerFrame[];
  66201. /** The expected number of textures the system is parsing. */
  66202. private _expecting;
  66203. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66204. private _paddingValue;
  66205. /**
  66206. * Initializes a texture package series from an array of meshes or a single mesh.
  66207. * @param name The name of the package
  66208. * @param meshes The target meshes to compose the package from
  66209. * @param options The arguments that texture packer should follow while building.
  66210. * @param scene The scene which the textures are scoped to.
  66211. * @returns TexturePacker
  66212. */
  66213. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66214. /**
  66215. * Starts the package process
  66216. * @param resolve The promises resolution function
  66217. * @returns TexturePacker
  66218. */
  66219. private _createFrames;
  66220. /**
  66221. * Calculates the Size of the Channel Sets
  66222. * @returns Vector2
  66223. */
  66224. private _calculateSize;
  66225. /**
  66226. * Calculates the UV data for the frames.
  66227. * @param baseSize the base frameSize
  66228. * @param padding the base frame padding
  66229. * @param dtSize size of the Dynamic Texture for that channel
  66230. * @param dtUnits is 1/dtSize
  66231. * @param update flag to update the input meshes
  66232. */
  66233. private _calculateMeshUVFrames;
  66234. /**
  66235. * Calculates the frames Offset.
  66236. * @param index of the frame
  66237. * @returns Vector2
  66238. */
  66239. private _getFrameOffset;
  66240. /**
  66241. * Updates a Mesh to the frame data
  66242. * @param mesh that is the target
  66243. * @param frameID or the frame index
  66244. */
  66245. private _updateMeshUV;
  66246. /**
  66247. * Updates a Meshes materials to use the texture packer channels
  66248. * @param m is the mesh to target
  66249. * @param force all channels on the packer to be set.
  66250. */
  66251. private _updateTextureReferences;
  66252. /**
  66253. * Public method to set a Mesh to a frame
  66254. * @param m that is the target
  66255. * @param frameID or the frame index
  66256. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66257. */
  66258. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66259. /**
  66260. * Starts the async promise to compile the texture packer.
  66261. * @returns Promise<void>
  66262. */
  66263. processAsync(): Promise<void>;
  66264. /**
  66265. * Disposes all textures associated with this packer
  66266. */
  66267. dispose(): void;
  66268. /**
  66269. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66270. * @param imageType is the image type to use.
  66271. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66272. */
  66273. download(imageType?: string, quality?: number): void;
  66274. /**
  66275. * Public method to load a texturePacker JSON file.
  66276. * @param data of the JSON file in string format.
  66277. */
  66278. updateFromJSON(data: string): void;
  66279. }
  66280. }
  66281. declare module BABYLON {
  66282. /**
  66283. * 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.
  66284. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66285. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66286. */
  66287. export class CustomProceduralTexture extends ProceduralTexture {
  66288. private _animate;
  66289. private _time;
  66290. private _config;
  66291. private _texturePath;
  66292. /**
  66293. * Instantiates a new Custom Procedural Texture.
  66294. * 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.
  66295. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66296. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66297. * @param name Define the name of the texture
  66298. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66299. * @param size Define the size of the texture to create
  66300. * @param scene Define the scene the texture belongs to
  66301. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66302. * @param generateMipMaps Define if the texture should creates mip maps or not
  66303. */
  66304. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66305. private _loadJson;
  66306. /**
  66307. * Is the texture ready to be used ? (rendered at least once)
  66308. * @returns true if ready, otherwise, false.
  66309. */
  66310. isReady(): boolean;
  66311. /**
  66312. * Render the texture to its associated render target.
  66313. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66314. */
  66315. render(useCameraPostProcess?: boolean): void;
  66316. /**
  66317. * Update the list of dependant textures samplers in the shader.
  66318. */
  66319. updateTextures(): void;
  66320. /**
  66321. * Update the uniform values of the procedural texture in the shader.
  66322. */
  66323. updateShaderUniforms(): void;
  66324. /**
  66325. * Define if the texture animates or not.
  66326. */
  66327. get animate(): boolean;
  66328. set animate(value: boolean);
  66329. }
  66330. }
  66331. declare module BABYLON {
  66332. /** @hidden */
  66333. export var noisePixelShader: {
  66334. name: string;
  66335. shader: string;
  66336. };
  66337. }
  66338. declare module BABYLON {
  66339. /**
  66340. * Class used to generate noise procedural textures
  66341. */
  66342. export class NoiseProceduralTexture extends ProceduralTexture {
  66343. /** Gets or sets the start time (default is 0) */
  66344. time: number;
  66345. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66346. brightness: number;
  66347. /** Defines the number of octaves to process */
  66348. octaves: number;
  66349. /** Defines the level of persistence (0.8 by default) */
  66350. persistence: number;
  66351. /** Gets or sets animation speed factor (default is 1) */
  66352. animationSpeedFactor: number;
  66353. /**
  66354. * Creates a new NoiseProceduralTexture
  66355. * @param name defines the name fo the texture
  66356. * @param size defines the size of the texture (default is 256)
  66357. * @param scene defines the hosting scene
  66358. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66359. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66360. */
  66361. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66362. private _updateShaderUniforms;
  66363. protected _getDefines(): string;
  66364. /** Generate the current state of the procedural texture */
  66365. render(useCameraPostProcess?: boolean): void;
  66366. /**
  66367. * Serializes this noise procedural texture
  66368. * @returns a serialized noise procedural texture object
  66369. */
  66370. serialize(): any;
  66371. /**
  66372. * Clone the texture.
  66373. * @returns the cloned texture
  66374. */
  66375. clone(): NoiseProceduralTexture;
  66376. /**
  66377. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66378. * @param parsedTexture defines parsed texture data
  66379. * @param scene defines the current scene
  66380. * @param rootUrl defines the root URL containing noise procedural texture information
  66381. * @returns a parsed NoiseProceduralTexture
  66382. */
  66383. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66384. }
  66385. }
  66386. declare module BABYLON {
  66387. /**
  66388. * Raw cube texture where the raw buffers are passed in
  66389. */
  66390. export class RawCubeTexture extends CubeTexture {
  66391. /**
  66392. * Creates a cube texture where the raw buffers are passed in.
  66393. * @param scene defines the scene the texture is attached to
  66394. * @param data defines the array of data to use to create each face
  66395. * @param size defines the size of the textures
  66396. * @param format defines the format of the data
  66397. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66398. * @param generateMipMaps defines if the engine should generate the mip levels
  66399. * @param invertY defines if data must be stored with Y axis inverted
  66400. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66401. * @param compression defines the compression used (null by default)
  66402. */
  66403. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66404. /**
  66405. * Updates the raw cube texture.
  66406. * @param data defines the data to store
  66407. * @param format defines the data format
  66408. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66409. * @param invertY defines if data must be stored with Y axis inverted
  66410. * @param compression defines the compression used (null by default)
  66411. * @param level defines which level of the texture to update
  66412. */
  66413. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66414. /**
  66415. * Updates a raw cube texture with RGBD encoded data.
  66416. * @param data defines the array of data [mipmap][face] to use to create each face
  66417. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66418. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66419. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66420. * @returns a promsie that resolves when the operation is complete
  66421. */
  66422. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66423. /**
  66424. * Clones the raw cube texture.
  66425. * @return a new cube texture
  66426. */
  66427. clone(): CubeTexture;
  66428. /** @hidden */
  66429. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66430. }
  66431. }
  66432. declare module BABYLON {
  66433. /**
  66434. * Class used to store 2D array textures containing user data
  66435. */
  66436. export class RawTexture2DArray extends Texture {
  66437. /** Gets or sets the texture format to use */
  66438. format: number;
  66439. /**
  66440. * Create a new RawTexture2DArray
  66441. * @param data defines the data of the texture
  66442. * @param width defines the width of the texture
  66443. * @param height defines the height of the texture
  66444. * @param depth defines the number of layers of the texture
  66445. * @param format defines the texture format to use
  66446. * @param scene defines the hosting scene
  66447. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66448. * @param invertY defines if texture must be stored with Y axis inverted
  66449. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66450. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66451. */
  66452. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66453. /** Gets or sets the texture format to use */
  66454. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66455. /**
  66456. * Update the texture with new data
  66457. * @param data defines the data to store in the texture
  66458. */
  66459. update(data: ArrayBufferView): void;
  66460. }
  66461. }
  66462. declare module BABYLON {
  66463. /**
  66464. * Class used to store 3D textures containing user data
  66465. */
  66466. export class RawTexture3D extends Texture {
  66467. /** Gets or sets the texture format to use */
  66468. format: number;
  66469. /**
  66470. * Create a new RawTexture3D
  66471. * @param data defines the data of the texture
  66472. * @param width defines the width of the texture
  66473. * @param height defines the height of the texture
  66474. * @param depth defines the depth of the texture
  66475. * @param format defines the texture format to use
  66476. * @param scene defines the hosting scene
  66477. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66478. * @param invertY defines if texture must be stored with Y axis inverted
  66479. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66480. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66481. */
  66482. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66483. /** Gets or sets the texture format to use */
  66484. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66485. /**
  66486. * Update the texture with new data
  66487. * @param data defines the data to store in the texture
  66488. */
  66489. update(data: ArrayBufferView): void;
  66490. }
  66491. }
  66492. declare module BABYLON {
  66493. /**
  66494. * Creates a refraction texture used by refraction channel of the standard material.
  66495. * It is like a mirror but to see through a material.
  66496. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66497. */
  66498. export class RefractionTexture extends RenderTargetTexture {
  66499. /**
  66500. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66501. * 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.
  66502. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66503. */
  66504. refractionPlane: Plane;
  66505. /**
  66506. * Define how deep under the surface we should see.
  66507. */
  66508. depth: number;
  66509. /**
  66510. * Creates a refraction texture used by refraction channel of the standard material.
  66511. * It is like a mirror but to see through a material.
  66512. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66513. * @param name Define the texture name
  66514. * @param size Define the size of the underlying texture
  66515. * @param scene Define the scene the refraction belongs to
  66516. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66517. */
  66518. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66519. /**
  66520. * Clone the refraction texture.
  66521. * @returns the cloned texture
  66522. */
  66523. clone(): RefractionTexture;
  66524. /**
  66525. * Serialize the texture to a JSON representation you could use in Parse later on
  66526. * @returns the serialized JSON representation
  66527. */
  66528. serialize(): any;
  66529. }
  66530. }
  66531. declare module BABYLON {
  66532. /**
  66533. * Block used to add support for vertex skinning (bones)
  66534. */
  66535. export class BonesBlock extends NodeMaterialBlock {
  66536. /**
  66537. * Creates a new BonesBlock
  66538. * @param name defines the block name
  66539. */
  66540. constructor(name: string);
  66541. /**
  66542. * Initialize the block and prepare the context for build
  66543. * @param state defines the state that will be used for the build
  66544. */
  66545. initialize(state: NodeMaterialBuildState): void;
  66546. /**
  66547. * Gets the current class name
  66548. * @returns the class name
  66549. */
  66550. getClassName(): string;
  66551. /**
  66552. * Gets the matrix indices input component
  66553. */
  66554. get matricesIndices(): NodeMaterialConnectionPoint;
  66555. /**
  66556. * Gets the matrix weights input component
  66557. */
  66558. get matricesWeights(): NodeMaterialConnectionPoint;
  66559. /**
  66560. * Gets the extra matrix indices input component
  66561. */
  66562. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66563. /**
  66564. * Gets the extra matrix weights input component
  66565. */
  66566. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66567. /**
  66568. * Gets the world input component
  66569. */
  66570. get world(): NodeMaterialConnectionPoint;
  66571. /**
  66572. * Gets the output component
  66573. */
  66574. get output(): NodeMaterialConnectionPoint;
  66575. autoConfigure(material: NodeMaterial): void;
  66576. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66577. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66578. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66579. protected _buildBlock(state: NodeMaterialBuildState): this;
  66580. }
  66581. }
  66582. declare module BABYLON {
  66583. /**
  66584. * Block used to add support for instances
  66585. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66586. */
  66587. export class InstancesBlock extends NodeMaterialBlock {
  66588. /**
  66589. * Creates a new InstancesBlock
  66590. * @param name defines the block name
  66591. */
  66592. constructor(name: string);
  66593. /**
  66594. * Gets the current class name
  66595. * @returns the class name
  66596. */
  66597. getClassName(): string;
  66598. /**
  66599. * Gets the first world row input component
  66600. */
  66601. get world0(): NodeMaterialConnectionPoint;
  66602. /**
  66603. * Gets the second world row input component
  66604. */
  66605. get world1(): NodeMaterialConnectionPoint;
  66606. /**
  66607. * Gets the third world row input component
  66608. */
  66609. get world2(): NodeMaterialConnectionPoint;
  66610. /**
  66611. * Gets the forth world row input component
  66612. */
  66613. get world3(): NodeMaterialConnectionPoint;
  66614. /**
  66615. * Gets the world input component
  66616. */
  66617. get world(): NodeMaterialConnectionPoint;
  66618. /**
  66619. * Gets the output component
  66620. */
  66621. get output(): NodeMaterialConnectionPoint;
  66622. /**
  66623. * Gets the isntanceID component
  66624. */
  66625. get instanceID(): NodeMaterialConnectionPoint;
  66626. autoConfigure(material: NodeMaterial): void;
  66627. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66628. protected _buildBlock(state: NodeMaterialBuildState): this;
  66629. }
  66630. }
  66631. declare module BABYLON {
  66632. /**
  66633. * Block used to add morph targets support to vertex shader
  66634. */
  66635. export class MorphTargetsBlock extends NodeMaterialBlock {
  66636. private _repeatableContentAnchor;
  66637. /**
  66638. * Create a new MorphTargetsBlock
  66639. * @param name defines the block name
  66640. */
  66641. constructor(name: string);
  66642. /**
  66643. * Gets the current class name
  66644. * @returns the class name
  66645. */
  66646. getClassName(): string;
  66647. /**
  66648. * Gets the position input component
  66649. */
  66650. get position(): NodeMaterialConnectionPoint;
  66651. /**
  66652. * Gets the normal input component
  66653. */
  66654. get normal(): NodeMaterialConnectionPoint;
  66655. /**
  66656. * Gets the tangent input component
  66657. */
  66658. get tangent(): NodeMaterialConnectionPoint;
  66659. /**
  66660. * Gets the tangent input component
  66661. */
  66662. get uv(): NodeMaterialConnectionPoint;
  66663. /**
  66664. * Gets the position output component
  66665. */
  66666. get positionOutput(): NodeMaterialConnectionPoint;
  66667. /**
  66668. * Gets the normal output component
  66669. */
  66670. get normalOutput(): NodeMaterialConnectionPoint;
  66671. /**
  66672. * Gets the tangent output component
  66673. */
  66674. get tangentOutput(): NodeMaterialConnectionPoint;
  66675. /**
  66676. * Gets the tangent output component
  66677. */
  66678. get uvOutput(): NodeMaterialConnectionPoint;
  66679. initialize(state: NodeMaterialBuildState): void;
  66680. autoConfigure(material: NodeMaterial): void;
  66681. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66682. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66683. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66684. protected _buildBlock(state: NodeMaterialBuildState): this;
  66685. }
  66686. }
  66687. declare module BABYLON {
  66688. /**
  66689. * Block used to get data information from a light
  66690. */
  66691. export class LightInformationBlock extends NodeMaterialBlock {
  66692. private _lightDataUniformName;
  66693. private _lightColorUniformName;
  66694. private _lightTypeDefineName;
  66695. /**
  66696. * Gets or sets the light associated with this block
  66697. */
  66698. light: Nullable<Light>;
  66699. /**
  66700. * Creates a new LightInformationBlock
  66701. * @param name defines the block name
  66702. */
  66703. constructor(name: string);
  66704. /**
  66705. * Gets the current class name
  66706. * @returns the class name
  66707. */
  66708. getClassName(): string;
  66709. /**
  66710. * Gets the world position input component
  66711. */
  66712. get worldPosition(): NodeMaterialConnectionPoint;
  66713. /**
  66714. * Gets the direction output component
  66715. */
  66716. get direction(): NodeMaterialConnectionPoint;
  66717. /**
  66718. * Gets the direction output component
  66719. */
  66720. get color(): NodeMaterialConnectionPoint;
  66721. /**
  66722. * Gets the direction output component
  66723. */
  66724. get intensity(): NodeMaterialConnectionPoint;
  66725. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66726. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66727. protected _buildBlock(state: NodeMaterialBuildState): this;
  66728. serialize(): any;
  66729. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66730. }
  66731. }
  66732. declare module BABYLON {
  66733. /**
  66734. * Block used to add image processing support to fragment shader
  66735. */
  66736. export class ImageProcessingBlock extends NodeMaterialBlock {
  66737. /**
  66738. * Create a new ImageProcessingBlock
  66739. * @param name defines the block name
  66740. */
  66741. constructor(name: string);
  66742. /**
  66743. * Gets the current class name
  66744. * @returns the class name
  66745. */
  66746. getClassName(): string;
  66747. /**
  66748. * Gets the color input component
  66749. */
  66750. get color(): NodeMaterialConnectionPoint;
  66751. /**
  66752. * Gets the output component
  66753. */
  66754. get output(): NodeMaterialConnectionPoint;
  66755. /**
  66756. * Initialize the block and prepare the context for build
  66757. * @param state defines the state that will be used for the build
  66758. */
  66759. initialize(state: NodeMaterialBuildState): void;
  66760. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66761. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66762. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66763. protected _buildBlock(state: NodeMaterialBuildState): this;
  66764. }
  66765. }
  66766. declare module BABYLON {
  66767. /**
  66768. * Block used to pertub normals based on a normal map
  66769. */
  66770. export class PerturbNormalBlock extends NodeMaterialBlock {
  66771. private _tangentSpaceParameterName;
  66772. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66773. invertX: boolean;
  66774. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66775. invertY: boolean;
  66776. /**
  66777. * Create a new PerturbNormalBlock
  66778. * @param name defines the block name
  66779. */
  66780. constructor(name: string);
  66781. /**
  66782. * Gets the current class name
  66783. * @returns the class name
  66784. */
  66785. getClassName(): string;
  66786. /**
  66787. * Gets the world position input component
  66788. */
  66789. get worldPosition(): NodeMaterialConnectionPoint;
  66790. /**
  66791. * Gets the world normal input component
  66792. */
  66793. get worldNormal(): NodeMaterialConnectionPoint;
  66794. /**
  66795. * Gets the world tangent input component
  66796. */
  66797. get worldTangent(): NodeMaterialConnectionPoint;
  66798. /**
  66799. * Gets the uv input component
  66800. */
  66801. get uv(): NodeMaterialConnectionPoint;
  66802. /**
  66803. * Gets the normal map color input component
  66804. */
  66805. get normalMapColor(): NodeMaterialConnectionPoint;
  66806. /**
  66807. * Gets the strength input component
  66808. */
  66809. get strength(): NodeMaterialConnectionPoint;
  66810. /**
  66811. * Gets the output component
  66812. */
  66813. get output(): NodeMaterialConnectionPoint;
  66814. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66815. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66816. autoConfigure(material: NodeMaterial): void;
  66817. protected _buildBlock(state: NodeMaterialBuildState): this;
  66818. protected _dumpPropertiesCode(): string;
  66819. serialize(): any;
  66820. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66821. }
  66822. }
  66823. declare module BABYLON {
  66824. /**
  66825. * Block used to discard a pixel if a value is smaller than a cutoff
  66826. */
  66827. export class DiscardBlock extends NodeMaterialBlock {
  66828. /**
  66829. * Create a new DiscardBlock
  66830. * @param name defines the block name
  66831. */
  66832. constructor(name: string);
  66833. /**
  66834. * Gets the current class name
  66835. * @returns the class name
  66836. */
  66837. getClassName(): string;
  66838. /**
  66839. * Gets the color input component
  66840. */
  66841. get value(): NodeMaterialConnectionPoint;
  66842. /**
  66843. * Gets the cutoff input component
  66844. */
  66845. get cutoff(): NodeMaterialConnectionPoint;
  66846. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66847. }
  66848. }
  66849. declare module BABYLON {
  66850. /**
  66851. * Block used to test if the fragment shader is front facing
  66852. */
  66853. export class FrontFacingBlock extends NodeMaterialBlock {
  66854. /**
  66855. * Creates a new FrontFacingBlock
  66856. * @param name defines the block name
  66857. */
  66858. constructor(name: string);
  66859. /**
  66860. * Gets the current class name
  66861. * @returns the class name
  66862. */
  66863. getClassName(): string;
  66864. /**
  66865. * Gets the output component
  66866. */
  66867. get output(): NodeMaterialConnectionPoint;
  66868. protected _buildBlock(state: NodeMaterialBuildState): this;
  66869. }
  66870. }
  66871. declare module BABYLON {
  66872. /**
  66873. * Block used to get the derivative value on x and y of a given input
  66874. */
  66875. export class DerivativeBlock extends NodeMaterialBlock {
  66876. /**
  66877. * Create a new DerivativeBlock
  66878. * @param name defines the block name
  66879. */
  66880. constructor(name: string);
  66881. /**
  66882. * Gets the current class name
  66883. * @returns the class name
  66884. */
  66885. getClassName(): string;
  66886. /**
  66887. * Gets the input component
  66888. */
  66889. get input(): NodeMaterialConnectionPoint;
  66890. /**
  66891. * Gets the derivative output on x
  66892. */
  66893. get dx(): NodeMaterialConnectionPoint;
  66894. /**
  66895. * Gets the derivative output on y
  66896. */
  66897. get dy(): NodeMaterialConnectionPoint;
  66898. protected _buildBlock(state: NodeMaterialBuildState): this;
  66899. }
  66900. }
  66901. declare module BABYLON {
  66902. /**
  66903. * Block used to make gl_FragCoord available
  66904. */
  66905. export class FragCoordBlock extends NodeMaterialBlock {
  66906. /**
  66907. * Creates a new FragCoordBlock
  66908. * @param name defines the block name
  66909. */
  66910. constructor(name: string);
  66911. /**
  66912. * Gets the current class name
  66913. * @returns the class name
  66914. */
  66915. getClassName(): string;
  66916. /**
  66917. * Gets the xy component
  66918. */
  66919. get xy(): NodeMaterialConnectionPoint;
  66920. /**
  66921. * Gets the xyz component
  66922. */
  66923. get xyz(): NodeMaterialConnectionPoint;
  66924. /**
  66925. * Gets the xyzw component
  66926. */
  66927. get xyzw(): NodeMaterialConnectionPoint;
  66928. /**
  66929. * Gets the x component
  66930. */
  66931. get x(): NodeMaterialConnectionPoint;
  66932. /**
  66933. * Gets the y component
  66934. */
  66935. get y(): NodeMaterialConnectionPoint;
  66936. /**
  66937. * Gets the z component
  66938. */
  66939. get z(): NodeMaterialConnectionPoint;
  66940. /**
  66941. * Gets the w component
  66942. */
  66943. get output(): NodeMaterialConnectionPoint;
  66944. protected writeOutputs(state: NodeMaterialBuildState): string;
  66945. protected _buildBlock(state: NodeMaterialBuildState): this;
  66946. }
  66947. }
  66948. declare module BABYLON {
  66949. /**
  66950. * Block used to get the screen sizes
  66951. */
  66952. export class ScreenSizeBlock extends NodeMaterialBlock {
  66953. private _varName;
  66954. private _scene;
  66955. /**
  66956. * Creates a new ScreenSizeBlock
  66957. * @param name defines the block name
  66958. */
  66959. constructor(name: string);
  66960. /**
  66961. * Gets the current class name
  66962. * @returns the class name
  66963. */
  66964. getClassName(): string;
  66965. /**
  66966. * Gets the xy component
  66967. */
  66968. get xy(): NodeMaterialConnectionPoint;
  66969. /**
  66970. * Gets the x component
  66971. */
  66972. get x(): NodeMaterialConnectionPoint;
  66973. /**
  66974. * Gets the y component
  66975. */
  66976. get y(): NodeMaterialConnectionPoint;
  66977. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66978. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66979. protected _buildBlock(state: NodeMaterialBuildState): this;
  66980. }
  66981. }
  66982. declare module BABYLON {
  66983. /**
  66984. * Block used to add support for scene fog
  66985. */
  66986. export class FogBlock extends NodeMaterialBlock {
  66987. private _fogDistanceName;
  66988. private _fogParameters;
  66989. /**
  66990. * Create a new FogBlock
  66991. * @param name defines the block name
  66992. */
  66993. constructor(name: string);
  66994. /**
  66995. * Gets the current class name
  66996. * @returns the class name
  66997. */
  66998. getClassName(): string;
  66999. /**
  67000. * Gets the world position input component
  67001. */
  67002. get worldPosition(): NodeMaterialConnectionPoint;
  67003. /**
  67004. * Gets the view input component
  67005. */
  67006. get view(): NodeMaterialConnectionPoint;
  67007. /**
  67008. * Gets the color input component
  67009. */
  67010. get input(): NodeMaterialConnectionPoint;
  67011. /**
  67012. * Gets the fog color input component
  67013. */
  67014. get fogColor(): NodeMaterialConnectionPoint;
  67015. /**
  67016. * Gets the output component
  67017. */
  67018. get output(): NodeMaterialConnectionPoint;
  67019. autoConfigure(material: NodeMaterial): void;
  67020. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67021. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67022. protected _buildBlock(state: NodeMaterialBuildState): this;
  67023. }
  67024. }
  67025. declare module BABYLON {
  67026. /**
  67027. * Block used to add light in the fragment shader
  67028. */
  67029. export class LightBlock extends NodeMaterialBlock {
  67030. private _lightId;
  67031. /**
  67032. * Gets or sets the light associated with this block
  67033. */
  67034. light: Nullable<Light>;
  67035. /**
  67036. * Create a new LightBlock
  67037. * @param name defines the block name
  67038. */
  67039. constructor(name: string);
  67040. /**
  67041. * Gets the current class name
  67042. * @returns the class name
  67043. */
  67044. getClassName(): string;
  67045. /**
  67046. * Gets the world position input component
  67047. */
  67048. get worldPosition(): NodeMaterialConnectionPoint;
  67049. /**
  67050. * Gets the world normal input component
  67051. */
  67052. get worldNormal(): NodeMaterialConnectionPoint;
  67053. /**
  67054. * Gets the camera (or eye) position component
  67055. */
  67056. get cameraPosition(): NodeMaterialConnectionPoint;
  67057. /**
  67058. * Gets the glossiness component
  67059. */
  67060. get glossiness(): NodeMaterialConnectionPoint;
  67061. /**
  67062. * Gets the glossinness power component
  67063. */
  67064. get glossPower(): NodeMaterialConnectionPoint;
  67065. /**
  67066. * Gets the diffuse color component
  67067. */
  67068. get diffuseColor(): NodeMaterialConnectionPoint;
  67069. /**
  67070. * Gets the specular color component
  67071. */
  67072. get specularColor(): NodeMaterialConnectionPoint;
  67073. /**
  67074. * Gets the view matrix component
  67075. */
  67076. get view(): NodeMaterialConnectionPoint;
  67077. /**
  67078. * Gets the diffuse output component
  67079. */
  67080. get diffuseOutput(): NodeMaterialConnectionPoint;
  67081. /**
  67082. * Gets the specular output component
  67083. */
  67084. get specularOutput(): NodeMaterialConnectionPoint;
  67085. /**
  67086. * Gets the shadow output component
  67087. */
  67088. get shadow(): NodeMaterialConnectionPoint;
  67089. autoConfigure(material: NodeMaterial): void;
  67090. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67091. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67092. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67093. private _injectVertexCode;
  67094. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67095. serialize(): any;
  67096. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67097. }
  67098. }
  67099. declare module BABYLON {
  67100. /**
  67101. * Block used to read a reflection texture from a sampler
  67102. */
  67103. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67104. /**
  67105. * Create a new ReflectionTextureBlock
  67106. * @param name defines the block name
  67107. */
  67108. constructor(name: string);
  67109. /**
  67110. * Gets the current class name
  67111. * @returns the class name
  67112. */
  67113. getClassName(): string;
  67114. /**
  67115. * Gets the world position input component
  67116. */
  67117. get position(): NodeMaterialConnectionPoint;
  67118. /**
  67119. * Gets the world position input component
  67120. */
  67121. get worldPosition(): NodeMaterialConnectionPoint;
  67122. /**
  67123. * Gets the world normal input component
  67124. */
  67125. get worldNormal(): NodeMaterialConnectionPoint;
  67126. /**
  67127. * Gets the world input component
  67128. */
  67129. get world(): NodeMaterialConnectionPoint;
  67130. /**
  67131. * Gets the camera (or eye) position component
  67132. */
  67133. get cameraPosition(): NodeMaterialConnectionPoint;
  67134. /**
  67135. * Gets the view input component
  67136. */
  67137. get view(): NodeMaterialConnectionPoint;
  67138. /**
  67139. * Gets the rgb output component
  67140. */
  67141. get rgb(): NodeMaterialConnectionPoint;
  67142. /**
  67143. * Gets the rgba output component
  67144. */
  67145. get rgba(): NodeMaterialConnectionPoint;
  67146. /**
  67147. * Gets the r output component
  67148. */
  67149. get r(): NodeMaterialConnectionPoint;
  67150. /**
  67151. * Gets the g output component
  67152. */
  67153. get g(): NodeMaterialConnectionPoint;
  67154. /**
  67155. * Gets the b output component
  67156. */
  67157. get b(): NodeMaterialConnectionPoint;
  67158. /**
  67159. * Gets the a output component
  67160. */
  67161. get a(): NodeMaterialConnectionPoint;
  67162. autoConfigure(material: NodeMaterial): void;
  67163. protected _buildBlock(state: NodeMaterialBuildState): this;
  67164. }
  67165. }
  67166. declare module BABYLON {
  67167. /**
  67168. * Block used to add 2 vectors
  67169. */
  67170. export class AddBlock extends NodeMaterialBlock {
  67171. /**
  67172. * Creates a new AddBlock
  67173. * @param name defines the block name
  67174. */
  67175. constructor(name: string);
  67176. /**
  67177. * Gets the current class name
  67178. * @returns the class name
  67179. */
  67180. getClassName(): string;
  67181. /**
  67182. * Gets the left operand input component
  67183. */
  67184. get left(): NodeMaterialConnectionPoint;
  67185. /**
  67186. * Gets the right operand input component
  67187. */
  67188. get right(): NodeMaterialConnectionPoint;
  67189. /**
  67190. * Gets the output component
  67191. */
  67192. get output(): NodeMaterialConnectionPoint;
  67193. protected _buildBlock(state: NodeMaterialBuildState): this;
  67194. }
  67195. }
  67196. declare module BABYLON {
  67197. /**
  67198. * Block used to scale a vector by a float
  67199. */
  67200. export class ScaleBlock extends NodeMaterialBlock {
  67201. /**
  67202. * Creates a new ScaleBlock
  67203. * @param name defines the block name
  67204. */
  67205. constructor(name: string);
  67206. /**
  67207. * Gets the current class name
  67208. * @returns the class name
  67209. */
  67210. getClassName(): string;
  67211. /**
  67212. * Gets the input component
  67213. */
  67214. get input(): NodeMaterialConnectionPoint;
  67215. /**
  67216. * Gets the factor input component
  67217. */
  67218. get factor(): NodeMaterialConnectionPoint;
  67219. /**
  67220. * Gets the output component
  67221. */
  67222. get output(): NodeMaterialConnectionPoint;
  67223. protected _buildBlock(state: NodeMaterialBuildState): this;
  67224. }
  67225. }
  67226. declare module BABYLON {
  67227. /**
  67228. * Block used to clamp a float
  67229. */
  67230. export class ClampBlock extends NodeMaterialBlock {
  67231. /** Gets or sets the minimum range */
  67232. minimum: number;
  67233. /** Gets or sets the maximum range */
  67234. maximum: number;
  67235. /**
  67236. * Creates a new ClampBlock
  67237. * @param name defines the block name
  67238. */
  67239. constructor(name: string);
  67240. /**
  67241. * Gets the current class name
  67242. * @returns the class name
  67243. */
  67244. getClassName(): string;
  67245. /**
  67246. * Gets the value input component
  67247. */
  67248. get value(): NodeMaterialConnectionPoint;
  67249. /**
  67250. * Gets the output component
  67251. */
  67252. get output(): NodeMaterialConnectionPoint;
  67253. protected _buildBlock(state: NodeMaterialBuildState): this;
  67254. protected _dumpPropertiesCode(): string;
  67255. serialize(): any;
  67256. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67257. }
  67258. }
  67259. declare module BABYLON {
  67260. /**
  67261. * Block used to apply a cross product between 2 vectors
  67262. */
  67263. export class CrossBlock extends NodeMaterialBlock {
  67264. /**
  67265. * Creates a new CrossBlock
  67266. * @param name defines the block name
  67267. */
  67268. constructor(name: string);
  67269. /**
  67270. * Gets the current class name
  67271. * @returns the class name
  67272. */
  67273. getClassName(): string;
  67274. /**
  67275. * Gets the left operand input component
  67276. */
  67277. get left(): NodeMaterialConnectionPoint;
  67278. /**
  67279. * Gets the right operand input component
  67280. */
  67281. get right(): NodeMaterialConnectionPoint;
  67282. /**
  67283. * Gets the output component
  67284. */
  67285. get output(): NodeMaterialConnectionPoint;
  67286. protected _buildBlock(state: NodeMaterialBuildState): this;
  67287. }
  67288. }
  67289. declare module BABYLON {
  67290. /**
  67291. * Block used to apply a dot product between 2 vectors
  67292. */
  67293. export class DotBlock extends NodeMaterialBlock {
  67294. /**
  67295. * Creates a new DotBlock
  67296. * @param name defines the block name
  67297. */
  67298. constructor(name: string);
  67299. /**
  67300. * Gets the current class name
  67301. * @returns the class name
  67302. */
  67303. getClassName(): string;
  67304. /**
  67305. * Gets the left operand input component
  67306. */
  67307. get left(): NodeMaterialConnectionPoint;
  67308. /**
  67309. * Gets the right operand input component
  67310. */
  67311. get right(): NodeMaterialConnectionPoint;
  67312. /**
  67313. * Gets the output component
  67314. */
  67315. get output(): NodeMaterialConnectionPoint;
  67316. protected _buildBlock(state: NodeMaterialBuildState): this;
  67317. }
  67318. }
  67319. declare module BABYLON {
  67320. /**
  67321. * Block used to normalize a vector
  67322. */
  67323. export class NormalizeBlock extends NodeMaterialBlock {
  67324. /**
  67325. * Creates a new NormalizeBlock
  67326. * @param name defines the block name
  67327. */
  67328. constructor(name: string);
  67329. /**
  67330. * Gets the current class name
  67331. * @returns the class name
  67332. */
  67333. getClassName(): string;
  67334. /**
  67335. * Gets the input component
  67336. */
  67337. get input(): NodeMaterialConnectionPoint;
  67338. /**
  67339. * Gets the output component
  67340. */
  67341. get output(): NodeMaterialConnectionPoint;
  67342. protected _buildBlock(state: NodeMaterialBuildState): this;
  67343. }
  67344. }
  67345. declare module BABYLON {
  67346. /**
  67347. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67348. */
  67349. export class ColorMergerBlock extends NodeMaterialBlock {
  67350. /**
  67351. * Create a new ColorMergerBlock
  67352. * @param name defines the block name
  67353. */
  67354. constructor(name: string);
  67355. /**
  67356. * Gets the current class name
  67357. * @returns the class name
  67358. */
  67359. getClassName(): string;
  67360. /**
  67361. * Gets the rgb component (input)
  67362. */
  67363. get rgbIn(): NodeMaterialConnectionPoint;
  67364. /**
  67365. * Gets the r component (input)
  67366. */
  67367. get r(): NodeMaterialConnectionPoint;
  67368. /**
  67369. * Gets the g component (input)
  67370. */
  67371. get g(): NodeMaterialConnectionPoint;
  67372. /**
  67373. * Gets the b component (input)
  67374. */
  67375. get b(): NodeMaterialConnectionPoint;
  67376. /**
  67377. * Gets the a component (input)
  67378. */
  67379. get a(): NodeMaterialConnectionPoint;
  67380. /**
  67381. * Gets the rgba component (output)
  67382. */
  67383. get rgba(): NodeMaterialConnectionPoint;
  67384. /**
  67385. * Gets the rgb component (output)
  67386. */
  67387. get rgbOut(): NodeMaterialConnectionPoint;
  67388. /**
  67389. * Gets the rgb component (output)
  67390. * @deprecated Please use rgbOut instead.
  67391. */
  67392. get rgb(): NodeMaterialConnectionPoint;
  67393. protected _buildBlock(state: NodeMaterialBuildState): this;
  67394. }
  67395. }
  67396. declare module BABYLON {
  67397. /**
  67398. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67399. */
  67400. export class VectorSplitterBlock extends NodeMaterialBlock {
  67401. /**
  67402. * Create a new VectorSplitterBlock
  67403. * @param name defines the block name
  67404. */
  67405. constructor(name: string);
  67406. /**
  67407. * Gets the current class name
  67408. * @returns the class name
  67409. */
  67410. getClassName(): string;
  67411. /**
  67412. * Gets the xyzw component (input)
  67413. */
  67414. get xyzw(): NodeMaterialConnectionPoint;
  67415. /**
  67416. * Gets the xyz component (input)
  67417. */
  67418. get xyzIn(): NodeMaterialConnectionPoint;
  67419. /**
  67420. * Gets the xy component (input)
  67421. */
  67422. get xyIn(): NodeMaterialConnectionPoint;
  67423. /**
  67424. * Gets the xyz component (output)
  67425. */
  67426. get xyzOut(): NodeMaterialConnectionPoint;
  67427. /**
  67428. * Gets the xy component (output)
  67429. */
  67430. get xyOut(): NodeMaterialConnectionPoint;
  67431. /**
  67432. * Gets the x component (output)
  67433. */
  67434. get x(): NodeMaterialConnectionPoint;
  67435. /**
  67436. * Gets the y component (output)
  67437. */
  67438. get y(): NodeMaterialConnectionPoint;
  67439. /**
  67440. * Gets the z component (output)
  67441. */
  67442. get z(): NodeMaterialConnectionPoint;
  67443. /**
  67444. * Gets the w component (output)
  67445. */
  67446. get w(): NodeMaterialConnectionPoint;
  67447. protected _inputRename(name: string): string;
  67448. protected _outputRename(name: string): string;
  67449. protected _buildBlock(state: NodeMaterialBuildState): this;
  67450. }
  67451. }
  67452. declare module BABYLON {
  67453. /**
  67454. * Block used to lerp between 2 values
  67455. */
  67456. export class LerpBlock extends NodeMaterialBlock {
  67457. /**
  67458. * Creates a new LerpBlock
  67459. * @param name defines the block name
  67460. */
  67461. constructor(name: string);
  67462. /**
  67463. * Gets the current class name
  67464. * @returns the class name
  67465. */
  67466. getClassName(): string;
  67467. /**
  67468. * Gets the left operand input component
  67469. */
  67470. get left(): NodeMaterialConnectionPoint;
  67471. /**
  67472. * Gets the right operand input component
  67473. */
  67474. get right(): NodeMaterialConnectionPoint;
  67475. /**
  67476. * Gets the gradient operand input component
  67477. */
  67478. get gradient(): NodeMaterialConnectionPoint;
  67479. /**
  67480. * Gets the output component
  67481. */
  67482. get output(): NodeMaterialConnectionPoint;
  67483. protected _buildBlock(state: NodeMaterialBuildState): this;
  67484. }
  67485. }
  67486. declare module BABYLON {
  67487. /**
  67488. * Block used to divide 2 vectors
  67489. */
  67490. export class DivideBlock extends NodeMaterialBlock {
  67491. /**
  67492. * Creates a new DivideBlock
  67493. * @param name defines the block name
  67494. */
  67495. constructor(name: string);
  67496. /**
  67497. * Gets the current class name
  67498. * @returns the class name
  67499. */
  67500. getClassName(): string;
  67501. /**
  67502. * Gets the left operand input component
  67503. */
  67504. get left(): NodeMaterialConnectionPoint;
  67505. /**
  67506. * Gets the right operand input component
  67507. */
  67508. get right(): NodeMaterialConnectionPoint;
  67509. /**
  67510. * Gets the output component
  67511. */
  67512. get output(): NodeMaterialConnectionPoint;
  67513. protected _buildBlock(state: NodeMaterialBuildState): this;
  67514. }
  67515. }
  67516. declare module BABYLON {
  67517. /**
  67518. * Block used to subtract 2 vectors
  67519. */
  67520. export class SubtractBlock extends NodeMaterialBlock {
  67521. /**
  67522. * Creates a new SubtractBlock
  67523. * @param name defines the block name
  67524. */
  67525. constructor(name: string);
  67526. /**
  67527. * Gets the current class name
  67528. * @returns the class name
  67529. */
  67530. getClassName(): string;
  67531. /**
  67532. * Gets the left operand input component
  67533. */
  67534. get left(): NodeMaterialConnectionPoint;
  67535. /**
  67536. * Gets the right operand input component
  67537. */
  67538. get right(): NodeMaterialConnectionPoint;
  67539. /**
  67540. * Gets the output component
  67541. */
  67542. get output(): NodeMaterialConnectionPoint;
  67543. protected _buildBlock(state: NodeMaterialBuildState): this;
  67544. }
  67545. }
  67546. declare module BABYLON {
  67547. /**
  67548. * Block used to step a value
  67549. */
  67550. export class StepBlock extends NodeMaterialBlock {
  67551. /**
  67552. * Creates a new StepBlock
  67553. * @param name defines the block name
  67554. */
  67555. constructor(name: string);
  67556. /**
  67557. * Gets the current class name
  67558. * @returns the class name
  67559. */
  67560. getClassName(): string;
  67561. /**
  67562. * Gets the value operand input component
  67563. */
  67564. get value(): NodeMaterialConnectionPoint;
  67565. /**
  67566. * Gets the edge operand input component
  67567. */
  67568. get edge(): NodeMaterialConnectionPoint;
  67569. /**
  67570. * Gets the output component
  67571. */
  67572. get output(): NodeMaterialConnectionPoint;
  67573. protected _buildBlock(state: NodeMaterialBuildState): this;
  67574. }
  67575. }
  67576. declare module BABYLON {
  67577. /**
  67578. * Block used to get the opposite (1 - x) of a value
  67579. */
  67580. export class OneMinusBlock extends NodeMaterialBlock {
  67581. /**
  67582. * Creates a new OneMinusBlock
  67583. * @param name defines the block name
  67584. */
  67585. constructor(name: string);
  67586. /**
  67587. * Gets the current class name
  67588. * @returns the class name
  67589. */
  67590. getClassName(): string;
  67591. /**
  67592. * Gets the input component
  67593. */
  67594. get input(): NodeMaterialConnectionPoint;
  67595. /**
  67596. * Gets the output component
  67597. */
  67598. get output(): NodeMaterialConnectionPoint;
  67599. protected _buildBlock(state: NodeMaterialBuildState): this;
  67600. }
  67601. }
  67602. declare module BABYLON {
  67603. /**
  67604. * Block used to get the view direction
  67605. */
  67606. export class ViewDirectionBlock extends NodeMaterialBlock {
  67607. /**
  67608. * Creates a new ViewDirectionBlock
  67609. * @param name defines the block name
  67610. */
  67611. constructor(name: string);
  67612. /**
  67613. * Gets the current class name
  67614. * @returns the class name
  67615. */
  67616. getClassName(): string;
  67617. /**
  67618. * Gets the world position component
  67619. */
  67620. get worldPosition(): NodeMaterialConnectionPoint;
  67621. /**
  67622. * Gets the camera position component
  67623. */
  67624. get cameraPosition(): NodeMaterialConnectionPoint;
  67625. /**
  67626. * Gets the output component
  67627. */
  67628. get output(): NodeMaterialConnectionPoint;
  67629. autoConfigure(material: NodeMaterial): void;
  67630. protected _buildBlock(state: NodeMaterialBuildState): this;
  67631. }
  67632. }
  67633. declare module BABYLON {
  67634. /**
  67635. * Block used to compute fresnel value
  67636. */
  67637. export class FresnelBlock extends NodeMaterialBlock {
  67638. /**
  67639. * Create a new FresnelBlock
  67640. * @param name defines the block name
  67641. */
  67642. constructor(name: string);
  67643. /**
  67644. * Gets the current class name
  67645. * @returns the class name
  67646. */
  67647. getClassName(): string;
  67648. /**
  67649. * Gets the world normal input component
  67650. */
  67651. get worldNormal(): NodeMaterialConnectionPoint;
  67652. /**
  67653. * Gets the view direction input component
  67654. */
  67655. get viewDirection(): NodeMaterialConnectionPoint;
  67656. /**
  67657. * Gets the bias input component
  67658. */
  67659. get bias(): NodeMaterialConnectionPoint;
  67660. /**
  67661. * Gets the camera (or eye) position component
  67662. */
  67663. get power(): NodeMaterialConnectionPoint;
  67664. /**
  67665. * Gets the fresnel output component
  67666. */
  67667. get fresnel(): NodeMaterialConnectionPoint;
  67668. autoConfigure(material: NodeMaterial): void;
  67669. protected _buildBlock(state: NodeMaterialBuildState): this;
  67670. }
  67671. }
  67672. declare module BABYLON {
  67673. /**
  67674. * Block used to get the max of 2 values
  67675. */
  67676. export class MaxBlock extends NodeMaterialBlock {
  67677. /**
  67678. * Creates a new MaxBlock
  67679. * @param name defines the block name
  67680. */
  67681. constructor(name: string);
  67682. /**
  67683. * Gets the current class name
  67684. * @returns the class name
  67685. */
  67686. getClassName(): string;
  67687. /**
  67688. * Gets the left operand input component
  67689. */
  67690. get left(): NodeMaterialConnectionPoint;
  67691. /**
  67692. * Gets the right operand input component
  67693. */
  67694. get right(): NodeMaterialConnectionPoint;
  67695. /**
  67696. * Gets the output component
  67697. */
  67698. get output(): NodeMaterialConnectionPoint;
  67699. protected _buildBlock(state: NodeMaterialBuildState): this;
  67700. }
  67701. }
  67702. declare module BABYLON {
  67703. /**
  67704. * Block used to get the min of 2 values
  67705. */
  67706. export class MinBlock extends NodeMaterialBlock {
  67707. /**
  67708. * Creates a new MinBlock
  67709. * @param name defines the block name
  67710. */
  67711. constructor(name: string);
  67712. /**
  67713. * Gets the current class name
  67714. * @returns the class name
  67715. */
  67716. getClassName(): string;
  67717. /**
  67718. * Gets the left operand input component
  67719. */
  67720. get left(): NodeMaterialConnectionPoint;
  67721. /**
  67722. * Gets the right operand input component
  67723. */
  67724. get right(): NodeMaterialConnectionPoint;
  67725. /**
  67726. * Gets the output component
  67727. */
  67728. get output(): NodeMaterialConnectionPoint;
  67729. protected _buildBlock(state: NodeMaterialBuildState): this;
  67730. }
  67731. }
  67732. declare module BABYLON {
  67733. /**
  67734. * Block used to get the distance between 2 values
  67735. */
  67736. export class DistanceBlock extends NodeMaterialBlock {
  67737. /**
  67738. * Creates a new DistanceBlock
  67739. * @param name defines the block name
  67740. */
  67741. constructor(name: string);
  67742. /**
  67743. * Gets the current class name
  67744. * @returns the class name
  67745. */
  67746. getClassName(): string;
  67747. /**
  67748. * Gets the left operand input component
  67749. */
  67750. get left(): NodeMaterialConnectionPoint;
  67751. /**
  67752. * Gets the right operand input component
  67753. */
  67754. get right(): NodeMaterialConnectionPoint;
  67755. /**
  67756. * Gets the output component
  67757. */
  67758. get output(): NodeMaterialConnectionPoint;
  67759. protected _buildBlock(state: NodeMaterialBuildState): this;
  67760. }
  67761. }
  67762. declare module BABYLON {
  67763. /**
  67764. * Block used to get the length of a vector
  67765. */
  67766. export class LengthBlock extends NodeMaterialBlock {
  67767. /**
  67768. * Creates a new LengthBlock
  67769. * @param name defines the block name
  67770. */
  67771. constructor(name: string);
  67772. /**
  67773. * Gets the current class name
  67774. * @returns the class name
  67775. */
  67776. getClassName(): string;
  67777. /**
  67778. * Gets the value input component
  67779. */
  67780. get value(): NodeMaterialConnectionPoint;
  67781. /**
  67782. * Gets the output component
  67783. */
  67784. get output(): NodeMaterialConnectionPoint;
  67785. protected _buildBlock(state: NodeMaterialBuildState): this;
  67786. }
  67787. }
  67788. declare module BABYLON {
  67789. /**
  67790. * Block used to get negative version of a value (i.e. x * -1)
  67791. */
  67792. export class NegateBlock extends NodeMaterialBlock {
  67793. /**
  67794. * Creates a new NegateBlock
  67795. * @param name defines the block name
  67796. */
  67797. constructor(name: string);
  67798. /**
  67799. * Gets the current class name
  67800. * @returns the class name
  67801. */
  67802. getClassName(): string;
  67803. /**
  67804. * Gets the value input component
  67805. */
  67806. get value(): NodeMaterialConnectionPoint;
  67807. /**
  67808. * Gets the output component
  67809. */
  67810. get output(): NodeMaterialConnectionPoint;
  67811. protected _buildBlock(state: NodeMaterialBuildState): this;
  67812. }
  67813. }
  67814. declare module BABYLON {
  67815. /**
  67816. * Block used to get the value of the first parameter raised to the power of the second
  67817. */
  67818. export class PowBlock extends NodeMaterialBlock {
  67819. /**
  67820. * Creates a new PowBlock
  67821. * @param name defines the block name
  67822. */
  67823. constructor(name: string);
  67824. /**
  67825. * Gets the current class name
  67826. * @returns the class name
  67827. */
  67828. getClassName(): string;
  67829. /**
  67830. * Gets the value operand input component
  67831. */
  67832. get value(): NodeMaterialConnectionPoint;
  67833. /**
  67834. * Gets the power operand input component
  67835. */
  67836. get power(): NodeMaterialConnectionPoint;
  67837. /**
  67838. * Gets the output component
  67839. */
  67840. get output(): NodeMaterialConnectionPoint;
  67841. protected _buildBlock(state: NodeMaterialBuildState): this;
  67842. }
  67843. }
  67844. declare module BABYLON {
  67845. /**
  67846. * Block used to get a random number
  67847. */
  67848. export class RandomNumberBlock extends NodeMaterialBlock {
  67849. /**
  67850. * Creates a new RandomNumberBlock
  67851. * @param name defines the block name
  67852. */
  67853. constructor(name: string);
  67854. /**
  67855. * Gets the current class name
  67856. * @returns the class name
  67857. */
  67858. getClassName(): string;
  67859. /**
  67860. * Gets the seed input component
  67861. */
  67862. get seed(): 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 compute arc tangent of 2 values
  67873. */
  67874. export class ArcTan2Block extends NodeMaterialBlock {
  67875. /**
  67876. * Creates a new ArcTan2Block
  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 x operand input component
  67887. */
  67888. get x(): NodeMaterialConnectionPoint;
  67889. /**
  67890. * Gets the y operand input component
  67891. */
  67892. get y(): 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 smooth step a value
  67903. */
  67904. export class SmoothStepBlock extends NodeMaterialBlock {
  67905. /**
  67906. * Creates a new SmoothStepBlock
  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 value operand input component
  67917. */
  67918. get value(): NodeMaterialConnectionPoint;
  67919. /**
  67920. * Gets the first edge operand input component
  67921. */
  67922. get edge0(): NodeMaterialConnectionPoint;
  67923. /**
  67924. * Gets the second edge operand input component
  67925. */
  67926. get edge1(): NodeMaterialConnectionPoint;
  67927. /**
  67928. * Gets the output component
  67929. */
  67930. get output(): NodeMaterialConnectionPoint;
  67931. protected _buildBlock(state: NodeMaterialBuildState): this;
  67932. }
  67933. }
  67934. declare module BABYLON {
  67935. /**
  67936. * Block used to get the reciprocal (1 / x) of a value
  67937. */
  67938. export class ReciprocalBlock extends NodeMaterialBlock {
  67939. /**
  67940. * Creates a new ReciprocalBlock
  67941. * @param name defines the block name
  67942. */
  67943. constructor(name: string);
  67944. /**
  67945. * Gets the current class name
  67946. * @returns the class name
  67947. */
  67948. getClassName(): string;
  67949. /**
  67950. * Gets the input component
  67951. */
  67952. get input(): NodeMaterialConnectionPoint;
  67953. /**
  67954. * Gets the output component
  67955. */
  67956. get output(): NodeMaterialConnectionPoint;
  67957. protected _buildBlock(state: NodeMaterialBuildState): this;
  67958. }
  67959. }
  67960. declare module BABYLON {
  67961. /**
  67962. * Block used to replace a color by another one
  67963. */
  67964. export class ReplaceColorBlock extends NodeMaterialBlock {
  67965. /**
  67966. * Creates a new ReplaceColorBlock
  67967. * @param name defines the block name
  67968. */
  67969. constructor(name: string);
  67970. /**
  67971. * Gets the current class name
  67972. * @returns the class name
  67973. */
  67974. getClassName(): string;
  67975. /**
  67976. * Gets the value input component
  67977. */
  67978. get value(): NodeMaterialConnectionPoint;
  67979. /**
  67980. * Gets the reference input component
  67981. */
  67982. get reference(): NodeMaterialConnectionPoint;
  67983. /**
  67984. * Gets the distance input component
  67985. */
  67986. get distance(): NodeMaterialConnectionPoint;
  67987. /**
  67988. * Gets the replacement input component
  67989. */
  67990. get replacement(): NodeMaterialConnectionPoint;
  67991. /**
  67992. * Gets the output component
  67993. */
  67994. get output(): NodeMaterialConnectionPoint;
  67995. protected _buildBlock(state: NodeMaterialBuildState): this;
  67996. }
  67997. }
  67998. declare module BABYLON {
  67999. /**
  68000. * Block used to posterize a value
  68001. * @see https://en.wikipedia.org/wiki/Posterization
  68002. */
  68003. export class PosterizeBlock extends NodeMaterialBlock {
  68004. /**
  68005. * Creates a new PosterizeBlock
  68006. * @param name defines the block name
  68007. */
  68008. constructor(name: string);
  68009. /**
  68010. * Gets the current class name
  68011. * @returns the class name
  68012. */
  68013. getClassName(): string;
  68014. /**
  68015. * Gets the value input component
  68016. */
  68017. get value(): NodeMaterialConnectionPoint;
  68018. /**
  68019. * Gets the steps input component
  68020. */
  68021. get steps(): NodeMaterialConnectionPoint;
  68022. /**
  68023. * Gets the output component
  68024. */
  68025. get output(): NodeMaterialConnectionPoint;
  68026. protected _buildBlock(state: NodeMaterialBuildState): this;
  68027. }
  68028. }
  68029. declare module BABYLON {
  68030. /**
  68031. * Operations supported by the Wave block
  68032. */
  68033. export enum WaveBlockKind {
  68034. /** SawTooth */
  68035. SawTooth = 0,
  68036. /** Square */
  68037. Square = 1,
  68038. /** Triangle */
  68039. Triangle = 2
  68040. }
  68041. /**
  68042. * Block used to apply wave operation to floats
  68043. */
  68044. export class WaveBlock extends NodeMaterialBlock {
  68045. /**
  68046. * Gets or sets the kibnd of wave to be applied by the block
  68047. */
  68048. kind: WaveBlockKind;
  68049. /**
  68050. * Creates a new WaveBlock
  68051. * @param name defines the block name
  68052. */
  68053. constructor(name: string);
  68054. /**
  68055. * Gets the current class name
  68056. * @returns the class name
  68057. */
  68058. getClassName(): string;
  68059. /**
  68060. * Gets the input component
  68061. */
  68062. get input(): NodeMaterialConnectionPoint;
  68063. /**
  68064. * Gets the output component
  68065. */
  68066. get output(): NodeMaterialConnectionPoint;
  68067. protected _buildBlock(state: NodeMaterialBuildState): this;
  68068. serialize(): any;
  68069. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68070. }
  68071. }
  68072. declare module BABYLON {
  68073. /**
  68074. * Class used to store a color step for the GradientBlock
  68075. */
  68076. export class GradientBlockColorStep {
  68077. private _step;
  68078. /**
  68079. * Gets value indicating which step this color is associated with (between 0 and 1)
  68080. */
  68081. get step(): number;
  68082. /**
  68083. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68084. */
  68085. set step(val: number);
  68086. private _color;
  68087. /**
  68088. * Gets the color associated with this step
  68089. */
  68090. get color(): Color3;
  68091. /**
  68092. * Sets the color associated with this step
  68093. */
  68094. set color(val: Color3);
  68095. /**
  68096. * Creates a new GradientBlockColorStep
  68097. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68098. * @param color defines the color associated with this step
  68099. */
  68100. constructor(step: number, color: Color3);
  68101. }
  68102. /**
  68103. * Block used to return a color from a gradient based on an input value between 0 and 1
  68104. */
  68105. export class GradientBlock extends NodeMaterialBlock {
  68106. /**
  68107. * Gets or sets the list of color steps
  68108. */
  68109. colorSteps: GradientBlockColorStep[];
  68110. /** Gets an observable raised when the value is changed */
  68111. onValueChangedObservable: Observable<GradientBlock>;
  68112. /** calls observable when the value is changed*/
  68113. colorStepsUpdated(): void;
  68114. /**
  68115. * Creates a new GradientBlock
  68116. * @param name defines the block name
  68117. */
  68118. constructor(name: string);
  68119. /**
  68120. * Gets the current class name
  68121. * @returns the class name
  68122. */
  68123. getClassName(): string;
  68124. /**
  68125. * Gets the gradient input component
  68126. */
  68127. get gradient(): NodeMaterialConnectionPoint;
  68128. /**
  68129. * Gets the output component
  68130. */
  68131. get output(): NodeMaterialConnectionPoint;
  68132. private _writeColorConstant;
  68133. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68134. serialize(): any;
  68135. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68136. protected _dumpPropertiesCode(): string;
  68137. }
  68138. }
  68139. declare module BABYLON {
  68140. /**
  68141. * Block used to normalize lerp between 2 values
  68142. */
  68143. export class NLerpBlock extends NodeMaterialBlock {
  68144. /**
  68145. * Creates a new NLerpBlock
  68146. * @param name defines the block name
  68147. */
  68148. constructor(name: string);
  68149. /**
  68150. * Gets the current class name
  68151. * @returns the class name
  68152. */
  68153. getClassName(): string;
  68154. /**
  68155. * Gets the left operand input component
  68156. */
  68157. get left(): NodeMaterialConnectionPoint;
  68158. /**
  68159. * Gets the right operand input component
  68160. */
  68161. get right(): NodeMaterialConnectionPoint;
  68162. /**
  68163. * Gets the gradient operand input component
  68164. */
  68165. get gradient(): NodeMaterialConnectionPoint;
  68166. /**
  68167. * Gets the output component
  68168. */
  68169. get output(): NodeMaterialConnectionPoint;
  68170. protected _buildBlock(state: NodeMaterialBuildState): this;
  68171. }
  68172. }
  68173. declare module BABYLON {
  68174. /**
  68175. * block used to Generate a Worley Noise 3D Noise Pattern
  68176. */
  68177. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68178. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68179. manhattanDistance: boolean;
  68180. /**
  68181. * Creates a new WorleyNoise3DBlock
  68182. * @param name defines the block name
  68183. */
  68184. constructor(name: string);
  68185. /**
  68186. * Gets the current class name
  68187. * @returns the class name
  68188. */
  68189. getClassName(): string;
  68190. /**
  68191. * Gets the seed input component
  68192. */
  68193. get seed(): NodeMaterialConnectionPoint;
  68194. /**
  68195. * Gets the jitter input component
  68196. */
  68197. get jitter(): NodeMaterialConnectionPoint;
  68198. /**
  68199. * Gets the output component
  68200. */
  68201. get output(): NodeMaterialConnectionPoint;
  68202. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68203. /**
  68204. * Exposes the properties to the UI?
  68205. */
  68206. protected _dumpPropertiesCode(): string;
  68207. /**
  68208. * Exposes the properties to the Seralize?
  68209. */
  68210. serialize(): any;
  68211. /**
  68212. * Exposes the properties to the deseralize?
  68213. */
  68214. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68215. }
  68216. }
  68217. declare module BABYLON {
  68218. /**
  68219. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68220. */
  68221. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68222. /**
  68223. * Creates a new SimplexPerlin3DBlock
  68224. * @param name defines the block name
  68225. */
  68226. constructor(name: string);
  68227. /**
  68228. * Gets the current class name
  68229. * @returns the class name
  68230. */
  68231. getClassName(): string;
  68232. /**
  68233. * Gets the seed operand input component
  68234. */
  68235. get seed(): NodeMaterialConnectionPoint;
  68236. /**
  68237. * Gets the output component
  68238. */
  68239. get output(): NodeMaterialConnectionPoint;
  68240. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68241. }
  68242. }
  68243. declare module BABYLON {
  68244. /**
  68245. * Block used to blend normals
  68246. */
  68247. export class NormalBlendBlock extends NodeMaterialBlock {
  68248. /**
  68249. * Creates a new NormalBlendBlock
  68250. * @param name defines the block name
  68251. */
  68252. constructor(name: string);
  68253. /**
  68254. * Gets the current class name
  68255. * @returns the class name
  68256. */
  68257. getClassName(): string;
  68258. /**
  68259. * Gets the first input component
  68260. */
  68261. get normalMap0(): NodeMaterialConnectionPoint;
  68262. /**
  68263. * Gets the second input component
  68264. */
  68265. get normalMap1(): NodeMaterialConnectionPoint;
  68266. /**
  68267. * Gets the output component
  68268. */
  68269. get output(): NodeMaterialConnectionPoint;
  68270. protected _buildBlock(state: NodeMaterialBuildState): this;
  68271. }
  68272. }
  68273. declare module BABYLON {
  68274. /**
  68275. * Block used to rotate a 2d vector by a given angle
  68276. */
  68277. export class Rotate2dBlock extends NodeMaterialBlock {
  68278. /**
  68279. * Creates a new Rotate2dBlock
  68280. * @param name defines the block name
  68281. */
  68282. constructor(name: string);
  68283. /**
  68284. * Gets the current class name
  68285. * @returns the class name
  68286. */
  68287. getClassName(): string;
  68288. /**
  68289. * Gets the input vector
  68290. */
  68291. get input(): NodeMaterialConnectionPoint;
  68292. /**
  68293. * Gets the input angle
  68294. */
  68295. get angle(): NodeMaterialConnectionPoint;
  68296. /**
  68297. * Gets the output component
  68298. */
  68299. get output(): NodeMaterialConnectionPoint;
  68300. autoConfigure(material: NodeMaterial): void;
  68301. protected _buildBlock(state: NodeMaterialBuildState): this;
  68302. }
  68303. }
  68304. declare module BABYLON {
  68305. /**
  68306. * Block used to get the reflected vector from a direction and a normal
  68307. */
  68308. export class ReflectBlock extends NodeMaterialBlock {
  68309. /**
  68310. * Creates a new ReflectBlock
  68311. * @param name defines the block name
  68312. */
  68313. constructor(name: string);
  68314. /**
  68315. * Gets the current class name
  68316. * @returns the class name
  68317. */
  68318. getClassName(): string;
  68319. /**
  68320. * Gets the incident component
  68321. */
  68322. get incident(): NodeMaterialConnectionPoint;
  68323. /**
  68324. * Gets the normal component
  68325. */
  68326. get normal(): NodeMaterialConnectionPoint;
  68327. /**
  68328. * Gets the output component
  68329. */
  68330. get output(): NodeMaterialConnectionPoint;
  68331. protected _buildBlock(state: NodeMaterialBuildState): this;
  68332. }
  68333. }
  68334. declare module BABYLON {
  68335. /**
  68336. * Block used to get the refracted vector from a direction and a normal
  68337. */
  68338. export class RefractBlock extends NodeMaterialBlock {
  68339. /**
  68340. * Creates a new RefractBlock
  68341. * @param name defines the block name
  68342. */
  68343. constructor(name: string);
  68344. /**
  68345. * Gets the current class name
  68346. * @returns the class name
  68347. */
  68348. getClassName(): string;
  68349. /**
  68350. * Gets the incident component
  68351. */
  68352. get incident(): NodeMaterialConnectionPoint;
  68353. /**
  68354. * Gets the normal component
  68355. */
  68356. get normal(): NodeMaterialConnectionPoint;
  68357. /**
  68358. * Gets the index of refraction component
  68359. */
  68360. get ior(): NodeMaterialConnectionPoint;
  68361. /**
  68362. * Gets the output component
  68363. */
  68364. get output(): NodeMaterialConnectionPoint;
  68365. protected _buildBlock(state: NodeMaterialBuildState): this;
  68366. }
  68367. }
  68368. declare module BABYLON {
  68369. /**
  68370. * Block used to desaturate a color
  68371. */
  68372. export class DesaturateBlock extends NodeMaterialBlock {
  68373. /**
  68374. * Creates a new DesaturateBlock
  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 color operand input component
  68385. */
  68386. get color(): NodeMaterialConnectionPoint;
  68387. /**
  68388. * Gets the level operand input component
  68389. */
  68390. get level(): NodeMaterialConnectionPoint;
  68391. /**
  68392. * Gets the output component
  68393. */
  68394. get output(): NodeMaterialConnectionPoint;
  68395. protected _buildBlock(state: NodeMaterialBuildState): this;
  68396. }
  68397. }
  68398. declare module BABYLON {
  68399. /**
  68400. * Block used to implement the reflection module of the PBR material
  68401. */
  68402. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68403. /** @hidden */
  68404. _defineLODReflectionAlpha: string;
  68405. /** @hidden */
  68406. _defineLinearSpecularReflection: string;
  68407. private _vEnvironmentIrradianceName;
  68408. /** @hidden */
  68409. _vReflectionMicrosurfaceInfosName: string;
  68410. /** @hidden */
  68411. _vReflectionInfosName: string;
  68412. /** @hidden */
  68413. _vReflectionFilteringInfoName: string;
  68414. private _scene;
  68415. /**
  68416. * The properties below are set by the main PBR block prior to calling methods of this class.
  68417. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68418. * It's less burden on the user side in the editor part.
  68419. */
  68420. /** @hidden */
  68421. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68422. /** @hidden */
  68423. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68424. /** @hidden */
  68425. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68426. /** @hidden */
  68427. viewConnectionPoint: NodeMaterialConnectionPoint;
  68428. /**
  68429. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68430. * diffuse part of the IBL.
  68431. */
  68432. useSphericalHarmonics: boolean;
  68433. /**
  68434. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68435. */
  68436. forceIrradianceInFragment: boolean;
  68437. /**
  68438. * Create a new ReflectionBlock
  68439. * @param name defines the block name
  68440. */
  68441. constructor(name: string);
  68442. /**
  68443. * Gets the current class name
  68444. * @returns the class name
  68445. */
  68446. getClassName(): string;
  68447. /**
  68448. * Gets the position input component
  68449. */
  68450. get position(): NodeMaterialConnectionPoint;
  68451. /**
  68452. * Gets the world position input component
  68453. */
  68454. get worldPosition(): NodeMaterialConnectionPoint;
  68455. /**
  68456. * Gets the world normal input component
  68457. */
  68458. get worldNormal(): NodeMaterialConnectionPoint;
  68459. /**
  68460. * Gets the world input component
  68461. */
  68462. get world(): NodeMaterialConnectionPoint;
  68463. /**
  68464. * Gets the camera (or eye) position component
  68465. */
  68466. get cameraPosition(): NodeMaterialConnectionPoint;
  68467. /**
  68468. * Gets the view input component
  68469. */
  68470. get view(): NodeMaterialConnectionPoint;
  68471. /**
  68472. * Gets the color input component
  68473. */
  68474. get color(): NodeMaterialConnectionPoint;
  68475. /**
  68476. * Gets the reflection object output component
  68477. */
  68478. get reflection(): NodeMaterialConnectionPoint;
  68479. /**
  68480. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68481. */
  68482. get hasTexture(): boolean;
  68483. /**
  68484. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68485. */
  68486. get reflectionColor(): string;
  68487. protected _getTexture(): Nullable<BaseTexture>;
  68488. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68489. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68490. /**
  68491. * Gets the code to inject in the vertex shader
  68492. * @param state current state of the node material building
  68493. * @returns the shader code
  68494. */
  68495. handleVertexSide(state: NodeMaterialBuildState): string;
  68496. /**
  68497. * Gets the main code of the block (fragment side)
  68498. * @param state current state of the node material building
  68499. * @param normalVarName name of the existing variable corresponding to the normal
  68500. * @returns the shader code
  68501. */
  68502. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68503. protected _buildBlock(state: NodeMaterialBuildState): this;
  68504. protected _dumpPropertiesCode(): string;
  68505. serialize(): any;
  68506. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68507. }
  68508. }
  68509. declare module BABYLON {
  68510. /**
  68511. * Block used to implement the sheen module of the PBR material
  68512. */
  68513. export class SheenBlock extends NodeMaterialBlock {
  68514. /**
  68515. * Create a new SheenBlock
  68516. * @param name defines the block name
  68517. */
  68518. constructor(name: string);
  68519. /**
  68520. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68521. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68522. * making it easier to setup and tweak the effect
  68523. */
  68524. albedoScaling: boolean;
  68525. /**
  68526. * Defines if the sheen is linked to the sheen color.
  68527. */
  68528. linkSheenWithAlbedo: boolean;
  68529. /**
  68530. * Initialize the block and prepare the context for build
  68531. * @param state defines the state that will be used for the build
  68532. */
  68533. initialize(state: NodeMaterialBuildState): void;
  68534. /**
  68535. * Gets the current class name
  68536. * @returns the class name
  68537. */
  68538. getClassName(): string;
  68539. /**
  68540. * Gets the intensity input component
  68541. */
  68542. get intensity(): NodeMaterialConnectionPoint;
  68543. /**
  68544. * Gets the color input component
  68545. */
  68546. get color(): NodeMaterialConnectionPoint;
  68547. /**
  68548. * Gets the roughness input component
  68549. */
  68550. get roughness(): NodeMaterialConnectionPoint;
  68551. /**
  68552. * Gets the sheen object output component
  68553. */
  68554. get sheen(): NodeMaterialConnectionPoint;
  68555. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68556. /**
  68557. * Gets the main code of the block (fragment side)
  68558. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68559. * @returns the shader code
  68560. */
  68561. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68562. protected _buildBlock(state: NodeMaterialBuildState): this;
  68563. protected _dumpPropertiesCode(): string;
  68564. serialize(): any;
  68565. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68566. }
  68567. }
  68568. declare module BABYLON {
  68569. /**
  68570. * Block used to implement the anisotropy module of the PBR material
  68571. */
  68572. export class AnisotropyBlock extends NodeMaterialBlock {
  68573. /**
  68574. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68575. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68576. * It's less burden on the user side in the editor part.
  68577. */
  68578. /** @hidden */
  68579. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68580. /** @hidden */
  68581. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68582. /**
  68583. * Create a new AnisotropyBlock
  68584. * @param name defines the block name
  68585. */
  68586. constructor(name: string);
  68587. /**
  68588. * Initialize the block and prepare the context for build
  68589. * @param state defines the state that will be used for the build
  68590. */
  68591. initialize(state: NodeMaterialBuildState): void;
  68592. /**
  68593. * Gets the current class name
  68594. * @returns the class name
  68595. */
  68596. getClassName(): string;
  68597. /**
  68598. * Gets the intensity input component
  68599. */
  68600. get intensity(): NodeMaterialConnectionPoint;
  68601. /**
  68602. * Gets the direction input component
  68603. */
  68604. get direction(): NodeMaterialConnectionPoint;
  68605. /**
  68606. * Gets the uv input component
  68607. */
  68608. get uv(): NodeMaterialConnectionPoint;
  68609. /**
  68610. * Gets the worldTangent input component
  68611. */
  68612. get worldTangent(): NodeMaterialConnectionPoint;
  68613. /**
  68614. * Gets the anisotropy object output component
  68615. */
  68616. get anisotropy(): NodeMaterialConnectionPoint;
  68617. private _generateTBNSpace;
  68618. /**
  68619. * Gets the main code of the block (fragment side)
  68620. * @param state current state of the node material building
  68621. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68622. * @returns the shader code
  68623. */
  68624. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68625. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68626. protected _buildBlock(state: NodeMaterialBuildState): this;
  68627. }
  68628. }
  68629. declare module BABYLON {
  68630. /**
  68631. * Block used to implement the clear coat module of the PBR material
  68632. */
  68633. export class ClearCoatBlock extends NodeMaterialBlock {
  68634. private _scene;
  68635. /**
  68636. * Create a new ClearCoatBlock
  68637. * @param name defines the block name
  68638. */
  68639. constructor(name: string);
  68640. /**
  68641. * Defines if the F0 value should be remapped to account for the interface change in the material.
  68642. */
  68643. remapF0OnInterfaceChange: boolean;
  68644. /**
  68645. * Initialize the block and prepare the context for build
  68646. * @param state defines the state that will be used for the build
  68647. */
  68648. initialize(state: NodeMaterialBuildState): void;
  68649. /**
  68650. * Gets the current class name
  68651. * @returns the class name
  68652. */
  68653. getClassName(): string;
  68654. /**
  68655. * Gets the intensity input component
  68656. */
  68657. get intensity(): NodeMaterialConnectionPoint;
  68658. /**
  68659. * Gets the roughness input component
  68660. */
  68661. get roughness(): NodeMaterialConnectionPoint;
  68662. /**
  68663. * Gets the ior input component
  68664. */
  68665. get indexOfRefraction(): NodeMaterialConnectionPoint;
  68666. /**
  68667. * Gets the bump texture input component
  68668. */
  68669. get normalMapColor(): NodeMaterialConnectionPoint;
  68670. /**
  68671. * Gets the uv input component
  68672. */
  68673. get uv(): NodeMaterialConnectionPoint;
  68674. /**
  68675. * Gets the tint color input component
  68676. */
  68677. get tintColor(): NodeMaterialConnectionPoint;
  68678. /**
  68679. * Gets the tint "at distance" input component
  68680. */
  68681. get tintAtDistance(): NodeMaterialConnectionPoint;
  68682. /**
  68683. * Gets the tint thickness input component
  68684. */
  68685. get tintThickness(): NodeMaterialConnectionPoint;
  68686. /**
  68687. * Gets the world tangent input component
  68688. */
  68689. get worldTangent(): NodeMaterialConnectionPoint;
  68690. /**
  68691. * Gets the clear coat object output component
  68692. */
  68693. get clearcoat(): NodeMaterialConnectionPoint;
  68694. autoConfigure(material: NodeMaterial): void;
  68695. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68696. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68697. private _generateTBNSpace;
  68698. /**
  68699. * Gets the main code of the block (fragment side)
  68700. * @param state current state of the node material building
  68701. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68702. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68703. * @param worldPosVarName name of the variable holding the world position
  68704. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68705. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68706. * @param worldNormalVarName name of the variable holding the world normal
  68707. * @returns the shader code
  68708. */
  68709. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68710. protected _buildBlock(state: NodeMaterialBuildState): this;
  68711. protected _dumpPropertiesCode(): string;
  68712. serialize(): any;
  68713. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68714. }
  68715. }
  68716. declare module BABYLON {
  68717. /**
  68718. * Block used to implement the sub surface module of the PBR material
  68719. */
  68720. export class SubSurfaceBlock extends NodeMaterialBlock {
  68721. /**
  68722. * Create a new SubSurfaceBlock
  68723. * @param name defines the block name
  68724. */
  68725. constructor(name: string);
  68726. /**
  68727. * Initialize the block and prepare the context for build
  68728. * @param state defines the state that will be used for the build
  68729. */
  68730. initialize(state: NodeMaterialBuildState): void;
  68731. /**
  68732. * Gets the current class name
  68733. * @returns the class name
  68734. */
  68735. getClassName(): string;
  68736. /**
  68737. * Gets the thickness component
  68738. */
  68739. get thickness(): NodeMaterialConnectionPoint;
  68740. /**
  68741. * Gets the tint color input component
  68742. */
  68743. get tintColor(): NodeMaterialConnectionPoint;
  68744. /**
  68745. * Gets the translucency intensity input component
  68746. */
  68747. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68748. /**
  68749. * Gets the translucency diffusion distance input component
  68750. */
  68751. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  68752. /**
  68753. * Gets the refraction object parameters
  68754. */
  68755. get refraction(): NodeMaterialConnectionPoint;
  68756. /**
  68757. * Gets the sub surface object output component
  68758. */
  68759. get subsurface(): NodeMaterialConnectionPoint;
  68760. autoConfigure(material: NodeMaterial): void;
  68761. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68762. /**
  68763. * Gets the main code of the block (fragment side)
  68764. * @param state current state of the node material building
  68765. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68766. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68767. * @param worldPosVarName name of the variable holding the world position
  68768. * @returns the shader code
  68769. */
  68770. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68771. protected _buildBlock(state: NodeMaterialBuildState): this;
  68772. }
  68773. }
  68774. declare module BABYLON {
  68775. /**
  68776. * Block used to implement the PBR metallic/roughness model
  68777. */
  68778. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68779. /**
  68780. * Gets or sets the light associated with this block
  68781. */
  68782. light: Nullable<Light>;
  68783. private _lightId;
  68784. private _scene;
  68785. private _environmentBRDFTexture;
  68786. private _environmentBrdfSamplerName;
  68787. private _vNormalWName;
  68788. private _invertNormalName;
  68789. private _metallicReflectanceColor;
  68790. private _metallicF0Factor;
  68791. private _vMetallicReflectanceFactorsName;
  68792. /**
  68793. * Create a new ReflectionBlock
  68794. * @param name defines the block name
  68795. */
  68796. constructor(name: string);
  68797. /**
  68798. * Intensity of the direct lights e.g. the four lights available in your scene.
  68799. * This impacts both the direct diffuse and specular highlights.
  68800. */
  68801. directIntensity: number;
  68802. /**
  68803. * Intensity of the environment e.g. how much the environment will light the object
  68804. * either through harmonics for rough material or through the refelction for shiny ones.
  68805. */
  68806. environmentIntensity: number;
  68807. /**
  68808. * This is a special control allowing the reduction of the specular highlights coming from the
  68809. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68810. */
  68811. specularIntensity: number;
  68812. /**
  68813. * Defines the falloff type used in this material.
  68814. * It by default is Physical.
  68815. */
  68816. lightFalloff: number;
  68817. /**
  68818. * Specifies that alpha test should be used
  68819. */
  68820. useAlphaTest: boolean;
  68821. /**
  68822. * Defines the alpha limits in alpha test mode.
  68823. */
  68824. alphaTestCutoff: number;
  68825. /**
  68826. * Specifies that alpha blending should be used
  68827. */
  68828. useAlphaBlending: boolean;
  68829. /**
  68830. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68831. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68832. */
  68833. useRadianceOverAlpha: boolean;
  68834. /**
  68835. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68836. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68837. */
  68838. useSpecularOverAlpha: boolean;
  68839. /**
  68840. * Enables specular anti aliasing in the PBR shader.
  68841. * It will both interacts on the Geometry for analytical and IBL lighting.
  68842. * It also prefilter the roughness map based on the bump values.
  68843. */
  68844. enableSpecularAntiAliasing: boolean;
  68845. /**
  68846. * Enables realtime filtering on the texture.
  68847. */
  68848. realTimeFiltering: boolean;
  68849. /**
  68850. * Quality switch for realtime filtering
  68851. */
  68852. realTimeFilteringQuality: number;
  68853. /**
  68854. * Defines if the material uses energy conservation.
  68855. */
  68856. useEnergyConservation: boolean;
  68857. /**
  68858. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68859. * too much the area relying on ambient texture to define their ambient occlusion.
  68860. */
  68861. useRadianceOcclusion: boolean;
  68862. /**
  68863. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68864. * makes the reflect vector face the model (under horizon).
  68865. */
  68866. useHorizonOcclusion: boolean;
  68867. /**
  68868. * If set to true, no lighting calculations will be applied.
  68869. */
  68870. unlit: boolean;
  68871. /**
  68872. * Force normal to face away from face.
  68873. */
  68874. forceNormalForward: boolean;
  68875. /**
  68876. * Defines the material debug mode.
  68877. * It helps seeing only some components of the material while troubleshooting.
  68878. */
  68879. debugMode: number;
  68880. /**
  68881. * Specify from where on screen the debug mode should start.
  68882. * The value goes from -1 (full screen) to 1 (not visible)
  68883. * It helps with side by side comparison against the final render
  68884. * This defaults to 0
  68885. */
  68886. debugLimit: number;
  68887. /**
  68888. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68889. * You can use the factor to better multiply the final value.
  68890. */
  68891. debugFactor: number;
  68892. /**
  68893. * Initialize the block and prepare the context for build
  68894. * @param state defines the state that will be used for the build
  68895. */
  68896. initialize(state: NodeMaterialBuildState): void;
  68897. /**
  68898. * Gets the current class name
  68899. * @returns the class name
  68900. */
  68901. getClassName(): string;
  68902. /**
  68903. * Gets the world position input component
  68904. */
  68905. get worldPosition(): NodeMaterialConnectionPoint;
  68906. /**
  68907. * Gets the world normal input component
  68908. */
  68909. get worldNormal(): NodeMaterialConnectionPoint;
  68910. /**
  68911. * Gets the view matrix parameter
  68912. */
  68913. get view(): NodeMaterialConnectionPoint;
  68914. /**
  68915. * Gets the camera position input component
  68916. */
  68917. get cameraPosition(): NodeMaterialConnectionPoint;
  68918. /**
  68919. * Gets the perturbed normal input component
  68920. */
  68921. get perturbedNormal(): NodeMaterialConnectionPoint;
  68922. /**
  68923. * Gets the base color input component
  68924. */
  68925. get baseColor(): NodeMaterialConnectionPoint;
  68926. /**
  68927. * Gets the metallic input component
  68928. */
  68929. get metallic(): NodeMaterialConnectionPoint;
  68930. /**
  68931. * Gets the roughness input component
  68932. */
  68933. get roughness(): NodeMaterialConnectionPoint;
  68934. /**
  68935. * Gets the ambient occlusion input component
  68936. */
  68937. get ambientOcc(): NodeMaterialConnectionPoint;
  68938. /**
  68939. * Gets the opacity input component
  68940. */
  68941. get opacity(): NodeMaterialConnectionPoint;
  68942. /**
  68943. * Gets the index of refraction input component
  68944. */
  68945. get indexOfRefraction(): NodeMaterialConnectionPoint;
  68946. /**
  68947. * Gets the ambient color input component
  68948. */
  68949. get ambientColor(): NodeMaterialConnectionPoint;
  68950. /**
  68951. * Gets the reflection object parameters
  68952. */
  68953. get reflection(): NodeMaterialConnectionPoint;
  68954. /**
  68955. * Gets the clear coat object parameters
  68956. */
  68957. get clearcoat(): NodeMaterialConnectionPoint;
  68958. /**
  68959. * Gets the sheen object parameters
  68960. */
  68961. get sheen(): NodeMaterialConnectionPoint;
  68962. /**
  68963. * Gets the sub surface object parameters
  68964. */
  68965. get subsurface(): NodeMaterialConnectionPoint;
  68966. /**
  68967. * Gets the anisotropy object parameters
  68968. */
  68969. get anisotropy(): NodeMaterialConnectionPoint;
  68970. /**
  68971. * Gets the ambient output component
  68972. */
  68973. get ambientClr(): NodeMaterialConnectionPoint;
  68974. /**
  68975. * Gets the diffuse output component
  68976. */
  68977. get diffuseDir(): NodeMaterialConnectionPoint;
  68978. /**
  68979. * Gets the specular output component
  68980. */
  68981. get specularDir(): NodeMaterialConnectionPoint;
  68982. /**
  68983. * Gets the clear coat output component
  68984. */
  68985. get clearcoatDir(): NodeMaterialConnectionPoint;
  68986. /**
  68987. * Gets the sheen output component
  68988. */
  68989. get sheenDir(): NodeMaterialConnectionPoint;
  68990. /**
  68991. * Gets the indirect diffuse output component
  68992. */
  68993. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68994. /**
  68995. * Gets the indirect specular output component
  68996. */
  68997. get specularIndirect(): NodeMaterialConnectionPoint;
  68998. /**
  68999. * Gets the indirect clear coat output component
  69000. */
  69001. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69002. /**
  69003. * Gets the indirect sheen output component
  69004. */
  69005. get sheenIndirect(): NodeMaterialConnectionPoint;
  69006. /**
  69007. * Gets the refraction output component
  69008. */
  69009. get refraction(): NodeMaterialConnectionPoint;
  69010. /**
  69011. * Gets the global lighting output component
  69012. */
  69013. get lighting(): NodeMaterialConnectionPoint;
  69014. /**
  69015. * Gets the shadow output component
  69016. */
  69017. get shadow(): NodeMaterialConnectionPoint;
  69018. /**
  69019. * Gets the alpha output component
  69020. */
  69021. get alpha(): NodeMaterialConnectionPoint;
  69022. autoConfigure(material: NodeMaterial): void;
  69023. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69024. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69025. isReady(): boolean;
  69026. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69027. private _injectVertexCode;
  69028. private _getAlbedoOpacityCode;
  69029. private _getAmbientOcclusionCode;
  69030. private _getReflectivityCode;
  69031. protected _buildBlock(state: NodeMaterialBuildState): this;
  69032. protected _dumpPropertiesCode(): string;
  69033. serialize(): any;
  69034. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69035. }
  69036. }
  69037. declare module BABYLON {
  69038. /**
  69039. * Block used to compute value of one parameter modulo another
  69040. */
  69041. export class ModBlock extends NodeMaterialBlock {
  69042. /**
  69043. * Creates a new ModBlock
  69044. * @param name defines the block name
  69045. */
  69046. constructor(name: string);
  69047. /**
  69048. * Gets the current class name
  69049. * @returns the class name
  69050. */
  69051. getClassName(): string;
  69052. /**
  69053. * Gets the left operand input component
  69054. */
  69055. get left(): NodeMaterialConnectionPoint;
  69056. /**
  69057. * Gets the right operand input component
  69058. */
  69059. get right(): NodeMaterialConnectionPoint;
  69060. /**
  69061. * Gets the output component
  69062. */
  69063. get output(): NodeMaterialConnectionPoint;
  69064. protected _buildBlock(state: NodeMaterialBuildState): this;
  69065. }
  69066. }
  69067. declare module BABYLON {
  69068. /**
  69069. * Configuration for Draco compression
  69070. */
  69071. export interface IDracoCompressionConfiguration {
  69072. /**
  69073. * Configuration for the decoder.
  69074. */
  69075. decoder: {
  69076. /**
  69077. * The url to the WebAssembly module.
  69078. */
  69079. wasmUrl?: string;
  69080. /**
  69081. * The url to the WebAssembly binary.
  69082. */
  69083. wasmBinaryUrl?: string;
  69084. /**
  69085. * The url to the fallback JavaScript module.
  69086. */
  69087. fallbackUrl?: string;
  69088. };
  69089. }
  69090. /**
  69091. * Draco compression (https://google.github.io/draco/)
  69092. *
  69093. * This class wraps the Draco module.
  69094. *
  69095. * **Encoder**
  69096. *
  69097. * The encoder is not currently implemented.
  69098. *
  69099. * **Decoder**
  69100. *
  69101. * 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.
  69102. *
  69103. * To update the configuration, use the following code:
  69104. * ```javascript
  69105. * DracoCompression.Configuration = {
  69106. * decoder: {
  69107. * wasmUrl: "<url to the WebAssembly library>",
  69108. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69109. * fallbackUrl: "<url to the fallback JavaScript library>",
  69110. * }
  69111. * };
  69112. * ```
  69113. *
  69114. * 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.
  69115. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69116. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69117. *
  69118. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69119. * ```javascript
  69120. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69121. * ```
  69122. *
  69123. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69124. */
  69125. export class DracoCompression implements IDisposable {
  69126. private _workerPoolPromise?;
  69127. private _decoderModulePromise?;
  69128. /**
  69129. * The configuration. Defaults to the following urls:
  69130. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69131. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69132. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69133. */
  69134. static Configuration: IDracoCompressionConfiguration;
  69135. /**
  69136. * Returns true if the decoder configuration is available.
  69137. */
  69138. static get DecoderAvailable(): boolean;
  69139. /**
  69140. * Default number of workers to create when creating the draco compression object.
  69141. */
  69142. static DefaultNumWorkers: number;
  69143. private static GetDefaultNumWorkers;
  69144. private static _Default;
  69145. /**
  69146. * Default instance for the draco compression object.
  69147. */
  69148. static get Default(): DracoCompression;
  69149. /**
  69150. * Constructor
  69151. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69152. */
  69153. constructor(numWorkers?: number);
  69154. /**
  69155. * Stop all async operations and release resources.
  69156. */
  69157. dispose(): void;
  69158. /**
  69159. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69160. * @returns a promise that resolves when ready
  69161. */
  69162. whenReadyAsync(): Promise<void>;
  69163. /**
  69164. * Decode Draco compressed mesh data to vertex data.
  69165. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69166. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69167. * @returns A promise that resolves with the decoded vertex data
  69168. */
  69169. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69170. [kind: string]: number;
  69171. }): Promise<VertexData>;
  69172. }
  69173. }
  69174. declare module BABYLON {
  69175. /**
  69176. * Class for building Constructive Solid Geometry
  69177. */
  69178. export class CSG {
  69179. private polygons;
  69180. /**
  69181. * The world matrix
  69182. */
  69183. matrix: Matrix;
  69184. /**
  69185. * Stores the position
  69186. */
  69187. position: Vector3;
  69188. /**
  69189. * Stores the rotation
  69190. */
  69191. rotation: Vector3;
  69192. /**
  69193. * Stores the rotation quaternion
  69194. */
  69195. rotationQuaternion: Nullable<Quaternion>;
  69196. /**
  69197. * Stores the scaling vector
  69198. */
  69199. scaling: Vector3;
  69200. /**
  69201. * Convert the Mesh to CSG
  69202. * @param mesh The Mesh to convert to CSG
  69203. * @returns A new CSG from the Mesh
  69204. */
  69205. static FromMesh(mesh: Mesh): CSG;
  69206. /**
  69207. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69208. * @param polygons Polygons used to construct a CSG solid
  69209. */
  69210. private static FromPolygons;
  69211. /**
  69212. * Clones, or makes a deep copy, of the CSG
  69213. * @returns A new CSG
  69214. */
  69215. clone(): CSG;
  69216. /**
  69217. * Unions this CSG with another CSG
  69218. * @param csg The CSG to union against this CSG
  69219. * @returns The unioned CSG
  69220. */
  69221. union(csg: CSG): CSG;
  69222. /**
  69223. * Unions this CSG with another CSG in place
  69224. * @param csg The CSG to union against this CSG
  69225. */
  69226. unionInPlace(csg: CSG): void;
  69227. /**
  69228. * Subtracts this CSG with another CSG
  69229. * @param csg The CSG to subtract against this CSG
  69230. * @returns A new CSG
  69231. */
  69232. subtract(csg: CSG): CSG;
  69233. /**
  69234. * Subtracts this CSG with another CSG in place
  69235. * @param csg The CSG to subtact against this CSG
  69236. */
  69237. subtractInPlace(csg: CSG): void;
  69238. /**
  69239. * Intersect this CSG with another CSG
  69240. * @param csg The CSG to intersect against this CSG
  69241. * @returns A new CSG
  69242. */
  69243. intersect(csg: CSG): CSG;
  69244. /**
  69245. * Intersects this CSG with another CSG in place
  69246. * @param csg The CSG to intersect against this CSG
  69247. */
  69248. intersectInPlace(csg: CSG): void;
  69249. /**
  69250. * Return a new CSG solid with solid and empty space switched. This solid is
  69251. * not modified.
  69252. * @returns A new CSG solid with solid and empty space switched
  69253. */
  69254. inverse(): CSG;
  69255. /**
  69256. * Inverses the CSG in place
  69257. */
  69258. inverseInPlace(): void;
  69259. /**
  69260. * This is used to keep meshes transformations so they can be restored
  69261. * when we build back a Babylon Mesh
  69262. * NB : All CSG operations are performed in world coordinates
  69263. * @param csg The CSG to copy the transform attributes from
  69264. * @returns This CSG
  69265. */
  69266. copyTransformAttributes(csg: CSG): CSG;
  69267. /**
  69268. * Build Raw mesh from CSG
  69269. * Coordinates here are in world space
  69270. * @param name The name of the mesh geometry
  69271. * @param scene The Scene
  69272. * @param keepSubMeshes Specifies if the submeshes should be kept
  69273. * @returns A new Mesh
  69274. */
  69275. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69276. /**
  69277. * Build Mesh from CSG taking material and transforms into account
  69278. * @param name The name of the Mesh
  69279. * @param material The material of the Mesh
  69280. * @param scene The Scene
  69281. * @param keepSubMeshes Specifies if submeshes should be kept
  69282. * @returns The new Mesh
  69283. */
  69284. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69285. }
  69286. }
  69287. declare module BABYLON {
  69288. /**
  69289. * Class used to create a trail following a mesh
  69290. */
  69291. export class TrailMesh extends Mesh {
  69292. private _generator;
  69293. private _autoStart;
  69294. private _running;
  69295. private _diameter;
  69296. private _length;
  69297. private _sectionPolygonPointsCount;
  69298. private _sectionVectors;
  69299. private _sectionNormalVectors;
  69300. private _beforeRenderObserver;
  69301. /**
  69302. * @constructor
  69303. * @param name The value used by scene.getMeshByName() to do a lookup.
  69304. * @param generator The mesh or transform node to generate a trail.
  69305. * @param scene The scene to add this mesh to.
  69306. * @param diameter Diameter of trailing mesh. Default is 1.
  69307. * @param length Length of trailing mesh. Default is 60.
  69308. * @param autoStart Automatically start trailing mesh. Default true.
  69309. */
  69310. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69311. /**
  69312. * "TrailMesh"
  69313. * @returns "TrailMesh"
  69314. */
  69315. getClassName(): string;
  69316. private _createMesh;
  69317. /**
  69318. * Start trailing mesh.
  69319. */
  69320. start(): void;
  69321. /**
  69322. * Stop trailing mesh.
  69323. */
  69324. stop(): void;
  69325. /**
  69326. * Update trailing mesh geometry.
  69327. */
  69328. update(): void;
  69329. /**
  69330. * Returns a new TrailMesh object.
  69331. * @param name is a string, the name given to the new mesh
  69332. * @param newGenerator use new generator object for cloned trail mesh
  69333. * @returns a new mesh
  69334. */
  69335. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69336. /**
  69337. * Serializes this trail mesh
  69338. * @param serializationObject object to write serialization to
  69339. */
  69340. serialize(serializationObject: any): void;
  69341. /**
  69342. * Parses a serialized trail mesh
  69343. * @param parsedMesh the serialized mesh
  69344. * @param scene the scene to create the trail mesh in
  69345. * @returns the created trail mesh
  69346. */
  69347. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69348. }
  69349. }
  69350. declare module BABYLON {
  69351. /**
  69352. * Class containing static functions to help procedurally build meshes
  69353. */
  69354. export class TiledBoxBuilder {
  69355. /**
  69356. * Creates a box mesh
  69357. * 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)
  69358. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69360. * * 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
  69361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69362. * @param name defines the name of the mesh
  69363. * @param options defines the options used to create the mesh
  69364. * @param scene defines the hosting scene
  69365. * @returns the box mesh
  69366. */
  69367. static CreateTiledBox(name: string, options: {
  69368. pattern?: number;
  69369. width?: number;
  69370. height?: number;
  69371. depth?: number;
  69372. tileSize?: number;
  69373. tileWidth?: number;
  69374. tileHeight?: number;
  69375. alignHorizontal?: number;
  69376. alignVertical?: number;
  69377. faceUV?: Vector4[];
  69378. faceColors?: Color4[];
  69379. sideOrientation?: number;
  69380. updatable?: boolean;
  69381. }, scene?: Nullable<Scene>): Mesh;
  69382. }
  69383. }
  69384. declare module BABYLON {
  69385. /**
  69386. * Class containing static functions to help procedurally build meshes
  69387. */
  69388. export class TorusKnotBuilder {
  69389. /**
  69390. * Creates a torus knot mesh
  69391. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69392. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69393. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69394. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69395. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69396. * * 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
  69397. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69398. * @param name defines the name of the mesh
  69399. * @param options defines the options used to create the mesh
  69400. * @param scene defines the hosting scene
  69401. * @returns the torus knot mesh
  69402. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69403. */
  69404. static CreateTorusKnot(name: string, options: {
  69405. radius?: number;
  69406. tube?: number;
  69407. radialSegments?: number;
  69408. tubularSegments?: number;
  69409. p?: number;
  69410. q?: number;
  69411. updatable?: boolean;
  69412. sideOrientation?: number;
  69413. frontUVs?: Vector4;
  69414. backUVs?: Vector4;
  69415. }, scene: any): Mesh;
  69416. }
  69417. }
  69418. declare module BABYLON {
  69419. /**
  69420. * Polygon
  69421. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69422. */
  69423. export class Polygon {
  69424. /**
  69425. * Creates a rectangle
  69426. * @param xmin bottom X coord
  69427. * @param ymin bottom Y coord
  69428. * @param xmax top X coord
  69429. * @param ymax top Y coord
  69430. * @returns points that make the resulting rectation
  69431. */
  69432. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69433. /**
  69434. * Creates a circle
  69435. * @param radius radius of circle
  69436. * @param cx scale in x
  69437. * @param cy scale in y
  69438. * @param numberOfSides number of sides that make up the circle
  69439. * @returns points that make the resulting circle
  69440. */
  69441. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69442. /**
  69443. * Creates a polygon from input string
  69444. * @param input Input polygon data
  69445. * @returns the parsed points
  69446. */
  69447. static Parse(input: string): Vector2[];
  69448. /**
  69449. * Starts building a polygon from x and y coordinates
  69450. * @param x x coordinate
  69451. * @param y y coordinate
  69452. * @returns the started path2
  69453. */
  69454. static StartingAt(x: number, y: number): Path2;
  69455. }
  69456. /**
  69457. * Builds a polygon
  69458. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69459. */
  69460. export class PolygonMeshBuilder {
  69461. private _points;
  69462. private _outlinepoints;
  69463. private _holes;
  69464. private _name;
  69465. private _scene;
  69466. private _epoints;
  69467. private _eholes;
  69468. private _addToepoint;
  69469. /**
  69470. * Babylon reference to the earcut plugin.
  69471. */
  69472. bjsEarcut: any;
  69473. /**
  69474. * Creates a PolygonMeshBuilder
  69475. * @param name name of the builder
  69476. * @param contours Path of the polygon
  69477. * @param scene scene to add to when creating the mesh
  69478. * @param earcutInjection can be used to inject your own earcut reference
  69479. */
  69480. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69481. /**
  69482. * Adds a whole within the polygon
  69483. * @param hole Array of points defining the hole
  69484. * @returns this
  69485. */
  69486. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69487. /**
  69488. * Creates the polygon
  69489. * @param updatable If the mesh should be updatable
  69490. * @param depth The depth of the mesh created
  69491. * @returns the created mesh
  69492. */
  69493. build(updatable?: boolean, depth?: number): Mesh;
  69494. /**
  69495. * Creates the polygon
  69496. * @param depth The depth of the mesh created
  69497. * @returns the created VertexData
  69498. */
  69499. buildVertexData(depth?: number): VertexData;
  69500. /**
  69501. * Adds a side to the polygon
  69502. * @param positions points that make the polygon
  69503. * @param normals normals of the polygon
  69504. * @param uvs uvs of the polygon
  69505. * @param indices indices of the polygon
  69506. * @param bounds bounds of the polygon
  69507. * @param points points of the polygon
  69508. * @param depth depth of the polygon
  69509. * @param flip flip of the polygon
  69510. */
  69511. private addSide;
  69512. }
  69513. }
  69514. declare module BABYLON {
  69515. /**
  69516. * Class containing static functions to help procedurally build meshes
  69517. */
  69518. export class PolygonBuilder {
  69519. /**
  69520. * Creates a polygon mesh
  69521. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69522. * * 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
  69523. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69525. * * 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)
  69526. * * Remember you can only change the shape positions, not their number when updating a polygon
  69527. * @param name defines the name of the mesh
  69528. * @param options defines the options used to create the mesh
  69529. * @param scene defines the hosting scene
  69530. * @param earcutInjection can be used to inject your own earcut reference
  69531. * @returns the polygon mesh
  69532. */
  69533. static CreatePolygon(name: string, options: {
  69534. shape: Vector3[];
  69535. holes?: Vector3[][];
  69536. depth?: number;
  69537. faceUV?: Vector4[];
  69538. faceColors?: Color4[];
  69539. updatable?: boolean;
  69540. sideOrientation?: number;
  69541. frontUVs?: Vector4;
  69542. backUVs?: Vector4;
  69543. wrap?: boolean;
  69544. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69545. /**
  69546. * Creates an extruded polygon mesh, with depth in the Y direction.
  69547. * * 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)
  69548. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69549. * @param name defines the name of the mesh
  69550. * @param options defines the options used to create the mesh
  69551. * @param scene defines the hosting scene
  69552. * @param earcutInjection can be used to inject your own earcut reference
  69553. * @returns the polygon mesh
  69554. */
  69555. static ExtrudePolygon(name: string, options: {
  69556. shape: Vector3[];
  69557. holes?: Vector3[][];
  69558. depth?: number;
  69559. faceUV?: Vector4[];
  69560. faceColors?: Color4[];
  69561. updatable?: boolean;
  69562. sideOrientation?: number;
  69563. frontUVs?: Vector4;
  69564. backUVs?: Vector4;
  69565. wrap?: boolean;
  69566. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69567. }
  69568. }
  69569. declare module BABYLON {
  69570. /**
  69571. * Class containing static functions to help procedurally build meshes
  69572. */
  69573. export class LatheBuilder {
  69574. /**
  69575. * Creates lathe mesh.
  69576. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69577. * * 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
  69578. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69579. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69580. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69581. * * 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
  69582. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69583. * * 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
  69584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69585. * * 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
  69586. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69588. * @param name defines the name of the mesh
  69589. * @param options defines the options used to create the mesh
  69590. * @param scene defines the hosting scene
  69591. * @returns the lathe mesh
  69592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69593. */
  69594. static CreateLathe(name: string, options: {
  69595. shape: Vector3[];
  69596. radius?: number;
  69597. tessellation?: number;
  69598. clip?: number;
  69599. arc?: number;
  69600. closed?: boolean;
  69601. updatable?: boolean;
  69602. sideOrientation?: number;
  69603. frontUVs?: Vector4;
  69604. backUVs?: Vector4;
  69605. cap?: number;
  69606. invertUV?: boolean;
  69607. }, scene?: Nullable<Scene>): Mesh;
  69608. }
  69609. }
  69610. declare module BABYLON {
  69611. /**
  69612. * Class containing static functions to help procedurally build meshes
  69613. */
  69614. export class TiledPlaneBuilder {
  69615. /**
  69616. * Creates a tiled plane mesh
  69617. * * The parameter `pattern` will, depending on value, do nothing or
  69618. * * * flip (reflect about central vertical) alternate tiles across and up
  69619. * * * flip every tile on alternate rows
  69620. * * * rotate (180 degs) alternate tiles across and up
  69621. * * * rotate every tile on alternate rows
  69622. * * * flip and rotate alternate tiles across and up
  69623. * * * flip and rotate every tile on alternate rows
  69624. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69625. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69626. * * 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
  69627. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69628. * * 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)
  69629. * * 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)
  69630. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69631. * @param name defines the name of the mesh
  69632. * @param options defines the options used to create the mesh
  69633. * @param scene defines the hosting scene
  69634. * @returns the box mesh
  69635. */
  69636. static CreateTiledPlane(name: string, options: {
  69637. pattern?: number;
  69638. tileSize?: number;
  69639. tileWidth?: number;
  69640. tileHeight?: number;
  69641. size?: number;
  69642. width?: number;
  69643. height?: number;
  69644. alignHorizontal?: number;
  69645. alignVertical?: number;
  69646. sideOrientation?: number;
  69647. frontUVs?: Vector4;
  69648. backUVs?: Vector4;
  69649. updatable?: boolean;
  69650. }, scene?: Nullable<Scene>): Mesh;
  69651. }
  69652. }
  69653. declare module BABYLON {
  69654. /**
  69655. * Class containing static functions to help procedurally build meshes
  69656. */
  69657. export class TubeBuilder {
  69658. /**
  69659. * Creates a tube mesh.
  69660. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69661. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69662. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69663. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69664. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69665. * * 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)
  69666. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69667. * * 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
  69668. * * 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
  69669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69670. * * 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
  69671. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69673. * @param name defines the name of the mesh
  69674. * @param options defines the options used to create the mesh
  69675. * @param scene defines the hosting scene
  69676. * @returns the tube mesh
  69677. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69678. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69679. */
  69680. static CreateTube(name: string, options: {
  69681. path: Vector3[];
  69682. radius?: number;
  69683. tessellation?: number;
  69684. radiusFunction?: {
  69685. (i: number, distance: number): number;
  69686. };
  69687. cap?: number;
  69688. arc?: number;
  69689. updatable?: boolean;
  69690. sideOrientation?: number;
  69691. frontUVs?: Vector4;
  69692. backUVs?: Vector4;
  69693. instance?: Mesh;
  69694. invertUV?: boolean;
  69695. }, scene?: Nullable<Scene>): Mesh;
  69696. }
  69697. }
  69698. declare module BABYLON {
  69699. /**
  69700. * Class containing static functions to help procedurally build meshes
  69701. */
  69702. export class IcoSphereBuilder {
  69703. /**
  69704. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69705. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69706. * * 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`)
  69707. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69708. * * 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
  69709. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69710. * * 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
  69711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69712. * @param name defines the name of the mesh
  69713. * @param options defines the options used to create the mesh
  69714. * @param scene defines the hosting scene
  69715. * @returns the icosahedron mesh
  69716. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69717. */
  69718. static CreateIcoSphere(name: string, options: {
  69719. radius?: number;
  69720. radiusX?: number;
  69721. radiusY?: number;
  69722. radiusZ?: number;
  69723. flat?: boolean;
  69724. subdivisions?: number;
  69725. sideOrientation?: number;
  69726. frontUVs?: Vector4;
  69727. backUVs?: Vector4;
  69728. updatable?: boolean;
  69729. }, scene?: Nullable<Scene>): Mesh;
  69730. }
  69731. }
  69732. declare module BABYLON {
  69733. /**
  69734. * Class containing static functions to help procedurally build meshes
  69735. */
  69736. export class DecalBuilder {
  69737. /**
  69738. * Creates a decal mesh.
  69739. * 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
  69740. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69741. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69742. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69743. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69744. * @param name defines the name of the mesh
  69745. * @param sourceMesh defines the mesh where the decal must be applied
  69746. * @param options defines the options used to create the mesh
  69747. * @param scene defines the hosting scene
  69748. * @returns the decal mesh
  69749. * @see https://doc.babylonjs.com/how_to/decals
  69750. */
  69751. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69752. position?: Vector3;
  69753. normal?: Vector3;
  69754. size?: Vector3;
  69755. angle?: number;
  69756. }): Mesh;
  69757. }
  69758. }
  69759. declare module BABYLON {
  69760. /**
  69761. * Class containing static functions to help procedurally build meshes
  69762. */
  69763. export class MeshBuilder {
  69764. /**
  69765. * Creates a box mesh
  69766. * * The parameter `size` sets the size (float) of each box side (default 1)
  69767. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69768. * * 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)
  69769. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69771. * * 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
  69772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69773. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69774. * @param name defines the name of the mesh
  69775. * @param options defines the options used to create the mesh
  69776. * @param scene defines the hosting scene
  69777. * @returns the box mesh
  69778. */
  69779. static CreateBox(name: string, options: {
  69780. size?: number;
  69781. width?: number;
  69782. height?: number;
  69783. depth?: number;
  69784. faceUV?: Vector4[];
  69785. faceColors?: Color4[];
  69786. sideOrientation?: number;
  69787. frontUVs?: Vector4;
  69788. backUVs?: Vector4;
  69789. wrap?: boolean;
  69790. topBaseAt?: number;
  69791. bottomBaseAt?: number;
  69792. updatable?: boolean;
  69793. }, scene?: Nullable<Scene>): Mesh;
  69794. /**
  69795. * Creates a tiled box mesh
  69796. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69798. * @param name defines the name of the mesh
  69799. * @param options defines the options used to create the mesh
  69800. * @param scene defines the hosting scene
  69801. * @returns the tiled box mesh
  69802. */
  69803. static CreateTiledBox(name: string, options: {
  69804. pattern?: number;
  69805. size?: number;
  69806. width?: number;
  69807. height?: number;
  69808. depth: number;
  69809. tileSize?: number;
  69810. tileWidth?: number;
  69811. tileHeight?: number;
  69812. faceUV?: Vector4[];
  69813. faceColors?: Color4[];
  69814. alignHorizontal?: number;
  69815. alignVertical?: number;
  69816. sideOrientation?: number;
  69817. updatable?: boolean;
  69818. }, scene?: Nullable<Scene>): Mesh;
  69819. /**
  69820. * Creates a sphere mesh
  69821. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69822. * * 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`)
  69823. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69824. * * 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
  69825. * * 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)
  69826. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69827. * * 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
  69828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69829. * @param name defines the name of the mesh
  69830. * @param options defines the options used to create the mesh
  69831. * @param scene defines the hosting scene
  69832. * @returns the sphere mesh
  69833. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69834. */
  69835. static CreateSphere(name: string, options: {
  69836. segments?: number;
  69837. diameter?: number;
  69838. diameterX?: number;
  69839. diameterY?: number;
  69840. diameterZ?: number;
  69841. arc?: number;
  69842. slice?: number;
  69843. sideOrientation?: number;
  69844. frontUVs?: Vector4;
  69845. backUVs?: Vector4;
  69846. updatable?: boolean;
  69847. }, scene?: Nullable<Scene>): Mesh;
  69848. /**
  69849. * Creates a plane polygonal mesh. By default, this is a disc
  69850. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69851. * * 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
  69852. * * 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
  69853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69854. * * 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
  69855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69856. * @param name defines the name of the mesh
  69857. * @param options defines the options used to create the mesh
  69858. * @param scene defines the hosting scene
  69859. * @returns the plane polygonal mesh
  69860. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69861. */
  69862. static CreateDisc(name: string, options: {
  69863. radius?: number;
  69864. tessellation?: number;
  69865. arc?: number;
  69866. updatable?: boolean;
  69867. sideOrientation?: number;
  69868. frontUVs?: Vector4;
  69869. backUVs?: Vector4;
  69870. }, scene?: Nullable<Scene>): Mesh;
  69871. /**
  69872. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69873. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69874. * * 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`)
  69875. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69876. * * 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
  69877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69878. * * 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
  69879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69880. * @param name defines the name of the mesh
  69881. * @param options defines the options used to create the mesh
  69882. * @param scene defines the hosting scene
  69883. * @returns the icosahedron mesh
  69884. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69885. */
  69886. static CreateIcoSphere(name: string, options: {
  69887. radius?: number;
  69888. radiusX?: number;
  69889. radiusY?: number;
  69890. radiusZ?: number;
  69891. flat?: boolean;
  69892. subdivisions?: number;
  69893. sideOrientation?: number;
  69894. frontUVs?: Vector4;
  69895. backUVs?: Vector4;
  69896. updatable?: boolean;
  69897. }, scene?: Nullable<Scene>): Mesh;
  69898. /**
  69899. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69900. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69901. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69902. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69903. * * 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
  69904. * * 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
  69905. * * 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
  69906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69907. * * 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
  69908. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69909. * * 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
  69910. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69911. * * 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
  69912. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69914. * @param name defines the name of the mesh
  69915. * @param options defines the options used to create the mesh
  69916. * @param scene defines the hosting scene
  69917. * @returns the ribbon mesh
  69918. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69919. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69920. */
  69921. static CreateRibbon(name: string, options: {
  69922. pathArray: Vector3[][];
  69923. closeArray?: boolean;
  69924. closePath?: boolean;
  69925. offset?: number;
  69926. updatable?: boolean;
  69927. sideOrientation?: number;
  69928. frontUVs?: Vector4;
  69929. backUVs?: Vector4;
  69930. instance?: Mesh;
  69931. invertUV?: boolean;
  69932. uvs?: Vector2[];
  69933. colors?: Color4[];
  69934. }, scene?: Nullable<Scene>): Mesh;
  69935. /**
  69936. * Creates a cylinder or a cone mesh
  69937. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69938. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69939. * * 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.
  69940. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69941. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69942. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69943. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69944. * * 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).
  69945. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69946. * * 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).
  69947. * * 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
  69948. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69949. * * 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
  69950. * * 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.
  69951. * * If `enclose` is false, a ring surface is one element.
  69952. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69953. * * 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
  69954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69955. * * 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
  69956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69957. * @param name defines the name of the mesh
  69958. * @param options defines the options used to create the mesh
  69959. * @param scene defines the hosting scene
  69960. * @returns the cylinder mesh
  69961. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69962. */
  69963. static CreateCylinder(name: string, options: {
  69964. height?: number;
  69965. diameterTop?: number;
  69966. diameterBottom?: number;
  69967. diameter?: number;
  69968. tessellation?: number;
  69969. subdivisions?: number;
  69970. arc?: number;
  69971. faceColors?: Color4[];
  69972. faceUV?: Vector4[];
  69973. updatable?: boolean;
  69974. hasRings?: boolean;
  69975. enclose?: boolean;
  69976. cap?: number;
  69977. sideOrientation?: number;
  69978. frontUVs?: Vector4;
  69979. backUVs?: Vector4;
  69980. }, scene?: Nullable<Scene>): Mesh;
  69981. /**
  69982. * Creates a torus mesh
  69983. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69984. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69985. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69987. * * 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
  69988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69989. * @param name defines the name of the mesh
  69990. * @param options defines the options used to create the mesh
  69991. * @param scene defines the hosting scene
  69992. * @returns the torus mesh
  69993. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69994. */
  69995. static CreateTorus(name: string, options: {
  69996. diameter?: number;
  69997. thickness?: number;
  69998. tessellation?: number;
  69999. updatable?: boolean;
  70000. sideOrientation?: number;
  70001. frontUVs?: Vector4;
  70002. backUVs?: Vector4;
  70003. }, scene?: Nullable<Scene>): Mesh;
  70004. /**
  70005. * Creates a torus knot mesh
  70006. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70007. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70008. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70009. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70011. * * 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
  70012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70013. * @param name defines the name of the mesh
  70014. * @param options defines the options used to create the mesh
  70015. * @param scene defines the hosting scene
  70016. * @returns the torus knot mesh
  70017. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70018. */
  70019. static CreateTorusKnot(name: string, options: {
  70020. radius?: number;
  70021. tube?: number;
  70022. radialSegments?: number;
  70023. tubularSegments?: number;
  70024. p?: number;
  70025. q?: number;
  70026. updatable?: boolean;
  70027. sideOrientation?: number;
  70028. frontUVs?: Vector4;
  70029. backUVs?: Vector4;
  70030. }, scene?: Nullable<Scene>): Mesh;
  70031. /**
  70032. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70033. * * 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
  70034. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70035. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70036. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70037. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70038. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70039. * * 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
  70040. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70042. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70043. * @param name defines the name of the new line system
  70044. * @param options defines the options used to create the line system
  70045. * @param scene defines the hosting scene
  70046. * @returns a new line system mesh
  70047. */
  70048. static CreateLineSystem(name: string, options: {
  70049. lines: Vector3[][];
  70050. updatable?: boolean;
  70051. instance?: Nullable<LinesMesh>;
  70052. colors?: Nullable<Color4[][]>;
  70053. useVertexAlpha?: boolean;
  70054. }, scene: Nullable<Scene>): LinesMesh;
  70055. /**
  70056. * Creates a line mesh
  70057. * 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
  70058. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70059. * * The parameter `points` is an array successive Vector3
  70060. * * 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
  70061. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70062. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70063. * * When updating an instance, remember that only point positions can change, not the number of points
  70064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70065. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70066. * @param name defines the name of the new line system
  70067. * @param options defines the options used to create the line system
  70068. * @param scene defines the hosting scene
  70069. * @returns a new line mesh
  70070. */
  70071. static CreateLines(name: string, options: {
  70072. points: Vector3[];
  70073. updatable?: boolean;
  70074. instance?: Nullable<LinesMesh>;
  70075. colors?: Color4[];
  70076. useVertexAlpha?: boolean;
  70077. }, scene?: Nullable<Scene>): LinesMesh;
  70078. /**
  70079. * Creates a dashed line mesh
  70080. * * 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
  70081. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70082. * * The parameter `points` is an array successive Vector3
  70083. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70084. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70085. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70086. * * 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
  70087. * * When updating an instance, remember that only point positions can change, not the number of points
  70088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70089. * @param name defines the name of the mesh
  70090. * @param options defines the options used to create the mesh
  70091. * @param scene defines the hosting scene
  70092. * @returns the dashed line mesh
  70093. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70094. */
  70095. static CreateDashedLines(name: string, options: {
  70096. points: Vector3[];
  70097. dashSize?: number;
  70098. gapSize?: number;
  70099. dashNb?: number;
  70100. updatable?: boolean;
  70101. instance?: LinesMesh;
  70102. }, scene?: Nullable<Scene>): LinesMesh;
  70103. /**
  70104. * 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.
  70105. * * 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.
  70106. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70107. * * 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.
  70108. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70109. * * 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
  70110. * * 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
  70111. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70113. * * 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
  70114. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70116. * @param name defines the name of the mesh
  70117. * @param options defines the options used to create the mesh
  70118. * @param scene defines the hosting scene
  70119. * @returns the extruded shape mesh
  70120. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70121. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70122. */
  70123. static ExtrudeShape(name: string, options: {
  70124. shape: Vector3[];
  70125. path: Vector3[];
  70126. scale?: number;
  70127. rotation?: number;
  70128. cap?: number;
  70129. updatable?: boolean;
  70130. sideOrientation?: number;
  70131. frontUVs?: Vector4;
  70132. backUVs?: Vector4;
  70133. instance?: Mesh;
  70134. invertUV?: boolean;
  70135. }, scene?: Nullable<Scene>): Mesh;
  70136. /**
  70137. * Creates an custom extruded shape mesh.
  70138. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70139. * * 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.
  70140. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70141. * * 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
  70142. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70143. * * 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
  70144. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70145. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70146. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70147. * * 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
  70148. * * 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
  70149. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70151. * * 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
  70152. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70154. * @param name defines the name of the mesh
  70155. * @param options defines the options used to create the mesh
  70156. * @param scene defines the hosting scene
  70157. * @returns the custom extruded shape mesh
  70158. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70159. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70161. */
  70162. static ExtrudeShapeCustom(name: string, options: {
  70163. shape: Vector3[];
  70164. path: Vector3[];
  70165. scaleFunction?: any;
  70166. rotationFunction?: any;
  70167. ribbonCloseArray?: boolean;
  70168. ribbonClosePath?: boolean;
  70169. cap?: number;
  70170. updatable?: boolean;
  70171. sideOrientation?: number;
  70172. frontUVs?: Vector4;
  70173. backUVs?: Vector4;
  70174. instance?: Mesh;
  70175. invertUV?: boolean;
  70176. }, scene?: Nullable<Scene>): Mesh;
  70177. /**
  70178. * Creates lathe mesh.
  70179. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70180. * * 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
  70181. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70182. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70183. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70184. * * 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
  70185. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70186. * * 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
  70187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70188. * * 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
  70189. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70191. * @param name defines the name of the mesh
  70192. * @param options defines the options used to create the mesh
  70193. * @param scene defines the hosting scene
  70194. * @returns the lathe mesh
  70195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70196. */
  70197. static CreateLathe(name: string, options: {
  70198. shape: Vector3[];
  70199. radius?: number;
  70200. tessellation?: number;
  70201. clip?: number;
  70202. arc?: number;
  70203. closed?: boolean;
  70204. updatable?: boolean;
  70205. sideOrientation?: number;
  70206. frontUVs?: Vector4;
  70207. backUVs?: Vector4;
  70208. cap?: number;
  70209. invertUV?: boolean;
  70210. }, scene?: Nullable<Scene>): Mesh;
  70211. /**
  70212. * Creates a tiled plane mesh
  70213. * * You can set a limited pattern arrangement with the tiles
  70214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70215. * * 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
  70216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70217. * @param name defines the name of the mesh
  70218. * @param options defines the options used to create the mesh
  70219. * @param scene defines the hosting scene
  70220. * @returns the plane mesh
  70221. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70222. */
  70223. static CreateTiledPlane(name: string, options: {
  70224. pattern?: number;
  70225. tileSize?: number;
  70226. tileWidth?: number;
  70227. tileHeight?: number;
  70228. size?: number;
  70229. width?: number;
  70230. height?: number;
  70231. alignHorizontal?: number;
  70232. alignVertical?: number;
  70233. sideOrientation?: number;
  70234. frontUVs?: Vector4;
  70235. backUVs?: Vector4;
  70236. updatable?: boolean;
  70237. }, scene?: Nullable<Scene>): Mesh;
  70238. /**
  70239. * Creates a plane mesh
  70240. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70241. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70242. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70244. * * 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
  70245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70246. * @param name defines the name of the mesh
  70247. * @param options defines the options used to create the mesh
  70248. * @param scene defines the hosting scene
  70249. * @returns the plane mesh
  70250. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70251. */
  70252. static CreatePlane(name: string, options: {
  70253. size?: number;
  70254. width?: number;
  70255. height?: number;
  70256. sideOrientation?: number;
  70257. frontUVs?: Vector4;
  70258. backUVs?: Vector4;
  70259. updatable?: boolean;
  70260. sourcePlane?: Plane;
  70261. }, scene?: Nullable<Scene>): Mesh;
  70262. /**
  70263. * Creates a ground mesh
  70264. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70265. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70267. * @param name defines the name of the mesh
  70268. * @param options defines the options used to create the mesh
  70269. * @param scene defines the hosting scene
  70270. * @returns the ground mesh
  70271. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70272. */
  70273. static CreateGround(name: string, options: {
  70274. width?: number;
  70275. height?: number;
  70276. subdivisions?: number;
  70277. subdivisionsX?: number;
  70278. subdivisionsY?: number;
  70279. updatable?: boolean;
  70280. }, scene?: Nullable<Scene>): Mesh;
  70281. /**
  70282. * Creates a tiled ground mesh
  70283. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70284. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70285. * * 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
  70286. * * 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
  70287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70288. * @param name defines the name of the mesh
  70289. * @param options defines the options used to create the mesh
  70290. * @param scene defines the hosting scene
  70291. * @returns the tiled ground mesh
  70292. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70293. */
  70294. static CreateTiledGround(name: string, options: {
  70295. xmin: number;
  70296. zmin: number;
  70297. xmax: number;
  70298. zmax: number;
  70299. subdivisions?: {
  70300. w: number;
  70301. h: number;
  70302. };
  70303. precision?: {
  70304. w: number;
  70305. h: number;
  70306. };
  70307. updatable?: boolean;
  70308. }, scene?: Nullable<Scene>): Mesh;
  70309. /**
  70310. * Creates a ground mesh from a height map
  70311. * * The parameter `url` sets the URL of the height map image resource.
  70312. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70313. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70314. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70315. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70316. * * 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.
  70317. * * 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).
  70318. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70320. * @param name defines the name of the mesh
  70321. * @param url defines the url to the height map
  70322. * @param options defines the options used to create the mesh
  70323. * @param scene defines the hosting scene
  70324. * @returns the ground mesh
  70325. * @see https://doc.babylonjs.com/babylon101/height_map
  70326. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70327. */
  70328. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70329. width?: number;
  70330. height?: number;
  70331. subdivisions?: number;
  70332. minHeight?: number;
  70333. maxHeight?: number;
  70334. colorFilter?: Color3;
  70335. alphaFilter?: number;
  70336. updatable?: boolean;
  70337. onReady?: (mesh: GroundMesh) => void;
  70338. }, scene?: Nullable<Scene>): GroundMesh;
  70339. /**
  70340. * Creates a polygon mesh
  70341. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70342. * * 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
  70343. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70345. * * 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)
  70346. * * Remember you can only change the shape positions, not their number when updating a polygon
  70347. * @param name defines the name of the mesh
  70348. * @param options defines the options used to create the mesh
  70349. * @param scene defines the hosting scene
  70350. * @param earcutInjection can be used to inject your own earcut reference
  70351. * @returns the polygon mesh
  70352. */
  70353. static CreatePolygon(name: string, options: {
  70354. shape: Vector3[];
  70355. holes?: Vector3[][];
  70356. depth?: number;
  70357. faceUV?: Vector4[];
  70358. faceColors?: Color4[];
  70359. updatable?: boolean;
  70360. sideOrientation?: number;
  70361. frontUVs?: Vector4;
  70362. backUVs?: Vector4;
  70363. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70364. /**
  70365. * Creates an extruded polygon mesh, with depth in the Y direction.
  70366. * * 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)
  70367. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70368. * @param name defines the name of the mesh
  70369. * @param options defines the options used to create the mesh
  70370. * @param scene defines the hosting scene
  70371. * @param earcutInjection can be used to inject your own earcut reference
  70372. * @returns the polygon mesh
  70373. */
  70374. static ExtrudePolygon(name: string, options: {
  70375. shape: Vector3[];
  70376. holes?: Vector3[][];
  70377. depth?: number;
  70378. faceUV?: Vector4[];
  70379. faceColors?: Color4[];
  70380. updatable?: boolean;
  70381. sideOrientation?: number;
  70382. frontUVs?: Vector4;
  70383. backUVs?: Vector4;
  70384. wrap?: boolean;
  70385. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70386. /**
  70387. * Creates a tube mesh.
  70388. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70389. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70390. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70391. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70392. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70393. * * 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)
  70394. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70395. * * 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
  70396. * * 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
  70397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70398. * * 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
  70399. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70401. * @param name defines the name of the mesh
  70402. * @param options defines the options used to create the mesh
  70403. * @param scene defines the hosting scene
  70404. * @returns the tube mesh
  70405. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70406. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70407. */
  70408. static CreateTube(name: string, options: {
  70409. path: Vector3[];
  70410. radius?: number;
  70411. tessellation?: number;
  70412. radiusFunction?: {
  70413. (i: number, distance: number): number;
  70414. };
  70415. cap?: number;
  70416. arc?: number;
  70417. updatable?: boolean;
  70418. sideOrientation?: number;
  70419. frontUVs?: Vector4;
  70420. backUVs?: Vector4;
  70421. instance?: Mesh;
  70422. invertUV?: boolean;
  70423. }, scene?: Nullable<Scene>): Mesh;
  70424. /**
  70425. * Creates a polyhedron mesh
  70426. * * 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
  70427. * * The parameter `size` (positive float, default 1) sets the polygon size
  70428. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70429. * * 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`
  70430. * * 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
  70431. * * 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)`)
  70432. * * 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
  70433. * * 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
  70434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70435. * * 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
  70436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70437. * @param name defines the name of the mesh
  70438. * @param options defines the options used to create the mesh
  70439. * @param scene defines the hosting scene
  70440. * @returns the polyhedron mesh
  70441. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70442. */
  70443. static CreatePolyhedron(name: string, options: {
  70444. type?: number;
  70445. size?: number;
  70446. sizeX?: number;
  70447. sizeY?: number;
  70448. sizeZ?: number;
  70449. custom?: any;
  70450. faceUV?: Vector4[];
  70451. faceColors?: Color4[];
  70452. flat?: boolean;
  70453. updatable?: boolean;
  70454. sideOrientation?: number;
  70455. frontUVs?: Vector4;
  70456. backUVs?: Vector4;
  70457. }, scene?: Nullable<Scene>): Mesh;
  70458. /**
  70459. * Creates a decal mesh.
  70460. * 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
  70461. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70462. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70463. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70464. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70465. * @param name defines the name of the mesh
  70466. * @param sourceMesh defines the mesh where the decal must be applied
  70467. * @param options defines the options used to create the mesh
  70468. * @param scene defines the hosting scene
  70469. * @returns the decal mesh
  70470. * @see https://doc.babylonjs.com/how_to/decals
  70471. */
  70472. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70473. position?: Vector3;
  70474. normal?: Vector3;
  70475. size?: Vector3;
  70476. angle?: number;
  70477. }): Mesh;
  70478. /**
  70479. * Creates a Capsule Mesh
  70480. * @param name defines the name of the mesh.
  70481. * @param options the constructors options used to shape the mesh.
  70482. * @param scene defines the scene the mesh is scoped to.
  70483. * @returns the capsule mesh
  70484. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70485. */
  70486. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70487. }
  70488. }
  70489. declare module BABYLON {
  70490. /**
  70491. * A simplifier interface for future simplification implementations
  70492. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70493. */
  70494. export interface ISimplifier {
  70495. /**
  70496. * Simplification of a given mesh according to the given settings.
  70497. * Since this requires computation, it is assumed that the function runs async.
  70498. * @param settings The settings of the simplification, including quality and distance
  70499. * @param successCallback A callback that will be called after the mesh was simplified.
  70500. * @param errorCallback in case of an error, this callback will be called. optional.
  70501. */
  70502. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70503. }
  70504. /**
  70505. * Expected simplification settings.
  70506. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70507. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70508. */
  70509. export interface ISimplificationSettings {
  70510. /**
  70511. * Gets or sets the expected quality
  70512. */
  70513. quality: number;
  70514. /**
  70515. * Gets or sets the distance when this optimized version should be used
  70516. */
  70517. distance: number;
  70518. /**
  70519. * Gets an already optimized mesh
  70520. */
  70521. optimizeMesh?: boolean;
  70522. }
  70523. /**
  70524. * Class used to specify simplification options
  70525. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70526. */
  70527. export class SimplificationSettings implements ISimplificationSettings {
  70528. /** expected quality */
  70529. quality: number;
  70530. /** distance when this optimized version should be used */
  70531. distance: number;
  70532. /** already optimized mesh */
  70533. optimizeMesh?: boolean | undefined;
  70534. /**
  70535. * Creates a SimplificationSettings
  70536. * @param quality expected quality
  70537. * @param distance distance when this optimized version should be used
  70538. * @param optimizeMesh already optimized mesh
  70539. */
  70540. constructor(
  70541. /** expected quality */
  70542. quality: number,
  70543. /** distance when this optimized version should be used */
  70544. distance: number,
  70545. /** already optimized mesh */
  70546. optimizeMesh?: boolean | undefined);
  70547. }
  70548. /**
  70549. * Interface used to define a simplification task
  70550. */
  70551. export interface ISimplificationTask {
  70552. /**
  70553. * Array of settings
  70554. */
  70555. settings: Array<ISimplificationSettings>;
  70556. /**
  70557. * Simplification type
  70558. */
  70559. simplificationType: SimplificationType;
  70560. /**
  70561. * Mesh to simplify
  70562. */
  70563. mesh: Mesh;
  70564. /**
  70565. * Callback called on success
  70566. */
  70567. successCallback?: () => void;
  70568. /**
  70569. * Defines if parallel processing can be used
  70570. */
  70571. parallelProcessing: boolean;
  70572. }
  70573. /**
  70574. * Queue used to order the simplification tasks
  70575. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70576. */
  70577. export class SimplificationQueue {
  70578. private _simplificationArray;
  70579. /**
  70580. * Gets a boolean indicating that the process is still running
  70581. */
  70582. running: boolean;
  70583. /**
  70584. * Creates a new queue
  70585. */
  70586. constructor();
  70587. /**
  70588. * Adds a new simplification task
  70589. * @param task defines a task to add
  70590. */
  70591. addTask(task: ISimplificationTask): void;
  70592. /**
  70593. * Execute next task
  70594. */
  70595. executeNext(): void;
  70596. /**
  70597. * Execute a simplification task
  70598. * @param task defines the task to run
  70599. */
  70600. runSimplification(task: ISimplificationTask): void;
  70601. private getSimplifier;
  70602. }
  70603. /**
  70604. * The implemented types of simplification
  70605. * At the moment only Quadratic Error Decimation is implemented
  70606. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70607. */
  70608. export enum SimplificationType {
  70609. /** Quadratic error decimation */
  70610. QUADRATIC = 0
  70611. }
  70612. /**
  70613. * An implementation of the Quadratic Error simplification algorithm.
  70614. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70615. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70616. * @author RaananW
  70617. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70618. */
  70619. export class QuadraticErrorSimplification implements ISimplifier {
  70620. private _mesh;
  70621. private triangles;
  70622. private vertices;
  70623. private references;
  70624. private _reconstructedMesh;
  70625. /** Gets or sets the number pf sync interations */
  70626. syncIterations: number;
  70627. /** Gets or sets the aggressiveness of the simplifier */
  70628. aggressiveness: number;
  70629. /** Gets or sets the number of allowed iterations for decimation */
  70630. decimationIterations: number;
  70631. /** Gets or sets the espilon to use for bounding box computation */
  70632. boundingBoxEpsilon: number;
  70633. /**
  70634. * Creates a new QuadraticErrorSimplification
  70635. * @param _mesh defines the target mesh
  70636. */
  70637. constructor(_mesh: Mesh);
  70638. /**
  70639. * Simplification of a given mesh according to the given settings.
  70640. * Since this requires computation, it is assumed that the function runs async.
  70641. * @param settings The settings of the simplification, including quality and distance
  70642. * @param successCallback A callback that will be called after the mesh was simplified.
  70643. */
  70644. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70645. private runDecimation;
  70646. private initWithMesh;
  70647. private init;
  70648. private reconstructMesh;
  70649. private initDecimatedMesh;
  70650. private isFlipped;
  70651. private updateTriangles;
  70652. private identifyBorder;
  70653. private updateMesh;
  70654. private vertexError;
  70655. private calculateError;
  70656. }
  70657. }
  70658. declare module BABYLON {
  70659. interface Scene {
  70660. /** @hidden (Backing field) */
  70661. _simplificationQueue: SimplificationQueue;
  70662. /**
  70663. * Gets or sets the simplification queue attached to the scene
  70664. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70665. */
  70666. simplificationQueue: SimplificationQueue;
  70667. }
  70668. interface Mesh {
  70669. /**
  70670. * Simplify the mesh according to the given array of settings.
  70671. * Function will return immediately and will simplify async
  70672. * @param settings a collection of simplification settings
  70673. * @param parallelProcessing should all levels calculate parallel or one after the other
  70674. * @param simplificationType the type of simplification to run
  70675. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70676. * @returns the current mesh
  70677. */
  70678. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70679. }
  70680. /**
  70681. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70682. * created in a scene
  70683. */
  70684. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70685. /**
  70686. * The component name helpfull to identify the component in the list of scene components.
  70687. */
  70688. readonly name: string;
  70689. /**
  70690. * The scene the component belongs to.
  70691. */
  70692. scene: Scene;
  70693. /**
  70694. * Creates a new instance of the component for the given scene
  70695. * @param scene Defines the scene to register the component in
  70696. */
  70697. constructor(scene: Scene);
  70698. /**
  70699. * Registers the component in a given scene
  70700. */
  70701. register(): void;
  70702. /**
  70703. * Rebuilds the elements related to this component in case of
  70704. * context lost for instance.
  70705. */
  70706. rebuild(): void;
  70707. /**
  70708. * Disposes the component and the associated ressources
  70709. */
  70710. dispose(): void;
  70711. private _beforeCameraUpdate;
  70712. }
  70713. }
  70714. declare module BABYLON {
  70715. interface Mesh {
  70716. /**
  70717. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70718. */
  70719. thinInstanceEnablePicking: boolean;
  70720. /**
  70721. * Creates a new thin instance
  70722. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70723. * @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
  70724. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70725. */
  70726. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70727. /**
  70728. * Adds the transformation (matrix) of the current mesh as a thin instance
  70729. * @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
  70730. * @returns the thin instance index number
  70731. */
  70732. thinInstanceAddSelf(refresh: boolean): number;
  70733. /**
  70734. * Registers a custom attribute to be used with thin instances
  70735. * @param kind name of the attribute
  70736. * @param stride size in floats of the attribute
  70737. */
  70738. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70739. /**
  70740. * Sets the matrix of a thin instance
  70741. * @param index index of the thin instance
  70742. * @param matrix matrix to set
  70743. * @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
  70744. */
  70745. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70746. /**
  70747. * Sets the value of a custom attribute for a thin instance
  70748. * @param kind name of the attribute
  70749. * @param index index of the thin instance
  70750. * @param value value to set
  70751. * @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
  70752. */
  70753. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70754. /**
  70755. * 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.
  70756. */
  70757. thinInstanceCount: number;
  70758. /**
  70759. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70760. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70761. * @param buffer buffer to set
  70762. * @param stride size in floats of each value of the buffer
  70763. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70764. */
  70765. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70766. /**
  70767. * Gets the list of world matrices
  70768. * @return an array containing all the world matrices from the thin instances
  70769. */
  70770. thinInstanceGetWorldMatrices(): Matrix[];
  70771. /**
  70772. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70773. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70774. */
  70775. thinInstanceBufferUpdated(kind: string): void;
  70776. /**
  70777. * Applies a partial update to a buffer directly on the GPU
  70778. * 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
  70779. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70780. * @param data the data to set in the GPU buffer
  70781. * @param offset the offset in the GPU buffer where to update the data
  70782. */
  70783. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70784. /**
  70785. * Refreshes the bounding info, taking into account all the thin instances defined
  70786. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70787. */
  70788. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70789. /** @hidden */
  70790. _thinInstanceInitializeUserStorage(): void;
  70791. /** @hidden */
  70792. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70793. /** @hidden */
  70794. _userThinInstanceBuffersStorage: {
  70795. data: {
  70796. [key: string]: Float32Array;
  70797. };
  70798. sizes: {
  70799. [key: string]: number;
  70800. };
  70801. vertexBuffers: {
  70802. [key: string]: Nullable<VertexBuffer>;
  70803. };
  70804. strides: {
  70805. [key: string]: number;
  70806. };
  70807. };
  70808. }
  70809. }
  70810. declare module BABYLON {
  70811. /**
  70812. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70813. */
  70814. export interface INavigationEnginePlugin {
  70815. /**
  70816. * plugin name
  70817. */
  70818. name: string;
  70819. /**
  70820. * Creates a navigation mesh
  70821. * @param meshes array of all the geometry used to compute the navigatio mesh
  70822. * @param parameters bunch of parameters used to filter geometry
  70823. */
  70824. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70825. /**
  70826. * Create a navigation mesh debug mesh
  70827. * @param scene is where the mesh will be added
  70828. * @returns debug display mesh
  70829. */
  70830. createDebugNavMesh(scene: Scene): Mesh;
  70831. /**
  70832. * Get a navigation mesh constrained position, closest to the parameter position
  70833. * @param position world position
  70834. * @returns the closest point to position constrained by the navigation mesh
  70835. */
  70836. getClosestPoint(position: Vector3): Vector3;
  70837. /**
  70838. * Get a navigation mesh constrained position, closest to the parameter position
  70839. * @param position world position
  70840. * @param result output the closest point to position constrained by the navigation mesh
  70841. */
  70842. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70843. /**
  70844. * Get a navigation mesh constrained position, within a particular radius
  70845. * @param position world position
  70846. * @param maxRadius the maximum distance to the constrained world position
  70847. * @returns the closest point to position constrained by the navigation mesh
  70848. */
  70849. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70850. /**
  70851. * Get a navigation mesh constrained position, within a particular radius
  70852. * @param position world position
  70853. * @param maxRadius the maximum distance to the constrained world position
  70854. * @param result output the closest point to position constrained by the navigation mesh
  70855. */
  70856. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70857. /**
  70858. * Compute the final position from a segment made of destination-position
  70859. * @param position world position
  70860. * @param destination world position
  70861. * @returns the resulting point along the navmesh
  70862. */
  70863. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70864. /**
  70865. * Compute the final position from a segment made of destination-position
  70866. * @param position world position
  70867. * @param destination world position
  70868. * @param result output the resulting point along the navmesh
  70869. */
  70870. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70871. /**
  70872. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70873. * @param start world position
  70874. * @param end world position
  70875. * @returns array containing world position composing the path
  70876. */
  70877. computePath(start: Vector3, end: Vector3): Vector3[];
  70878. /**
  70879. * If this plugin is supported
  70880. * @returns true if plugin is supported
  70881. */
  70882. isSupported(): boolean;
  70883. /**
  70884. * Create a new Crowd so you can add agents
  70885. * @param maxAgents the maximum agent count in the crowd
  70886. * @param maxAgentRadius the maximum radius an agent can have
  70887. * @param scene to attach the crowd to
  70888. * @returns the crowd you can add agents to
  70889. */
  70890. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70891. /**
  70892. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70893. * The queries will try to find a solution within those bounds
  70894. * default is (1,1,1)
  70895. * @param extent x,y,z value that define the extent around the queries point of reference
  70896. */
  70897. setDefaultQueryExtent(extent: Vector3): void;
  70898. /**
  70899. * Get the Bounding box extent specified by setDefaultQueryExtent
  70900. * @returns the box extent values
  70901. */
  70902. getDefaultQueryExtent(): Vector3;
  70903. /**
  70904. * build the navmesh from a previously saved state using getNavmeshData
  70905. * @param data the Uint8Array returned by getNavmeshData
  70906. */
  70907. buildFromNavmeshData(data: Uint8Array): void;
  70908. /**
  70909. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70910. * @returns data the Uint8Array that can be saved and reused
  70911. */
  70912. getNavmeshData(): Uint8Array;
  70913. /**
  70914. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70915. * @param result output the box extent values
  70916. */
  70917. getDefaultQueryExtentToRef(result: Vector3): void;
  70918. /**
  70919. * Set the time step of the navigation tick update.
  70920. * Default is 1/60.
  70921. * A value of 0 will disable fixed time update
  70922. * @param newTimeStep the new timestep to apply to this world.
  70923. */
  70924. setTimeStep(newTimeStep: number): void;
  70925. /**
  70926. * Get the time step of the navigation tick update.
  70927. * @returns the current time step
  70928. */
  70929. getTimeStep(): number;
  70930. /**
  70931. * If delta time in navigation tick update is greater than the time step
  70932. * a number of sub iterations are done. If more iterations are need to reach deltatime
  70933. * they will be discarded.
  70934. * A value of 0 will set to no maximum and update will use as many substeps as needed
  70935. * @param newStepCount the maximum number of iterations
  70936. */
  70937. setMaximumSubStepCount(newStepCount: number): void;
  70938. /**
  70939. * Get the maximum number of iterations per navigation tick update
  70940. * @returns the maximum number of iterations
  70941. */
  70942. getMaximumSubStepCount(): number;
  70943. /**
  70944. * Release all resources
  70945. */
  70946. dispose(): void;
  70947. }
  70948. /**
  70949. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70950. */
  70951. export interface ICrowd {
  70952. /**
  70953. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70954. * You can attach anything to that node. The node position is updated in the scene update tick.
  70955. * @param pos world position that will be constrained by the navigation mesh
  70956. * @param parameters agent parameters
  70957. * @param transform hooked to the agent that will be update by the scene
  70958. * @returns agent index
  70959. */
  70960. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70961. /**
  70962. * Returns the agent position in world space
  70963. * @param index agent index returned by addAgent
  70964. * @returns world space position
  70965. */
  70966. getAgentPosition(index: number): Vector3;
  70967. /**
  70968. * Gets the agent position result in world space
  70969. * @param index agent index returned by addAgent
  70970. * @param result output world space position
  70971. */
  70972. getAgentPositionToRef(index: number, result: Vector3): void;
  70973. /**
  70974. * Gets the agent velocity in world space
  70975. * @param index agent index returned by addAgent
  70976. * @returns world space velocity
  70977. */
  70978. getAgentVelocity(index: number): Vector3;
  70979. /**
  70980. * Gets the agent velocity result in world space
  70981. * @param index agent index returned by addAgent
  70982. * @param result output world space velocity
  70983. */
  70984. getAgentVelocityToRef(index: number, result: Vector3): void;
  70985. /**
  70986. * Gets the agent next target point on the path
  70987. * @param index agent index returned by addAgent
  70988. * @returns world space position
  70989. */
  70990. getAgentNextTargetPath(index: number): Vector3;
  70991. /**
  70992. * Gets the agent state
  70993. * @param index agent index returned by addAgent
  70994. * @returns agent state
  70995. */
  70996. getAgentState(index: number): number;
  70997. /**
  70998. * returns true if the agent in over an off mesh link connection
  70999. * @param index agent index returned by addAgent
  71000. * @returns true if over an off mesh link connection
  71001. */
  71002. overOffmeshConnection(index: number): boolean;
  71003. /**
  71004. * Gets the agent next target point on the path
  71005. * @param index agent index returned by addAgent
  71006. * @param result output world space position
  71007. */
  71008. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71009. /**
  71010. * remove a particular agent previously created
  71011. * @param index agent index returned by addAgent
  71012. */
  71013. removeAgent(index: number): void;
  71014. /**
  71015. * get the list of all agents attached to this crowd
  71016. * @returns list of agent indices
  71017. */
  71018. getAgents(): number[];
  71019. /**
  71020. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71021. * @param deltaTime in seconds
  71022. */
  71023. update(deltaTime: number): void;
  71024. /**
  71025. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71026. * @param index agent index returned by addAgent
  71027. * @param destination targeted world position
  71028. */
  71029. agentGoto(index: number, destination: Vector3): void;
  71030. /**
  71031. * Teleport the agent to a new position
  71032. * @param index agent index returned by addAgent
  71033. * @param destination targeted world position
  71034. */
  71035. agentTeleport(index: number, destination: Vector3): void;
  71036. /**
  71037. * Update agent parameters
  71038. * @param index agent index returned by addAgent
  71039. * @param parameters agent parameters
  71040. */
  71041. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71042. /**
  71043. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71044. * The queries will try to find a solution within those bounds
  71045. * default is (1,1,1)
  71046. * @param extent x,y,z value that define the extent around the queries point of reference
  71047. */
  71048. setDefaultQueryExtent(extent: Vector3): void;
  71049. /**
  71050. * Get the Bounding box extent specified by setDefaultQueryExtent
  71051. * @returns the box extent values
  71052. */
  71053. getDefaultQueryExtent(): Vector3;
  71054. /**
  71055. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71056. * @param result output the box extent values
  71057. */
  71058. getDefaultQueryExtentToRef(result: Vector3): void;
  71059. /**
  71060. * Release all resources
  71061. */
  71062. dispose(): void;
  71063. }
  71064. /**
  71065. * Configures an agent
  71066. */
  71067. export interface IAgentParameters {
  71068. /**
  71069. * Agent radius. [Limit: >= 0]
  71070. */
  71071. radius: number;
  71072. /**
  71073. * Agent height. [Limit: > 0]
  71074. */
  71075. height: number;
  71076. /**
  71077. * Maximum allowed acceleration. [Limit: >= 0]
  71078. */
  71079. maxAcceleration: number;
  71080. /**
  71081. * Maximum allowed speed. [Limit: >= 0]
  71082. */
  71083. maxSpeed: number;
  71084. /**
  71085. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71086. */
  71087. collisionQueryRange: number;
  71088. /**
  71089. * The path visibility optimization range. [Limit: > 0]
  71090. */
  71091. pathOptimizationRange: number;
  71092. /**
  71093. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71094. */
  71095. separationWeight: number;
  71096. }
  71097. /**
  71098. * Configures the navigation mesh creation
  71099. */
  71100. export interface INavMeshParameters {
  71101. /**
  71102. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71103. */
  71104. cs: number;
  71105. /**
  71106. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71107. */
  71108. ch: number;
  71109. /**
  71110. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71111. */
  71112. walkableSlopeAngle: number;
  71113. /**
  71114. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71115. * be considered walkable. [Limit: >= 3] [Units: vx]
  71116. */
  71117. walkableHeight: number;
  71118. /**
  71119. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71120. */
  71121. walkableClimb: number;
  71122. /**
  71123. * The distance to erode/shrink the walkable area of the heightfield away from
  71124. * obstructions. [Limit: >=0] [Units: vx]
  71125. */
  71126. walkableRadius: number;
  71127. /**
  71128. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71129. */
  71130. maxEdgeLen: number;
  71131. /**
  71132. * The maximum distance a simplfied contour's border edges should deviate
  71133. * the original raw contour. [Limit: >=0] [Units: vx]
  71134. */
  71135. maxSimplificationError: number;
  71136. /**
  71137. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71138. */
  71139. minRegionArea: number;
  71140. /**
  71141. * Any regions with a span count smaller than this value will, if possible,
  71142. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71143. */
  71144. mergeRegionArea: number;
  71145. /**
  71146. * The maximum number of vertices allowed for polygons generated during the
  71147. * contour to polygon conversion process. [Limit: >= 3]
  71148. */
  71149. maxVertsPerPoly: number;
  71150. /**
  71151. * Sets the sampling distance to use when generating the detail mesh.
  71152. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71153. */
  71154. detailSampleDist: number;
  71155. /**
  71156. * The maximum distance the detail mesh surface should deviate from heightfield
  71157. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71158. */
  71159. detailSampleMaxError: number;
  71160. }
  71161. }
  71162. declare module BABYLON {
  71163. /**
  71164. * RecastJS navigation plugin
  71165. */
  71166. export class RecastJSPlugin implements INavigationEnginePlugin {
  71167. /**
  71168. * Reference to the Recast library
  71169. */
  71170. bjsRECAST: any;
  71171. /**
  71172. * plugin name
  71173. */
  71174. name: string;
  71175. /**
  71176. * the first navmesh created. We might extend this to support multiple navmeshes
  71177. */
  71178. navMesh: any;
  71179. private _maximumSubStepCount;
  71180. private _timeStep;
  71181. /**
  71182. * Initializes the recastJS plugin
  71183. * @param recastInjection can be used to inject your own recast reference
  71184. */
  71185. constructor(recastInjection?: any);
  71186. /**
  71187. * Set the time step of the navigation tick update.
  71188. * Default is 1/60.
  71189. * A value of 0 will disable fixed time update
  71190. * @param newTimeStep the new timestep to apply to this world.
  71191. */
  71192. setTimeStep(newTimeStep?: number): void;
  71193. /**
  71194. * Get the time step of the navigation tick update.
  71195. * @returns the current time step
  71196. */
  71197. getTimeStep(): number;
  71198. /**
  71199. * If delta time in navigation tick update is greater than the time step
  71200. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71201. * they will be discarded.
  71202. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71203. * @param newStepCount the maximum number of iterations
  71204. */
  71205. setMaximumSubStepCount(newStepCount?: number): void;
  71206. /**
  71207. * Get the maximum number of iterations per navigation tick update
  71208. * @returns the maximum number of iterations
  71209. */
  71210. getMaximumSubStepCount(): number;
  71211. /**
  71212. * Creates a navigation mesh
  71213. * @param meshes array of all the geometry used to compute the navigatio mesh
  71214. * @param parameters bunch of parameters used to filter geometry
  71215. */
  71216. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71217. /**
  71218. * Create a navigation mesh debug mesh
  71219. * @param scene is where the mesh will be added
  71220. * @returns debug display mesh
  71221. */
  71222. createDebugNavMesh(scene: Scene): Mesh;
  71223. /**
  71224. * Get a navigation mesh constrained position, closest to the parameter position
  71225. * @param position world position
  71226. * @returns the closest point to position constrained by the navigation mesh
  71227. */
  71228. getClosestPoint(position: Vector3): Vector3;
  71229. /**
  71230. * Get a navigation mesh constrained position, closest to the parameter position
  71231. * @param position world position
  71232. * @param result output the closest point to position constrained by the navigation mesh
  71233. */
  71234. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71235. /**
  71236. * Get a navigation mesh constrained position, within a particular radius
  71237. * @param position world position
  71238. * @param maxRadius the maximum distance to the constrained world position
  71239. * @returns the closest point to position constrained by the navigation mesh
  71240. */
  71241. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71242. /**
  71243. * Get a navigation mesh constrained position, within a particular radius
  71244. * @param position world position
  71245. * @param maxRadius the maximum distance to the constrained world position
  71246. * @param result output the closest point to position constrained by the navigation mesh
  71247. */
  71248. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71249. /**
  71250. * Compute the final position from a segment made of destination-position
  71251. * @param position world position
  71252. * @param destination world position
  71253. * @returns the resulting point along the navmesh
  71254. */
  71255. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71256. /**
  71257. * Compute the final position from a segment made of destination-position
  71258. * @param position world position
  71259. * @param destination world position
  71260. * @param result output the resulting point along the navmesh
  71261. */
  71262. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71263. /**
  71264. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71265. * @param start world position
  71266. * @param end world position
  71267. * @returns array containing world position composing the path
  71268. */
  71269. computePath(start: Vector3, end: Vector3): Vector3[];
  71270. /**
  71271. * Create a new Crowd so you can add agents
  71272. * @param maxAgents the maximum agent count in the crowd
  71273. * @param maxAgentRadius the maximum radius an agent can have
  71274. * @param scene to attach the crowd to
  71275. * @returns the crowd you can add agents to
  71276. */
  71277. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71278. /**
  71279. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71280. * The queries will try to find a solution within those bounds
  71281. * default is (1,1,1)
  71282. * @param extent x,y,z value that define the extent around the queries point of reference
  71283. */
  71284. setDefaultQueryExtent(extent: Vector3): void;
  71285. /**
  71286. * Get the Bounding box extent specified by setDefaultQueryExtent
  71287. * @returns the box extent values
  71288. */
  71289. getDefaultQueryExtent(): Vector3;
  71290. /**
  71291. * build the navmesh from a previously saved state using getNavmeshData
  71292. * @param data the Uint8Array returned by getNavmeshData
  71293. */
  71294. buildFromNavmeshData(data: Uint8Array): void;
  71295. /**
  71296. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71297. * @returns data the Uint8Array that can be saved and reused
  71298. */
  71299. getNavmeshData(): Uint8Array;
  71300. /**
  71301. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71302. * @param result output the box extent values
  71303. */
  71304. getDefaultQueryExtentToRef(result: Vector3): void;
  71305. /**
  71306. * Disposes
  71307. */
  71308. dispose(): void;
  71309. /**
  71310. * If this plugin is supported
  71311. * @returns true if plugin is supported
  71312. */
  71313. isSupported(): boolean;
  71314. }
  71315. /**
  71316. * Recast detour crowd implementation
  71317. */
  71318. export class RecastJSCrowd implements ICrowd {
  71319. /**
  71320. * Recast/detour plugin
  71321. */
  71322. bjsRECASTPlugin: RecastJSPlugin;
  71323. /**
  71324. * Link to the detour crowd
  71325. */
  71326. recastCrowd: any;
  71327. /**
  71328. * One transform per agent
  71329. */
  71330. transforms: TransformNode[];
  71331. /**
  71332. * All agents created
  71333. */
  71334. agents: number[];
  71335. /**
  71336. * Link to the scene is kept to unregister the crowd from the scene
  71337. */
  71338. private _scene;
  71339. /**
  71340. * Observer for crowd updates
  71341. */
  71342. private _onBeforeAnimationsObserver;
  71343. /**
  71344. * Constructor
  71345. * @param plugin recastJS plugin
  71346. * @param maxAgents the maximum agent count in the crowd
  71347. * @param maxAgentRadius the maximum radius an agent can have
  71348. * @param scene to attach the crowd to
  71349. * @returns the crowd you can add agents to
  71350. */
  71351. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71352. /**
  71353. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71354. * You can attach anything to that node. The node position is updated in the scene update tick.
  71355. * @param pos world position that will be constrained by the navigation mesh
  71356. * @param parameters agent parameters
  71357. * @param transform hooked to the agent that will be update by the scene
  71358. * @returns agent index
  71359. */
  71360. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71361. /**
  71362. * Returns the agent position in world space
  71363. * @param index agent index returned by addAgent
  71364. * @returns world space position
  71365. */
  71366. getAgentPosition(index: number): Vector3;
  71367. /**
  71368. * Returns the agent position result in world space
  71369. * @param index agent index returned by addAgent
  71370. * @param result output world space position
  71371. */
  71372. getAgentPositionToRef(index: number, result: Vector3): void;
  71373. /**
  71374. * Returns the agent velocity in world space
  71375. * @param index agent index returned by addAgent
  71376. * @returns world space velocity
  71377. */
  71378. getAgentVelocity(index: number): Vector3;
  71379. /**
  71380. * Returns the agent velocity result in world space
  71381. * @param index agent index returned by addAgent
  71382. * @param result output world space velocity
  71383. */
  71384. getAgentVelocityToRef(index: number, result: Vector3): void;
  71385. /**
  71386. * Returns the agent next target point on the path
  71387. * @param index agent index returned by addAgent
  71388. * @returns world space position
  71389. */
  71390. getAgentNextTargetPath(index: number): Vector3;
  71391. /**
  71392. * Returns the agent next target point on the path
  71393. * @param index agent index returned by addAgent
  71394. * @param result output world space position
  71395. */
  71396. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71397. /**
  71398. * Gets the agent state
  71399. * @param index agent index returned by addAgent
  71400. * @returns agent state
  71401. */
  71402. getAgentState(index: number): number;
  71403. /**
  71404. * returns true if the agent in over an off mesh link connection
  71405. * @param index agent index returned by addAgent
  71406. * @returns true if over an off mesh link connection
  71407. */
  71408. overOffmeshConnection(index: number): boolean;
  71409. /**
  71410. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71411. * @param index agent index returned by addAgent
  71412. * @param destination targeted world position
  71413. */
  71414. agentGoto(index: number, destination: Vector3): void;
  71415. /**
  71416. * Teleport the agent to a new position
  71417. * @param index agent index returned by addAgent
  71418. * @param destination targeted world position
  71419. */
  71420. agentTeleport(index: number, destination: Vector3): void;
  71421. /**
  71422. * Update agent parameters
  71423. * @param index agent index returned by addAgent
  71424. * @param parameters agent parameters
  71425. */
  71426. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71427. /**
  71428. * remove a particular agent previously created
  71429. * @param index agent index returned by addAgent
  71430. */
  71431. removeAgent(index: number): void;
  71432. /**
  71433. * get the list of all agents attached to this crowd
  71434. * @returns list of agent indices
  71435. */
  71436. getAgents(): number[];
  71437. /**
  71438. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71439. * @param deltaTime in seconds
  71440. */
  71441. update(deltaTime: number): void;
  71442. /**
  71443. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71444. * The queries will try to find a solution within those bounds
  71445. * default is (1,1,1)
  71446. * @param extent x,y,z value that define the extent around the queries point of reference
  71447. */
  71448. setDefaultQueryExtent(extent: Vector3): void;
  71449. /**
  71450. * Get the Bounding box extent specified by setDefaultQueryExtent
  71451. * @returns the box extent values
  71452. */
  71453. getDefaultQueryExtent(): Vector3;
  71454. /**
  71455. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71456. * @param result output the box extent values
  71457. */
  71458. getDefaultQueryExtentToRef(result: Vector3): void;
  71459. /**
  71460. * Release all resources
  71461. */
  71462. dispose(): void;
  71463. }
  71464. }
  71465. declare module BABYLON {
  71466. /**
  71467. * Class used to enable access to IndexedDB
  71468. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71469. */
  71470. export class Database implements IOfflineProvider {
  71471. private _callbackManifestChecked;
  71472. private _currentSceneUrl;
  71473. private _db;
  71474. private _enableSceneOffline;
  71475. private _enableTexturesOffline;
  71476. private _manifestVersionFound;
  71477. private _mustUpdateRessources;
  71478. private _hasReachedQuota;
  71479. private _isSupported;
  71480. private _idbFactory;
  71481. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71482. private static IsUASupportingBlobStorage;
  71483. /**
  71484. * Gets a boolean indicating if Database storate is enabled (off by default)
  71485. */
  71486. static IDBStorageEnabled: boolean;
  71487. /**
  71488. * Gets a boolean indicating if scene must be saved in the database
  71489. */
  71490. get enableSceneOffline(): boolean;
  71491. /**
  71492. * Gets a boolean indicating if textures must be saved in the database
  71493. */
  71494. get enableTexturesOffline(): boolean;
  71495. /**
  71496. * Creates a new Database
  71497. * @param urlToScene defines the url to load the scene
  71498. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71499. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71500. */
  71501. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71502. private static _ParseURL;
  71503. private static _ReturnFullUrlLocation;
  71504. private _checkManifestFile;
  71505. /**
  71506. * Open the database and make it available
  71507. * @param successCallback defines the callback to call on success
  71508. * @param errorCallback defines the callback to call on error
  71509. */
  71510. open(successCallback: () => void, errorCallback: () => void): void;
  71511. /**
  71512. * Loads an image from the database
  71513. * @param url defines the url to load from
  71514. * @param image defines the target DOM image
  71515. */
  71516. loadImage(url: string, image: HTMLImageElement): void;
  71517. private _loadImageFromDBAsync;
  71518. private _saveImageIntoDBAsync;
  71519. private _checkVersionFromDB;
  71520. private _loadVersionFromDBAsync;
  71521. private _saveVersionIntoDBAsync;
  71522. /**
  71523. * Loads a file from database
  71524. * @param url defines the URL to load from
  71525. * @param sceneLoaded defines a callback to call on success
  71526. * @param progressCallBack defines a callback to call when progress changed
  71527. * @param errorCallback defines a callback to call on error
  71528. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71529. */
  71530. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71531. private _loadFileAsync;
  71532. private _saveFileAsync;
  71533. /**
  71534. * Validates if xhr data is correct
  71535. * @param xhr defines the request to validate
  71536. * @param dataType defines the expected data type
  71537. * @returns true if data is correct
  71538. */
  71539. private static _ValidateXHRData;
  71540. }
  71541. }
  71542. declare module BABYLON {
  71543. /** @hidden */
  71544. export var gpuUpdateParticlesPixelShader: {
  71545. name: string;
  71546. shader: string;
  71547. };
  71548. }
  71549. declare module BABYLON {
  71550. /** @hidden */
  71551. export var gpuUpdateParticlesVertexShader: {
  71552. name: string;
  71553. shader: string;
  71554. };
  71555. }
  71556. declare module BABYLON {
  71557. /** @hidden */
  71558. export var clipPlaneFragmentDeclaration2: {
  71559. name: string;
  71560. shader: string;
  71561. };
  71562. }
  71563. declare module BABYLON {
  71564. /** @hidden */
  71565. export var gpuRenderParticlesPixelShader: {
  71566. name: string;
  71567. shader: string;
  71568. };
  71569. }
  71570. declare module BABYLON {
  71571. /** @hidden */
  71572. export var clipPlaneVertexDeclaration2: {
  71573. name: string;
  71574. shader: string;
  71575. };
  71576. }
  71577. declare module BABYLON {
  71578. /** @hidden */
  71579. export var gpuRenderParticlesVertexShader: {
  71580. name: string;
  71581. shader: string;
  71582. };
  71583. }
  71584. declare module BABYLON {
  71585. /**
  71586. * This represents a GPU particle system in Babylon
  71587. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71588. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71589. */
  71590. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71591. /**
  71592. * The layer mask we are rendering the particles through.
  71593. */
  71594. layerMask: number;
  71595. private _capacity;
  71596. private _activeCount;
  71597. private _currentActiveCount;
  71598. private _accumulatedCount;
  71599. private _renderEffect;
  71600. private _updateEffect;
  71601. private _buffer0;
  71602. private _buffer1;
  71603. private _spriteBuffer;
  71604. private _updateVAO;
  71605. private _renderVAO;
  71606. private _targetIndex;
  71607. private _sourceBuffer;
  71608. private _targetBuffer;
  71609. private _currentRenderId;
  71610. private _started;
  71611. private _stopped;
  71612. private _timeDelta;
  71613. private _randomTexture;
  71614. private _randomTexture2;
  71615. private _attributesStrideSize;
  71616. private _updateEffectOptions;
  71617. private _randomTextureSize;
  71618. private _actualFrame;
  71619. private _customEffect;
  71620. private readonly _rawTextureWidth;
  71621. /**
  71622. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71623. */
  71624. static get IsSupported(): boolean;
  71625. /**
  71626. * An event triggered when the system is disposed.
  71627. */
  71628. onDisposeObservable: Observable<IParticleSystem>;
  71629. /**
  71630. * An event triggered when the system is stopped
  71631. */
  71632. onStoppedObservable: Observable<IParticleSystem>;
  71633. /**
  71634. * Gets the maximum number of particles active at the same time.
  71635. * @returns The max number of active particles.
  71636. */
  71637. getCapacity(): number;
  71638. /**
  71639. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71640. * to override the particles.
  71641. */
  71642. forceDepthWrite: boolean;
  71643. /**
  71644. * Gets or set the number of active particles
  71645. */
  71646. get activeParticleCount(): number;
  71647. set activeParticleCount(value: number);
  71648. private _preWarmDone;
  71649. /**
  71650. * Specifies if the particles are updated in emitter local space or world space.
  71651. */
  71652. isLocal: boolean;
  71653. /** Gets or sets a matrix to use to compute projection */
  71654. defaultProjectionMatrix: Matrix;
  71655. /**
  71656. * Is this system ready to be used/rendered
  71657. * @return true if the system is ready
  71658. */
  71659. isReady(): boolean;
  71660. /**
  71661. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71662. * @returns True if it has been started, otherwise false.
  71663. */
  71664. isStarted(): boolean;
  71665. /**
  71666. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71667. * @returns True if it has been stopped, otherwise false.
  71668. */
  71669. isStopped(): boolean;
  71670. /**
  71671. * Gets a boolean indicating that the system is stopping
  71672. * @returns true if the system is currently stopping
  71673. */
  71674. isStopping(): boolean;
  71675. /**
  71676. * Gets the number of particles active at the same time.
  71677. * @returns The number of active particles.
  71678. */
  71679. getActiveCount(): number;
  71680. /**
  71681. * Starts the particle system and begins to emit
  71682. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71683. */
  71684. start(delay?: number): void;
  71685. /**
  71686. * Stops the particle system.
  71687. */
  71688. stop(): void;
  71689. /**
  71690. * Remove all active particles
  71691. */
  71692. reset(): void;
  71693. /**
  71694. * Returns the string "GPUParticleSystem"
  71695. * @returns a string containing the class name
  71696. */
  71697. getClassName(): string;
  71698. /**
  71699. * Gets the custom effect used to render the particles
  71700. * @param blendMode Blend mode for which the effect should be retrieved
  71701. * @returns The effect
  71702. */
  71703. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71704. /**
  71705. * Sets the custom effect used to render the particles
  71706. * @param effect The effect to set
  71707. * @param blendMode Blend mode for which the effect should be set
  71708. */
  71709. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71710. /** @hidden */
  71711. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71712. /**
  71713. * Observable that will be called just before the particles are drawn
  71714. */
  71715. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71716. /**
  71717. * Gets the name of the particle vertex shader
  71718. */
  71719. get vertexShaderName(): string;
  71720. private _colorGradientsTexture;
  71721. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71722. /**
  71723. * Adds a new color gradient
  71724. * @param gradient defines the gradient to use (between 0 and 1)
  71725. * @param color1 defines the color to affect to the specified gradient
  71726. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71727. * @returns the current particle system
  71728. */
  71729. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71730. private _refreshColorGradient;
  71731. /** Force the system to rebuild all gradients that need to be resync */
  71732. forceRefreshGradients(): void;
  71733. /**
  71734. * Remove a specific color gradient
  71735. * @param gradient defines the gradient to remove
  71736. * @returns the current particle system
  71737. */
  71738. removeColorGradient(gradient: number): GPUParticleSystem;
  71739. private _angularSpeedGradientsTexture;
  71740. private _sizeGradientsTexture;
  71741. private _velocityGradientsTexture;
  71742. private _limitVelocityGradientsTexture;
  71743. private _dragGradientsTexture;
  71744. private _addFactorGradient;
  71745. /**
  71746. * Adds a new size gradient
  71747. * @param gradient defines the gradient to use (between 0 and 1)
  71748. * @param factor defines the size factor to affect to the specified gradient
  71749. * @returns the current particle system
  71750. */
  71751. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71752. /**
  71753. * Remove a specific size gradient
  71754. * @param gradient defines the gradient to remove
  71755. * @returns the current particle system
  71756. */
  71757. removeSizeGradient(gradient: number): GPUParticleSystem;
  71758. private _refreshFactorGradient;
  71759. /**
  71760. * Adds a new angular speed gradient
  71761. * @param gradient defines the gradient to use (between 0 and 1)
  71762. * @param factor defines the angular speed to affect to the specified gradient
  71763. * @returns the current particle system
  71764. */
  71765. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71766. /**
  71767. * Remove a specific angular speed gradient
  71768. * @param gradient defines the gradient to remove
  71769. * @returns the current particle system
  71770. */
  71771. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71772. /**
  71773. * Adds a new velocity gradient
  71774. * @param gradient defines the gradient to use (between 0 and 1)
  71775. * @param factor defines the velocity to affect to the specified gradient
  71776. * @returns the current particle system
  71777. */
  71778. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71779. /**
  71780. * Remove a specific velocity gradient
  71781. * @param gradient defines the gradient to remove
  71782. * @returns the current particle system
  71783. */
  71784. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71785. /**
  71786. * Adds a new limit velocity gradient
  71787. * @param gradient defines the gradient to use (between 0 and 1)
  71788. * @param factor defines the limit velocity value to affect to the specified gradient
  71789. * @returns the current particle system
  71790. */
  71791. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71792. /**
  71793. * Remove a specific limit velocity gradient
  71794. * @param gradient defines the gradient to remove
  71795. * @returns the current particle system
  71796. */
  71797. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71798. /**
  71799. * Adds a new drag gradient
  71800. * @param gradient defines the gradient to use (between 0 and 1)
  71801. * @param factor defines the drag value to affect to the specified gradient
  71802. * @returns the current particle system
  71803. */
  71804. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71805. /**
  71806. * Remove a specific drag gradient
  71807. * @param gradient defines the gradient to remove
  71808. * @returns the current particle system
  71809. */
  71810. removeDragGradient(gradient: number): GPUParticleSystem;
  71811. /**
  71812. * Not supported by GPUParticleSystem
  71813. * @param gradient defines the gradient to use (between 0 and 1)
  71814. * @param factor defines the emit rate value to affect to the specified gradient
  71815. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71816. * @returns the current particle system
  71817. */
  71818. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71819. /**
  71820. * Not supported by GPUParticleSystem
  71821. * @param gradient defines the gradient to remove
  71822. * @returns the current particle system
  71823. */
  71824. removeEmitRateGradient(gradient: number): IParticleSystem;
  71825. /**
  71826. * Not supported by GPUParticleSystem
  71827. * @param gradient defines the gradient to use (between 0 and 1)
  71828. * @param factor defines the start size value to affect to the specified gradient
  71829. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71830. * @returns the current particle system
  71831. */
  71832. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71833. /**
  71834. * Not supported by GPUParticleSystem
  71835. * @param gradient defines the gradient to remove
  71836. * @returns the current particle system
  71837. */
  71838. removeStartSizeGradient(gradient: number): IParticleSystem;
  71839. /**
  71840. * Not supported by GPUParticleSystem
  71841. * @param gradient defines the gradient to use (between 0 and 1)
  71842. * @param min defines the color remap minimal range
  71843. * @param max defines the color remap maximal range
  71844. * @returns the current particle system
  71845. */
  71846. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71847. /**
  71848. * Not supported by GPUParticleSystem
  71849. * @param gradient defines the gradient to remove
  71850. * @returns the current particle system
  71851. */
  71852. removeColorRemapGradient(): IParticleSystem;
  71853. /**
  71854. * Not supported by GPUParticleSystem
  71855. * @param gradient defines the gradient to use (between 0 and 1)
  71856. * @param min defines the alpha remap minimal range
  71857. * @param max defines the alpha remap maximal range
  71858. * @returns the current particle system
  71859. */
  71860. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71861. /**
  71862. * Not supported by GPUParticleSystem
  71863. * @param gradient defines the gradient to remove
  71864. * @returns the current particle system
  71865. */
  71866. removeAlphaRemapGradient(): IParticleSystem;
  71867. /**
  71868. * Not supported by GPUParticleSystem
  71869. * @param gradient defines the gradient to use (between 0 and 1)
  71870. * @param color defines the color to affect to the specified gradient
  71871. * @returns the current particle system
  71872. */
  71873. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71874. /**
  71875. * Not supported by GPUParticleSystem
  71876. * @param gradient defines the gradient to remove
  71877. * @returns the current particle system
  71878. */
  71879. removeRampGradient(): IParticleSystem;
  71880. /**
  71881. * Not supported by GPUParticleSystem
  71882. * @returns the list of ramp gradients
  71883. */
  71884. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71885. /**
  71886. * Not supported by GPUParticleSystem
  71887. * Gets or sets a boolean indicating that ramp gradients must be used
  71888. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71889. */
  71890. get useRampGradients(): boolean;
  71891. set useRampGradients(value: boolean);
  71892. /**
  71893. * Not supported by GPUParticleSystem
  71894. * @param gradient defines the gradient to use (between 0 and 1)
  71895. * @param factor defines the life time factor to affect to the specified gradient
  71896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71897. * @returns the current particle system
  71898. */
  71899. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71900. /**
  71901. * Not supported by GPUParticleSystem
  71902. * @param gradient defines the gradient to remove
  71903. * @returns the current particle system
  71904. */
  71905. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71906. /**
  71907. * Instantiates a GPU particle system.
  71908. * 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.
  71909. * @param name The name of the particle system
  71910. * @param options The options used to create the system
  71911. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71912. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71913. * @param customEffect a custom effect used to change the way particles are rendered by default
  71914. */
  71915. constructor(name: string, options: Partial<{
  71916. capacity: number;
  71917. randomTextureSize: number;
  71918. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71919. protected _reset(): void;
  71920. private _createUpdateVAO;
  71921. private _createRenderVAO;
  71922. private _initialize;
  71923. /** @hidden */
  71924. _recreateUpdateEffect(): void;
  71925. private _getEffect;
  71926. /**
  71927. * Fill the defines array according to the current settings of the particle system
  71928. * @param defines Array to be updated
  71929. * @param blendMode blend mode to take into account when updating the array
  71930. */
  71931. fillDefines(defines: Array<string>, blendMode?: number): void;
  71932. /**
  71933. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71934. * @param uniforms Uniforms array to fill
  71935. * @param attributes Attributes array to fill
  71936. * @param samplers Samplers array to fill
  71937. */
  71938. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71939. /** @hidden */
  71940. _recreateRenderEffect(): Effect;
  71941. /**
  71942. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71943. * @param preWarm defines if we are in the pre-warmimg phase
  71944. */
  71945. animate(preWarm?: boolean): void;
  71946. private _createFactorGradientTexture;
  71947. private _createSizeGradientTexture;
  71948. private _createAngularSpeedGradientTexture;
  71949. private _createVelocityGradientTexture;
  71950. private _createLimitVelocityGradientTexture;
  71951. private _createDragGradientTexture;
  71952. private _createColorGradientTexture;
  71953. /**
  71954. * Renders the particle system in its current state
  71955. * @param preWarm defines if the system should only update the particles but not render them
  71956. * @returns the current number of particles
  71957. */
  71958. render(preWarm?: boolean): number;
  71959. /**
  71960. * Rebuilds the particle system
  71961. */
  71962. rebuild(): void;
  71963. private _releaseBuffers;
  71964. private _releaseVAOs;
  71965. /**
  71966. * Disposes the particle system and free the associated resources
  71967. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71968. */
  71969. dispose(disposeTexture?: boolean): void;
  71970. /**
  71971. * Clones the particle system.
  71972. * @param name The name of the cloned object
  71973. * @param newEmitter The new emitter to use
  71974. * @returns the cloned particle system
  71975. */
  71976. clone(name: string, newEmitter: any): GPUParticleSystem;
  71977. /**
  71978. * Serializes the particle system to a JSON object
  71979. * @param serializeTexture defines if the texture must be serialized as well
  71980. * @returns the JSON object
  71981. */
  71982. serialize(serializeTexture?: boolean): any;
  71983. /**
  71984. * Parses a JSON object to create a GPU particle system.
  71985. * @param parsedParticleSystem The JSON object to parse
  71986. * @param sceneOrEngine The scene or the engine to create the particle system in
  71987. * @param rootUrl The root url to use to load external dependencies like texture
  71988. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71989. * @returns the parsed GPU particle system
  71990. */
  71991. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71992. }
  71993. }
  71994. declare module BABYLON {
  71995. /**
  71996. * Represents a set of particle systems working together to create a specific effect
  71997. */
  71998. export class ParticleSystemSet implements IDisposable {
  71999. /**
  72000. * Gets or sets base Assets URL
  72001. */
  72002. static BaseAssetsUrl: string;
  72003. private _emitterCreationOptions;
  72004. private _emitterNode;
  72005. /**
  72006. * Gets the particle system list
  72007. */
  72008. systems: IParticleSystem[];
  72009. /**
  72010. * Gets the emitter node used with this set
  72011. */
  72012. get emitterNode(): Nullable<TransformNode>;
  72013. /**
  72014. * Creates a new emitter mesh as a sphere
  72015. * @param options defines the options used to create the sphere
  72016. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72017. * @param scene defines the hosting scene
  72018. */
  72019. setEmitterAsSphere(options: {
  72020. diameter: number;
  72021. segments: number;
  72022. color: Color3;
  72023. }, renderingGroupId: number, scene: Scene): void;
  72024. /**
  72025. * Starts all particle systems of the set
  72026. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72027. */
  72028. start(emitter?: AbstractMesh): void;
  72029. /**
  72030. * Release all associated resources
  72031. */
  72032. dispose(): void;
  72033. /**
  72034. * Serialize the set into a JSON compatible object
  72035. * @param serializeTexture defines if the texture must be serialized as well
  72036. * @returns a JSON compatible representation of the set
  72037. */
  72038. serialize(serializeTexture?: boolean): any;
  72039. /**
  72040. * Parse a new ParticleSystemSet from a serialized source
  72041. * @param data defines a JSON compatible representation of the set
  72042. * @param scene defines the hosting scene
  72043. * @param gpu defines if we want GPU particles or CPU particles
  72044. * @returns a new ParticleSystemSet
  72045. */
  72046. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72047. }
  72048. }
  72049. declare module BABYLON {
  72050. /**
  72051. * This class is made for on one-liner static method to help creating particle system set.
  72052. */
  72053. export class ParticleHelper {
  72054. /**
  72055. * Gets or sets base Assets URL
  72056. */
  72057. static BaseAssetsUrl: string;
  72058. /** Define the Url to load snippets */
  72059. static SnippetUrl: string;
  72060. /**
  72061. * Create a default particle system that you can tweak
  72062. * @param emitter defines the emitter to use
  72063. * @param capacity defines the system capacity (default is 500 particles)
  72064. * @param scene defines the hosting scene
  72065. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72066. * @returns the new Particle system
  72067. */
  72068. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72069. /**
  72070. * This is the main static method (one-liner) of this helper to create different particle systems
  72071. * @param type This string represents the type to the particle system to create
  72072. * @param scene The scene where the particle system should live
  72073. * @param gpu If the system will use gpu
  72074. * @returns the ParticleSystemSet created
  72075. */
  72076. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72077. /**
  72078. * Static function used to export a particle system to a ParticleSystemSet variable.
  72079. * Please note that the emitter shape is not exported
  72080. * @param systems defines the particle systems to export
  72081. * @returns the created particle system set
  72082. */
  72083. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72084. /**
  72085. * Creates a particle system from a snippet saved in a remote file
  72086. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72087. * @param url defines the url to load from
  72088. * @param scene defines the hosting scene
  72089. * @param gpu If the system will use gpu
  72090. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72091. * @returns a promise that will resolve to the new particle system
  72092. */
  72093. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72094. /**
  72095. * Creates a particle system from a snippet saved by the particle system editor
  72096. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72097. * @param scene defines the hosting scene
  72098. * @param gpu If the system will use gpu
  72099. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72100. * @returns a promise that will resolve to the new particle system
  72101. */
  72102. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72103. }
  72104. }
  72105. declare module BABYLON {
  72106. interface Engine {
  72107. /**
  72108. * Create an effect to use with particle systems.
  72109. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72110. * the particle system for which you want to create a custom effect in the last parameter
  72111. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72112. * @param uniformsNames defines a list of attribute names
  72113. * @param samplers defines an array of string used to represent textures
  72114. * @param defines defines the string containing the defines to use to compile the shaders
  72115. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72116. * @param onCompiled defines a function to call when the effect creation is successful
  72117. * @param onError defines a function to call when the effect creation has failed
  72118. * @param particleSystem the particle system you want to create the effect for
  72119. * @returns the new Effect
  72120. */
  72121. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72122. }
  72123. interface Mesh {
  72124. /**
  72125. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72126. * @returns an array of IParticleSystem
  72127. */
  72128. getEmittedParticleSystems(): IParticleSystem[];
  72129. /**
  72130. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72131. * @returns an array of IParticleSystem
  72132. */
  72133. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72134. }
  72135. }
  72136. declare module BABYLON {
  72137. /** Defines the 4 color options */
  72138. export enum PointColor {
  72139. /** color value */
  72140. Color = 2,
  72141. /** uv value */
  72142. UV = 1,
  72143. /** random value */
  72144. Random = 0,
  72145. /** stated value */
  72146. Stated = 3
  72147. }
  72148. /**
  72149. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72150. * 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.
  72151. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72152. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72153. *
  72154. * Full documentation here : TO BE ENTERED
  72155. */
  72156. export class PointsCloudSystem implements IDisposable {
  72157. /**
  72158. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72159. * Example : var p = SPS.particles[i];
  72160. */
  72161. particles: CloudPoint[];
  72162. /**
  72163. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72164. */
  72165. nbParticles: number;
  72166. /**
  72167. * This a counter for your own usage. It's not set by any SPS functions.
  72168. */
  72169. counter: number;
  72170. /**
  72171. * The PCS name. This name is also given to the underlying mesh.
  72172. */
  72173. name: string;
  72174. /**
  72175. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72176. */
  72177. mesh: Mesh;
  72178. /**
  72179. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72180. * Please read :
  72181. */
  72182. vars: any;
  72183. /**
  72184. * @hidden
  72185. */
  72186. _size: number;
  72187. private _scene;
  72188. private _promises;
  72189. private _positions;
  72190. private _indices;
  72191. private _normals;
  72192. private _colors;
  72193. private _uvs;
  72194. private _indices32;
  72195. private _positions32;
  72196. private _colors32;
  72197. private _uvs32;
  72198. private _updatable;
  72199. private _isVisibilityBoxLocked;
  72200. private _alwaysVisible;
  72201. private _groups;
  72202. private _groupCounter;
  72203. private _computeParticleColor;
  72204. private _computeParticleTexture;
  72205. private _computeParticleRotation;
  72206. private _computeBoundingBox;
  72207. private _isReady;
  72208. /**
  72209. * Creates a PCS (Points Cloud System) object
  72210. * @param name (String) is the PCS name, this will be the underlying mesh name
  72211. * @param pointSize (number) is the size for each point
  72212. * @param scene (Scene) is the scene in which the PCS is added
  72213. * @param options defines the options of the PCS e.g.
  72214. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72215. */
  72216. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72217. updatable?: boolean;
  72218. });
  72219. /**
  72220. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72221. * If no points were added to the PCS, the returned mesh is just a single point.
  72222. * @returns a promise for the created mesh
  72223. */
  72224. buildMeshAsync(): Promise<Mesh>;
  72225. /**
  72226. * @hidden
  72227. */
  72228. private _buildMesh;
  72229. private _addParticle;
  72230. private _randomUnitVector;
  72231. private _getColorIndicesForCoord;
  72232. private _setPointsColorOrUV;
  72233. private _colorFromTexture;
  72234. private _calculateDensity;
  72235. /**
  72236. * Adds points to the PCS in random positions within a unit sphere
  72237. * @param nb (positive integer) the number of particles to be created from this model
  72238. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72239. * @returns the number of groups in the system
  72240. */
  72241. addPoints(nb: number, pointFunction?: any): number;
  72242. /**
  72243. * Adds points to the PCS from the surface of the model shape
  72244. * @param mesh is any Mesh object that will be used as a surface model for the points
  72245. * @param nb (positive integer) the number of particles to be created from this model
  72246. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72247. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72248. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72249. * @returns the number of groups in the system
  72250. */
  72251. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72252. /**
  72253. * Adds points to the PCS inside the model shape
  72254. * @param mesh is any Mesh object that will be used as a surface model for the points
  72255. * @param nb (positive integer) the number of particles to be created from this model
  72256. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72257. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72258. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72259. * @returns the number of groups in the system
  72260. */
  72261. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72262. /**
  72263. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72264. * This method calls `updateParticle()` for each particle of the SPS.
  72265. * For an animated SPS, it is usually called within the render loop.
  72266. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72267. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72268. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72269. * @returns the PCS.
  72270. */
  72271. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72272. /**
  72273. * Disposes the PCS.
  72274. */
  72275. dispose(): void;
  72276. /**
  72277. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72278. * doc :
  72279. * @returns the PCS.
  72280. */
  72281. refreshVisibleSize(): PointsCloudSystem;
  72282. /**
  72283. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72284. * @param size the size (float) of the visibility box
  72285. * note : this doesn't lock the PCS mesh bounding box.
  72286. * doc :
  72287. */
  72288. setVisibilityBox(size: number): void;
  72289. /**
  72290. * Gets whether the PCS is always visible or not
  72291. * doc :
  72292. */
  72293. get isAlwaysVisible(): boolean;
  72294. /**
  72295. * Sets the PCS as always visible or not
  72296. * doc :
  72297. */
  72298. set isAlwaysVisible(val: boolean);
  72299. /**
  72300. * Tells to `setParticles()` to compute the particle rotations or not
  72301. * Default value : false. The PCS is faster when it's set to false
  72302. * Note : particle rotations are only applied to parent particles
  72303. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72304. */
  72305. set computeParticleRotation(val: boolean);
  72306. /**
  72307. * Tells to `setParticles()` to compute the particle colors or not.
  72308. * Default value : true. The PCS is faster when it's set to false.
  72309. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72310. */
  72311. set computeParticleColor(val: boolean);
  72312. set computeParticleTexture(val: boolean);
  72313. /**
  72314. * Gets if `setParticles()` computes the particle colors or not.
  72315. * Default value : false. The PCS is faster when it's set to false.
  72316. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72317. */
  72318. get computeParticleColor(): boolean;
  72319. /**
  72320. * Gets if `setParticles()` computes the particle textures or not.
  72321. * Default value : false. The PCS is faster when it's set to false.
  72322. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72323. */
  72324. get computeParticleTexture(): boolean;
  72325. /**
  72326. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72327. */
  72328. set computeBoundingBox(val: boolean);
  72329. /**
  72330. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72331. */
  72332. get computeBoundingBox(): boolean;
  72333. /**
  72334. * This function does nothing. It may be overwritten to set all the particle first values.
  72335. * The PCS doesn't call this function, you may have to call it by your own.
  72336. * doc :
  72337. */
  72338. initParticles(): void;
  72339. /**
  72340. * This function does nothing. It may be overwritten to recycle a particle
  72341. * The PCS doesn't call this function, you can to call it
  72342. * doc :
  72343. * @param particle The particle to recycle
  72344. * @returns the recycled particle
  72345. */
  72346. recycleParticle(particle: CloudPoint): CloudPoint;
  72347. /**
  72348. * Updates a particle : this function should be overwritten by the user.
  72349. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72350. * doc :
  72351. * @example : just set a particle position or velocity and recycle conditions
  72352. * @param particle The particle to update
  72353. * @returns the updated particle
  72354. */
  72355. updateParticle(particle: CloudPoint): CloudPoint;
  72356. /**
  72357. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72358. * This does nothing and may be overwritten by the user.
  72359. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72360. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72361. * @param update the boolean update value actually passed to setParticles()
  72362. */
  72363. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72364. /**
  72365. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72366. * This will be passed three parameters.
  72367. * This does nothing and may be overwritten by the user.
  72368. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72369. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72370. * @param update the boolean update value actually passed to setParticles()
  72371. */
  72372. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72373. }
  72374. }
  72375. declare module BABYLON {
  72376. /**
  72377. * Represents one particle of a points cloud system.
  72378. */
  72379. export class CloudPoint {
  72380. /**
  72381. * particle global index
  72382. */
  72383. idx: number;
  72384. /**
  72385. * The color of the particle
  72386. */
  72387. color: Nullable<Color4>;
  72388. /**
  72389. * The world space position of the particle.
  72390. */
  72391. position: Vector3;
  72392. /**
  72393. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72394. */
  72395. rotation: Vector3;
  72396. /**
  72397. * The world space rotation quaternion of the particle.
  72398. */
  72399. rotationQuaternion: Nullable<Quaternion>;
  72400. /**
  72401. * The uv of the particle.
  72402. */
  72403. uv: Nullable<Vector2>;
  72404. /**
  72405. * The current speed of the particle.
  72406. */
  72407. velocity: Vector3;
  72408. /**
  72409. * The pivot point in the particle local space.
  72410. */
  72411. pivot: Vector3;
  72412. /**
  72413. * Must the particle be translated from its pivot point in its local space ?
  72414. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72415. * Default : false
  72416. */
  72417. translateFromPivot: boolean;
  72418. /**
  72419. * Index of this particle in the global "positions" array (Internal use)
  72420. * @hidden
  72421. */
  72422. _pos: number;
  72423. /**
  72424. * @hidden Index of this particle in the global "indices" array (Internal use)
  72425. */
  72426. _ind: number;
  72427. /**
  72428. * Group this particle belongs to
  72429. */
  72430. _group: PointsGroup;
  72431. /**
  72432. * Group id of this particle
  72433. */
  72434. groupId: number;
  72435. /**
  72436. * Index of the particle in its group id (Internal use)
  72437. */
  72438. idxInGroup: number;
  72439. /**
  72440. * @hidden Particle BoundingInfo object (Internal use)
  72441. */
  72442. _boundingInfo: BoundingInfo;
  72443. /**
  72444. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72445. */
  72446. _pcs: PointsCloudSystem;
  72447. /**
  72448. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72449. */
  72450. _stillInvisible: boolean;
  72451. /**
  72452. * @hidden Last computed particle rotation matrix
  72453. */
  72454. _rotationMatrix: number[];
  72455. /**
  72456. * Parent particle Id, if any.
  72457. * Default null.
  72458. */
  72459. parentId: Nullable<number>;
  72460. /**
  72461. * @hidden Internal global position in the PCS.
  72462. */
  72463. _globalPosition: Vector3;
  72464. /**
  72465. * Creates a Point Cloud object.
  72466. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72467. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72468. * @param group (PointsGroup) is the group the particle belongs to
  72469. * @param groupId (integer) is the group identifier in the PCS.
  72470. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72471. * @param pcs defines the PCS it is associated to
  72472. */
  72473. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72474. /**
  72475. * get point size
  72476. */
  72477. get size(): Vector3;
  72478. /**
  72479. * Set point size
  72480. */
  72481. set size(scale: Vector3);
  72482. /**
  72483. * Legacy support, changed quaternion to rotationQuaternion
  72484. */
  72485. get quaternion(): Nullable<Quaternion>;
  72486. /**
  72487. * Legacy support, changed quaternion to rotationQuaternion
  72488. */
  72489. set quaternion(q: Nullable<Quaternion>);
  72490. /**
  72491. * Returns a boolean. True if the particle intersects a mesh, else false
  72492. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72493. * @param target is the object (point or mesh) what the intersection is computed against
  72494. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72495. * @returns true if it intersects
  72496. */
  72497. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72498. /**
  72499. * get the rotation matrix of the particle
  72500. * @hidden
  72501. */
  72502. getRotationMatrix(m: Matrix): void;
  72503. }
  72504. /**
  72505. * Represents a group of points in a points cloud system
  72506. * * PCS internal tool, don't use it manually.
  72507. */
  72508. export class PointsGroup {
  72509. /**
  72510. * The group id
  72511. * @hidden
  72512. */
  72513. groupID: number;
  72514. /**
  72515. * image data for group (internal use)
  72516. * @hidden
  72517. */
  72518. _groupImageData: Nullable<ArrayBufferView>;
  72519. /**
  72520. * Image Width (internal use)
  72521. * @hidden
  72522. */
  72523. _groupImgWidth: number;
  72524. /**
  72525. * Image Height (internal use)
  72526. * @hidden
  72527. */
  72528. _groupImgHeight: number;
  72529. /**
  72530. * Custom position function (internal use)
  72531. * @hidden
  72532. */
  72533. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72534. /**
  72535. * density per facet for surface points
  72536. * @hidden
  72537. */
  72538. _groupDensity: number[];
  72539. /**
  72540. * Only when points are colored by texture carries pointer to texture list array
  72541. * @hidden
  72542. */
  72543. _textureNb: number;
  72544. /**
  72545. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72546. * PCS internal tool, don't use it manually.
  72547. * @hidden
  72548. */
  72549. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72550. }
  72551. }
  72552. declare module BABYLON {
  72553. interface Scene {
  72554. /** @hidden (Backing field) */
  72555. _physicsEngine: Nullable<IPhysicsEngine>;
  72556. /** @hidden */
  72557. _physicsTimeAccumulator: number;
  72558. /**
  72559. * Gets the current physics engine
  72560. * @returns a IPhysicsEngine or null if none attached
  72561. */
  72562. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72563. /**
  72564. * Enables physics to the current scene
  72565. * @param gravity defines the scene's gravity for the physics engine
  72566. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72567. * @return a boolean indicating if the physics engine was initialized
  72568. */
  72569. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72570. /**
  72571. * Disables and disposes the physics engine associated with the scene
  72572. */
  72573. disablePhysicsEngine(): void;
  72574. /**
  72575. * Gets a boolean indicating if there is an active physics engine
  72576. * @returns a boolean indicating if there is an active physics engine
  72577. */
  72578. isPhysicsEnabled(): boolean;
  72579. /**
  72580. * Deletes a physics compound impostor
  72581. * @param compound defines the compound to delete
  72582. */
  72583. deleteCompoundImpostor(compound: any): void;
  72584. /**
  72585. * An event triggered when physic simulation is about to be run
  72586. */
  72587. onBeforePhysicsObservable: Observable<Scene>;
  72588. /**
  72589. * An event triggered when physic simulation has been done
  72590. */
  72591. onAfterPhysicsObservable: Observable<Scene>;
  72592. }
  72593. interface AbstractMesh {
  72594. /** @hidden */
  72595. _physicsImpostor: Nullable<PhysicsImpostor>;
  72596. /**
  72597. * Gets or sets impostor used for physic simulation
  72598. * @see https://doc.babylonjs.com/features/physics_engine
  72599. */
  72600. physicsImpostor: Nullable<PhysicsImpostor>;
  72601. /**
  72602. * Gets the current physics impostor
  72603. * @see https://doc.babylonjs.com/features/physics_engine
  72604. * @returns a physics impostor or null
  72605. */
  72606. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72607. /** Apply a physic impulse to the mesh
  72608. * @param force defines the force to apply
  72609. * @param contactPoint defines where to apply the force
  72610. * @returns the current mesh
  72611. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72612. */
  72613. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72614. /**
  72615. * Creates a physic joint between two meshes
  72616. * @param otherMesh defines the other mesh to use
  72617. * @param pivot1 defines the pivot to use on this mesh
  72618. * @param pivot2 defines the pivot to use on the other mesh
  72619. * @param options defines additional options (can be plugin dependent)
  72620. * @returns the current mesh
  72621. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72622. */
  72623. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72624. /** @hidden */
  72625. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72626. }
  72627. /**
  72628. * Defines the physics engine scene component responsible to manage a physics engine
  72629. */
  72630. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72631. /**
  72632. * The component name helpful to identify the component in the list of scene components.
  72633. */
  72634. readonly name: string;
  72635. /**
  72636. * The scene the component belongs to.
  72637. */
  72638. scene: Scene;
  72639. /**
  72640. * Creates a new instance of the component for the given scene
  72641. * @param scene Defines the scene to register the component in
  72642. */
  72643. constructor(scene: Scene);
  72644. /**
  72645. * Registers the component in a given scene
  72646. */
  72647. register(): void;
  72648. /**
  72649. * Rebuilds the elements related to this component in case of
  72650. * context lost for instance.
  72651. */
  72652. rebuild(): void;
  72653. /**
  72654. * Disposes the component and the associated ressources
  72655. */
  72656. dispose(): void;
  72657. }
  72658. }
  72659. declare module BABYLON {
  72660. /**
  72661. * A helper for physics simulations
  72662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72663. */
  72664. export class PhysicsHelper {
  72665. private _scene;
  72666. private _physicsEngine;
  72667. /**
  72668. * Initializes the Physics helper
  72669. * @param scene Babylon.js scene
  72670. */
  72671. constructor(scene: Scene);
  72672. /**
  72673. * Applies a radial explosion impulse
  72674. * @param origin the origin of the explosion
  72675. * @param radiusOrEventOptions the radius or the options of radial explosion
  72676. * @param strength the explosion strength
  72677. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72678. * @returns A physics radial explosion event, or null
  72679. */
  72680. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72681. /**
  72682. * Applies a radial explosion force
  72683. * @param origin the origin of the explosion
  72684. * @param radiusOrEventOptions the radius or the options of radial explosion
  72685. * @param strength the explosion strength
  72686. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72687. * @returns A physics radial explosion event, or null
  72688. */
  72689. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72690. /**
  72691. * Creates a gravitational field
  72692. * @param origin the origin of the explosion
  72693. * @param radiusOrEventOptions the radius or the options of radial explosion
  72694. * @param strength the explosion strength
  72695. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72696. * @returns A physics gravitational field event, or null
  72697. */
  72698. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72699. /**
  72700. * Creates a physics updraft event
  72701. * @param origin the origin of the updraft
  72702. * @param radiusOrEventOptions the radius or the options of the updraft
  72703. * @param strength the strength of the updraft
  72704. * @param height the height of the updraft
  72705. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72706. * @returns A physics updraft event, or null
  72707. */
  72708. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72709. /**
  72710. * Creates a physics vortex event
  72711. * @param origin the of the vortex
  72712. * @param radiusOrEventOptions the radius or the options of the vortex
  72713. * @param strength the strength of the vortex
  72714. * @param height the height of the vortex
  72715. * @returns a Physics vortex event, or null
  72716. * A physics vortex event or null
  72717. */
  72718. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72719. }
  72720. /**
  72721. * Represents a physics radial explosion event
  72722. */
  72723. class PhysicsRadialExplosionEvent {
  72724. private _scene;
  72725. private _options;
  72726. private _sphere;
  72727. private _dataFetched;
  72728. /**
  72729. * Initializes a radial explosioin event
  72730. * @param _scene BabylonJS scene
  72731. * @param _options The options for the vortex event
  72732. */
  72733. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72734. /**
  72735. * Returns the data related to the radial explosion event (sphere).
  72736. * @returns The radial explosion event data
  72737. */
  72738. getData(): PhysicsRadialExplosionEventData;
  72739. /**
  72740. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72741. * @param impostor A physics imposter
  72742. * @param origin the origin of the explosion
  72743. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72744. */
  72745. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72746. /**
  72747. * Triggers affecterd impostors callbacks
  72748. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72749. */
  72750. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72751. /**
  72752. * Disposes the sphere.
  72753. * @param force Specifies if the sphere should be disposed by force
  72754. */
  72755. dispose(force?: boolean): void;
  72756. /*** Helpers ***/
  72757. private _prepareSphere;
  72758. private _intersectsWithSphere;
  72759. }
  72760. /**
  72761. * Represents a gravitational field event
  72762. */
  72763. class PhysicsGravitationalFieldEvent {
  72764. private _physicsHelper;
  72765. private _scene;
  72766. private _origin;
  72767. private _options;
  72768. private _tickCallback;
  72769. private _sphere;
  72770. private _dataFetched;
  72771. /**
  72772. * Initializes the physics gravitational field event
  72773. * @param _physicsHelper A physics helper
  72774. * @param _scene BabylonJS scene
  72775. * @param _origin The origin position of the gravitational field event
  72776. * @param _options The options for the vortex event
  72777. */
  72778. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72779. /**
  72780. * Returns the data related to the gravitational field event (sphere).
  72781. * @returns A gravitational field event
  72782. */
  72783. getData(): PhysicsGravitationalFieldEventData;
  72784. /**
  72785. * Enables the gravitational field.
  72786. */
  72787. enable(): void;
  72788. /**
  72789. * Disables the gravitational field.
  72790. */
  72791. disable(): void;
  72792. /**
  72793. * Disposes the sphere.
  72794. * @param force The force to dispose from the gravitational field event
  72795. */
  72796. dispose(force?: boolean): void;
  72797. private _tick;
  72798. }
  72799. /**
  72800. * Represents a physics updraft event
  72801. */
  72802. class PhysicsUpdraftEvent {
  72803. private _scene;
  72804. private _origin;
  72805. private _options;
  72806. private _physicsEngine;
  72807. private _originTop;
  72808. private _originDirection;
  72809. private _tickCallback;
  72810. private _cylinder;
  72811. private _cylinderPosition;
  72812. private _dataFetched;
  72813. /**
  72814. * Initializes the physics updraft event
  72815. * @param _scene BabylonJS scene
  72816. * @param _origin The origin position of the updraft
  72817. * @param _options The options for the updraft event
  72818. */
  72819. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72820. /**
  72821. * Returns the data related to the updraft event (cylinder).
  72822. * @returns A physics updraft event
  72823. */
  72824. getData(): PhysicsUpdraftEventData;
  72825. /**
  72826. * Enables the updraft.
  72827. */
  72828. enable(): void;
  72829. /**
  72830. * Disables the updraft.
  72831. */
  72832. disable(): void;
  72833. /**
  72834. * Disposes the cylinder.
  72835. * @param force Specifies if the updraft should be disposed by force
  72836. */
  72837. dispose(force?: boolean): void;
  72838. private getImpostorHitData;
  72839. private _tick;
  72840. /*** Helpers ***/
  72841. private _prepareCylinder;
  72842. private _intersectsWithCylinder;
  72843. }
  72844. /**
  72845. * Represents a physics vortex event
  72846. */
  72847. class PhysicsVortexEvent {
  72848. private _scene;
  72849. private _origin;
  72850. private _options;
  72851. private _physicsEngine;
  72852. private _originTop;
  72853. private _tickCallback;
  72854. private _cylinder;
  72855. private _cylinderPosition;
  72856. private _dataFetched;
  72857. /**
  72858. * Initializes the physics vortex event
  72859. * @param _scene The BabylonJS scene
  72860. * @param _origin The origin position of the vortex
  72861. * @param _options The options for the vortex event
  72862. */
  72863. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72864. /**
  72865. * Returns the data related to the vortex event (cylinder).
  72866. * @returns The physics vortex event data
  72867. */
  72868. getData(): PhysicsVortexEventData;
  72869. /**
  72870. * Enables the vortex.
  72871. */
  72872. enable(): void;
  72873. /**
  72874. * Disables the cortex.
  72875. */
  72876. disable(): void;
  72877. /**
  72878. * Disposes the sphere.
  72879. * @param force
  72880. */
  72881. dispose(force?: boolean): void;
  72882. private getImpostorHitData;
  72883. private _tick;
  72884. /*** Helpers ***/
  72885. private _prepareCylinder;
  72886. private _intersectsWithCylinder;
  72887. }
  72888. /**
  72889. * Options fot the radial explosion event
  72890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72891. */
  72892. export class PhysicsRadialExplosionEventOptions {
  72893. /**
  72894. * The radius of the sphere for the radial explosion.
  72895. */
  72896. radius: number;
  72897. /**
  72898. * The strenth of the explosion.
  72899. */
  72900. strength: number;
  72901. /**
  72902. * The strenght of the force in correspondence to the distance of the affected object
  72903. */
  72904. falloff: PhysicsRadialImpulseFalloff;
  72905. /**
  72906. * Sphere options for the radial explosion.
  72907. */
  72908. sphere: {
  72909. segments: number;
  72910. diameter: number;
  72911. };
  72912. /**
  72913. * Sphere options for the radial explosion.
  72914. */
  72915. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72916. }
  72917. /**
  72918. * Options fot the updraft event
  72919. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72920. */
  72921. export class PhysicsUpdraftEventOptions {
  72922. /**
  72923. * The radius of the cylinder for the vortex
  72924. */
  72925. radius: number;
  72926. /**
  72927. * The strenth of the updraft.
  72928. */
  72929. strength: number;
  72930. /**
  72931. * The height of the cylinder for the updraft.
  72932. */
  72933. height: number;
  72934. /**
  72935. * The mode for the the updraft.
  72936. */
  72937. updraftMode: PhysicsUpdraftMode;
  72938. }
  72939. /**
  72940. * Options fot the vortex event
  72941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72942. */
  72943. export class PhysicsVortexEventOptions {
  72944. /**
  72945. * The radius of the cylinder for the vortex
  72946. */
  72947. radius: number;
  72948. /**
  72949. * The strenth of the vortex.
  72950. */
  72951. strength: number;
  72952. /**
  72953. * The height of the cylinder for the vortex.
  72954. */
  72955. height: number;
  72956. /**
  72957. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72958. */
  72959. centripetalForceThreshold: number;
  72960. /**
  72961. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72962. */
  72963. centripetalForceMultiplier: number;
  72964. /**
  72965. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72966. */
  72967. centrifugalForceMultiplier: number;
  72968. /**
  72969. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72970. */
  72971. updraftForceMultiplier: number;
  72972. }
  72973. /**
  72974. * The strenght of the force in correspondence to the distance of the affected object
  72975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72976. */
  72977. export enum PhysicsRadialImpulseFalloff {
  72978. /** Defines that impulse is constant in strength across it's whole radius */
  72979. Constant = 0,
  72980. /** Defines that impulse gets weaker if it's further from the origin */
  72981. Linear = 1
  72982. }
  72983. /**
  72984. * The strength of the force in correspondence to the distance of the affected object
  72985. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72986. */
  72987. export enum PhysicsUpdraftMode {
  72988. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72989. Center = 0,
  72990. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72991. Perpendicular = 1
  72992. }
  72993. /**
  72994. * Interface for a physics hit data
  72995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72996. */
  72997. export interface PhysicsHitData {
  72998. /**
  72999. * The force applied at the contact point
  73000. */
  73001. force: Vector3;
  73002. /**
  73003. * The contact point
  73004. */
  73005. contactPoint: Vector3;
  73006. /**
  73007. * The distance from the origin to the contact point
  73008. */
  73009. distanceFromOrigin: number;
  73010. }
  73011. /**
  73012. * Interface for radial explosion event data
  73013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73014. */
  73015. export interface PhysicsRadialExplosionEventData {
  73016. /**
  73017. * A sphere used for the radial explosion event
  73018. */
  73019. sphere: Mesh;
  73020. }
  73021. /**
  73022. * Interface for gravitational field event data
  73023. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73024. */
  73025. export interface PhysicsGravitationalFieldEventData {
  73026. /**
  73027. * A sphere mesh used for the gravitational field event
  73028. */
  73029. sphere: Mesh;
  73030. }
  73031. /**
  73032. * Interface for updraft event data
  73033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73034. */
  73035. export interface PhysicsUpdraftEventData {
  73036. /**
  73037. * A cylinder used for the updraft event
  73038. */
  73039. cylinder: Mesh;
  73040. }
  73041. /**
  73042. * Interface for vortex event data
  73043. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73044. */
  73045. export interface PhysicsVortexEventData {
  73046. /**
  73047. * A cylinder used for the vortex event
  73048. */
  73049. cylinder: Mesh;
  73050. }
  73051. /**
  73052. * Interface for an affected physics impostor
  73053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73054. */
  73055. export interface PhysicsAffectedImpostorWithData {
  73056. /**
  73057. * The impostor affected by the effect
  73058. */
  73059. impostor: PhysicsImpostor;
  73060. /**
  73061. * The data about the hit/horce from the explosion
  73062. */
  73063. hitData: PhysicsHitData;
  73064. }
  73065. }
  73066. declare module BABYLON {
  73067. /** @hidden */
  73068. export var blackAndWhitePixelShader: {
  73069. name: string;
  73070. shader: string;
  73071. };
  73072. }
  73073. declare module BABYLON {
  73074. /**
  73075. * Post process used to render in black and white
  73076. */
  73077. export class BlackAndWhitePostProcess extends PostProcess {
  73078. /**
  73079. * Linear about to convert he result to black and white (default: 1)
  73080. */
  73081. degree: number;
  73082. /**
  73083. * Gets a string identifying the name of the class
  73084. * @returns "BlackAndWhitePostProcess" string
  73085. */
  73086. getClassName(): string;
  73087. /**
  73088. * Creates a black and white post process
  73089. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73090. * @param name The name of the effect.
  73091. * @param options The required width/height ratio to downsize to before computing the render pass.
  73092. * @param camera The camera to apply the render pass to.
  73093. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73094. * @param engine The engine which the post process will be applied. (default: current engine)
  73095. * @param reusable If the post process can be reused on the same frame. (default: false)
  73096. */
  73097. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73098. /** @hidden */
  73099. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73100. }
  73101. }
  73102. declare module BABYLON {
  73103. /**
  73104. * This represents a set of one or more post processes in Babylon.
  73105. * A post process can be used to apply a shader to a texture after it is rendered.
  73106. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73107. */
  73108. export class PostProcessRenderEffect {
  73109. private _postProcesses;
  73110. private _getPostProcesses;
  73111. private _singleInstance;
  73112. private _cameras;
  73113. private _indicesForCamera;
  73114. /**
  73115. * Name of the effect
  73116. * @hidden
  73117. */
  73118. _name: string;
  73119. /**
  73120. * Instantiates a post process render effect.
  73121. * A post process can be used to apply a shader to a texture after it is rendered.
  73122. * @param engine The engine the effect is tied to
  73123. * @param name The name of the effect
  73124. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73125. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73126. */
  73127. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73128. /**
  73129. * Checks if all the post processes in the effect are supported.
  73130. */
  73131. get isSupported(): boolean;
  73132. /**
  73133. * Updates the current state of the effect
  73134. * @hidden
  73135. */
  73136. _update(): void;
  73137. /**
  73138. * Attaches the effect on cameras
  73139. * @param cameras The camera to attach to.
  73140. * @hidden
  73141. */
  73142. _attachCameras(cameras: Camera): void;
  73143. /**
  73144. * Attaches the effect on cameras
  73145. * @param cameras The camera to attach to.
  73146. * @hidden
  73147. */
  73148. _attachCameras(cameras: Camera[]): void;
  73149. /**
  73150. * Detaches the effect on cameras
  73151. * @param cameras The camera to detatch from.
  73152. * @hidden
  73153. */
  73154. _detachCameras(cameras: Camera): void;
  73155. /**
  73156. * Detatches the effect on cameras
  73157. * @param cameras The camera to detatch from.
  73158. * @hidden
  73159. */
  73160. _detachCameras(cameras: Camera[]): void;
  73161. /**
  73162. * Enables the effect on given cameras
  73163. * @param cameras The camera to enable.
  73164. * @hidden
  73165. */
  73166. _enable(cameras: Camera): void;
  73167. /**
  73168. * Enables the effect on given cameras
  73169. * @param cameras The camera to enable.
  73170. * @hidden
  73171. */
  73172. _enable(cameras: Nullable<Camera[]>): void;
  73173. /**
  73174. * Disables the effect on the given cameras
  73175. * @param cameras The camera to disable.
  73176. * @hidden
  73177. */
  73178. _disable(cameras: Camera): void;
  73179. /**
  73180. * Disables the effect on the given cameras
  73181. * @param cameras The camera to disable.
  73182. * @hidden
  73183. */
  73184. _disable(cameras: Nullable<Camera[]>): void;
  73185. /**
  73186. * Gets a list of the post processes contained in the effect.
  73187. * @param camera The camera to get the post processes on.
  73188. * @returns The list of the post processes in the effect.
  73189. */
  73190. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73191. }
  73192. }
  73193. declare module BABYLON {
  73194. /** @hidden */
  73195. export var extractHighlightsPixelShader: {
  73196. name: string;
  73197. shader: string;
  73198. };
  73199. }
  73200. declare module BABYLON {
  73201. /**
  73202. * 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.
  73203. */
  73204. export class ExtractHighlightsPostProcess extends PostProcess {
  73205. /**
  73206. * The luminance threshold, pixels below this value will be set to black.
  73207. */
  73208. threshold: number;
  73209. /** @hidden */
  73210. _exposure: number;
  73211. /**
  73212. * Post process which has the input texture to be used when performing highlight extraction
  73213. * @hidden
  73214. */
  73215. _inputPostProcess: Nullable<PostProcess>;
  73216. /**
  73217. * Gets a string identifying the name of the class
  73218. * @returns "ExtractHighlightsPostProcess" string
  73219. */
  73220. getClassName(): string;
  73221. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73222. }
  73223. }
  73224. declare module BABYLON {
  73225. /** @hidden */
  73226. export var bloomMergePixelShader: {
  73227. name: string;
  73228. shader: string;
  73229. };
  73230. }
  73231. declare module BABYLON {
  73232. /**
  73233. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73234. */
  73235. export class BloomMergePostProcess extends PostProcess {
  73236. /** Weight of the bloom to be added to the original input. */
  73237. weight: number;
  73238. /**
  73239. * Gets a string identifying the name of the class
  73240. * @returns "BloomMergePostProcess" string
  73241. */
  73242. getClassName(): string;
  73243. /**
  73244. * Creates a new instance of @see BloomMergePostProcess
  73245. * @param name The name of the effect.
  73246. * @param originalFromInput Post process which's input will be used for the merge.
  73247. * @param blurred Blurred highlights post process which's output will be used.
  73248. * @param weight Weight of the bloom to be added to the original input.
  73249. * @param options The required width/height ratio to downsize to before computing the render pass.
  73250. * @param camera The camera to apply the render pass to.
  73251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73252. * @param engine The engine which the post process will be applied. (default: current engine)
  73253. * @param reusable If the post process can be reused on the same frame. (default: false)
  73254. * @param textureType Type of textures used when performing the post process. (default: 0)
  73255. * @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)
  73256. */
  73257. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73258. /** Weight of the bloom to be added to the original input. */
  73259. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73260. }
  73261. }
  73262. declare module BABYLON {
  73263. /**
  73264. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73265. */
  73266. export class BloomEffect extends PostProcessRenderEffect {
  73267. private bloomScale;
  73268. /**
  73269. * @hidden Internal
  73270. */
  73271. _effects: Array<PostProcess>;
  73272. /**
  73273. * @hidden Internal
  73274. */
  73275. _downscale: ExtractHighlightsPostProcess;
  73276. private _blurX;
  73277. private _blurY;
  73278. private _merge;
  73279. /**
  73280. * The luminance threshold to find bright areas of the image to bloom.
  73281. */
  73282. get threshold(): number;
  73283. set threshold(value: number);
  73284. /**
  73285. * The strength of the bloom.
  73286. */
  73287. get weight(): number;
  73288. set weight(value: number);
  73289. /**
  73290. * Specifies the size of the bloom blur kernel, relative to the final output size
  73291. */
  73292. get kernel(): number;
  73293. set kernel(value: number);
  73294. /**
  73295. * Creates a new instance of @see BloomEffect
  73296. * @param scene The scene the effect belongs to.
  73297. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73298. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73299. * @param bloomWeight The the strength of bloom.
  73300. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73301. * @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)
  73302. */
  73303. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73304. /**
  73305. * Disposes each of the internal effects for a given camera.
  73306. * @param camera The camera to dispose the effect on.
  73307. */
  73308. disposeEffects(camera: Camera): void;
  73309. /**
  73310. * @hidden Internal
  73311. */
  73312. _updateEffects(): void;
  73313. /**
  73314. * Internal
  73315. * @returns if all the contained post processes are ready.
  73316. * @hidden
  73317. */
  73318. _isReady(): boolean;
  73319. }
  73320. }
  73321. declare module BABYLON {
  73322. /** @hidden */
  73323. export var chromaticAberrationPixelShader: {
  73324. name: string;
  73325. shader: string;
  73326. };
  73327. }
  73328. declare module BABYLON {
  73329. /**
  73330. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73331. */
  73332. export class ChromaticAberrationPostProcess extends PostProcess {
  73333. /**
  73334. * The amount of seperation of rgb channels (default: 30)
  73335. */
  73336. aberrationAmount: number;
  73337. /**
  73338. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73339. */
  73340. radialIntensity: number;
  73341. /**
  73342. * 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))
  73343. */
  73344. direction: Vector2;
  73345. /**
  73346. * 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))
  73347. */
  73348. centerPosition: Vector2;
  73349. /** The width of the screen to apply the effect on */
  73350. screenWidth: number;
  73351. /** The height of the screen to apply the effect on */
  73352. screenHeight: number;
  73353. /**
  73354. * Gets a string identifying the name of the class
  73355. * @returns "ChromaticAberrationPostProcess" string
  73356. */
  73357. getClassName(): string;
  73358. /**
  73359. * Creates a new instance ChromaticAberrationPostProcess
  73360. * @param name The name of the effect.
  73361. * @param screenWidth The width of the screen to apply the effect on.
  73362. * @param screenHeight The height of the screen to apply the effect on.
  73363. * @param options The required width/height ratio to downsize to before computing the render pass.
  73364. * @param camera The camera to apply the render pass to.
  73365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73366. * @param engine The engine which the post process will be applied. (default: current engine)
  73367. * @param reusable If the post process can be reused on the same frame. (default: false)
  73368. * @param textureType Type of textures used when performing the post process. (default: 0)
  73369. * @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)
  73370. */
  73371. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73372. /** @hidden */
  73373. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73374. }
  73375. }
  73376. declare module BABYLON {
  73377. /** @hidden */
  73378. export var circleOfConfusionPixelShader: {
  73379. name: string;
  73380. shader: string;
  73381. };
  73382. }
  73383. declare module BABYLON {
  73384. /**
  73385. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73386. */
  73387. export class CircleOfConfusionPostProcess extends PostProcess {
  73388. /**
  73389. * 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.
  73390. */
  73391. lensSize: number;
  73392. /**
  73393. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73394. */
  73395. fStop: number;
  73396. /**
  73397. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73398. */
  73399. focusDistance: number;
  73400. /**
  73401. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73402. */
  73403. focalLength: number;
  73404. /**
  73405. * Gets a string identifying the name of the class
  73406. * @returns "CircleOfConfusionPostProcess" string
  73407. */
  73408. getClassName(): string;
  73409. private _depthTexture;
  73410. /**
  73411. * Creates a new instance CircleOfConfusionPostProcess
  73412. * @param name The name of the effect.
  73413. * @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.
  73414. * @param options The required width/height ratio to downsize to before computing the render pass.
  73415. * @param camera The camera to apply the render pass to.
  73416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73417. * @param engine The engine which the post process will be applied. (default: current engine)
  73418. * @param reusable If the post process can be reused on the same frame. (default: false)
  73419. * @param textureType Type of textures used when performing the post process. (default: 0)
  73420. * @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)
  73421. */
  73422. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73423. /**
  73424. * 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.
  73425. */
  73426. set depthTexture(value: RenderTargetTexture);
  73427. }
  73428. }
  73429. declare module BABYLON {
  73430. /** @hidden */
  73431. export var colorCorrectionPixelShader: {
  73432. name: string;
  73433. shader: string;
  73434. };
  73435. }
  73436. declare module BABYLON {
  73437. /**
  73438. *
  73439. * This post-process allows the modification of rendered colors by using
  73440. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73441. *
  73442. * The object needs to be provided an url to a texture containing the color
  73443. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73444. * Use an image editing software to tweak the LUT to match your needs.
  73445. *
  73446. * For an example of a color LUT, see here:
  73447. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73448. * For explanations on color grading, see here:
  73449. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73450. *
  73451. */
  73452. export class ColorCorrectionPostProcess extends PostProcess {
  73453. private _colorTableTexture;
  73454. /**
  73455. * Gets the color table url used to create the LUT texture
  73456. */
  73457. colorTableUrl: string;
  73458. /**
  73459. * Gets a string identifying the name of the class
  73460. * @returns "ColorCorrectionPostProcess" string
  73461. */
  73462. getClassName(): string;
  73463. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73464. /** @hidden */
  73465. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73466. }
  73467. }
  73468. declare module BABYLON {
  73469. /** @hidden */
  73470. export var convolutionPixelShader: {
  73471. name: string;
  73472. shader: string;
  73473. };
  73474. }
  73475. declare module BABYLON {
  73476. /**
  73477. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73478. * input texture to perform effects such as edge detection or sharpening
  73479. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73480. */
  73481. export class ConvolutionPostProcess extends PostProcess {
  73482. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73483. kernel: number[];
  73484. /**
  73485. * Gets a string identifying the name of the class
  73486. * @returns "ConvolutionPostProcess" string
  73487. */
  73488. getClassName(): string;
  73489. /**
  73490. * Creates a new instance ConvolutionPostProcess
  73491. * @param name The name of the effect.
  73492. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73493. * @param options The required width/height ratio to downsize to before computing the render pass.
  73494. * @param camera The camera to apply the render pass to.
  73495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73496. * @param engine The engine which the post process will be applied. (default: current engine)
  73497. * @param reusable If the post process can be reused on the same frame. (default: false)
  73498. * @param textureType Type of textures used when performing the post process. (default: 0)
  73499. */
  73500. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73501. /** @hidden */
  73502. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73503. /**
  73504. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73505. */
  73506. static EdgeDetect0Kernel: number[];
  73507. /**
  73508. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73509. */
  73510. static EdgeDetect1Kernel: number[];
  73511. /**
  73512. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73513. */
  73514. static EdgeDetect2Kernel: number[];
  73515. /**
  73516. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73517. */
  73518. static SharpenKernel: number[];
  73519. /**
  73520. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73521. */
  73522. static EmbossKernel: number[];
  73523. /**
  73524. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73525. */
  73526. static GaussianKernel: number[];
  73527. }
  73528. }
  73529. declare module BABYLON {
  73530. /**
  73531. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73532. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73533. * based on samples that have a large difference in distance than the center pixel.
  73534. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73535. */
  73536. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73537. /**
  73538. * The direction the blur should be applied
  73539. */
  73540. direction: Vector2;
  73541. /**
  73542. * Gets a string identifying the name of the class
  73543. * @returns "DepthOfFieldBlurPostProcess" string
  73544. */
  73545. getClassName(): string;
  73546. /**
  73547. * Creates a new instance CircleOfConfusionPostProcess
  73548. * @param name The name of the effect.
  73549. * @param scene The scene the effect belongs to.
  73550. * @param direction The direction the blur should be applied.
  73551. * @param kernel The size of the kernel used to blur.
  73552. * @param options The required width/height ratio to downsize to before computing the render pass.
  73553. * @param camera The camera to apply the render pass to.
  73554. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73555. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73557. * @param engine The engine which the post process will be applied. (default: current engine)
  73558. * @param reusable If the post process can be reused on the same frame. (default: false)
  73559. * @param textureType Type of textures used when performing the post process. (default: 0)
  73560. * @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)
  73561. */
  73562. 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);
  73563. }
  73564. }
  73565. declare module BABYLON {
  73566. /** @hidden */
  73567. export var depthOfFieldMergePixelShader: {
  73568. name: string;
  73569. shader: string;
  73570. };
  73571. }
  73572. declare module BABYLON {
  73573. /**
  73574. * Options to be set when merging outputs from the default pipeline.
  73575. */
  73576. export class DepthOfFieldMergePostProcessOptions {
  73577. /**
  73578. * The original image to merge on top of
  73579. */
  73580. originalFromInput: PostProcess;
  73581. /**
  73582. * Parameters to perform the merge of the depth of field effect
  73583. */
  73584. depthOfField?: {
  73585. circleOfConfusion: PostProcess;
  73586. blurSteps: Array<PostProcess>;
  73587. };
  73588. /**
  73589. * Parameters to perform the merge of bloom effect
  73590. */
  73591. bloom?: {
  73592. blurred: PostProcess;
  73593. weight: number;
  73594. };
  73595. }
  73596. /**
  73597. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73598. */
  73599. export class DepthOfFieldMergePostProcess extends PostProcess {
  73600. private blurSteps;
  73601. /**
  73602. * Gets a string identifying the name of the class
  73603. * @returns "DepthOfFieldMergePostProcess" string
  73604. */
  73605. getClassName(): string;
  73606. /**
  73607. * Creates a new instance of DepthOfFieldMergePostProcess
  73608. * @param name The name of the effect.
  73609. * @param originalFromInput Post process which's input will be used for the merge.
  73610. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73611. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73612. * @param options The required width/height ratio to downsize to before computing the render pass.
  73613. * @param camera The camera to apply the render pass to.
  73614. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73615. * @param engine The engine which the post process will be applied. (default: current engine)
  73616. * @param reusable If the post process can be reused on the same frame. (default: false)
  73617. * @param textureType Type of textures used when performing the post process. (default: 0)
  73618. * @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)
  73619. */
  73620. 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);
  73621. /**
  73622. * Updates the effect with the current post process compile time values and recompiles the shader.
  73623. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73624. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73625. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73626. * @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
  73627. * @param onCompiled Called when the shader has been compiled.
  73628. * @param onError Called if there is an error when compiling a shader.
  73629. */
  73630. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73631. }
  73632. }
  73633. declare module BABYLON {
  73634. /**
  73635. * Specifies the level of max blur that should be applied when using the depth of field effect
  73636. */
  73637. export enum DepthOfFieldEffectBlurLevel {
  73638. /**
  73639. * Subtle blur
  73640. */
  73641. Low = 0,
  73642. /**
  73643. * Medium blur
  73644. */
  73645. Medium = 1,
  73646. /**
  73647. * Large blur
  73648. */
  73649. High = 2
  73650. }
  73651. /**
  73652. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73653. */
  73654. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73655. private _circleOfConfusion;
  73656. /**
  73657. * @hidden Internal, blurs from high to low
  73658. */
  73659. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73660. private _depthOfFieldBlurY;
  73661. private _dofMerge;
  73662. /**
  73663. * @hidden Internal post processes in depth of field effect
  73664. */
  73665. _effects: Array<PostProcess>;
  73666. /**
  73667. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73668. */
  73669. set focalLength(value: number);
  73670. get focalLength(): number;
  73671. /**
  73672. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73673. */
  73674. set fStop(value: number);
  73675. get fStop(): number;
  73676. /**
  73677. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73678. */
  73679. set focusDistance(value: number);
  73680. get focusDistance(): number;
  73681. /**
  73682. * 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.
  73683. */
  73684. set lensSize(value: number);
  73685. get lensSize(): number;
  73686. /**
  73687. * Creates a new instance DepthOfFieldEffect
  73688. * @param scene The scene the effect belongs to.
  73689. * @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.
  73690. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73691. * @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)
  73692. */
  73693. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73694. /**
  73695. * Get the current class name of the current effet
  73696. * @returns "DepthOfFieldEffect"
  73697. */
  73698. getClassName(): string;
  73699. /**
  73700. * 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.
  73701. */
  73702. set depthTexture(value: RenderTargetTexture);
  73703. /**
  73704. * Disposes each of the internal effects for a given camera.
  73705. * @param camera The camera to dispose the effect on.
  73706. */
  73707. disposeEffects(camera: Camera): void;
  73708. /**
  73709. * @hidden Internal
  73710. */
  73711. _updateEffects(): void;
  73712. /**
  73713. * Internal
  73714. * @returns if all the contained post processes are ready.
  73715. * @hidden
  73716. */
  73717. _isReady(): boolean;
  73718. }
  73719. }
  73720. declare module BABYLON {
  73721. /** @hidden */
  73722. export var displayPassPixelShader: {
  73723. name: string;
  73724. shader: string;
  73725. };
  73726. }
  73727. declare module BABYLON {
  73728. /**
  73729. * DisplayPassPostProcess which produces an output the same as it's input
  73730. */
  73731. export class DisplayPassPostProcess extends PostProcess {
  73732. /**
  73733. * Gets a string identifying the name of the class
  73734. * @returns "DisplayPassPostProcess" string
  73735. */
  73736. getClassName(): string;
  73737. /**
  73738. * Creates the DisplayPassPostProcess
  73739. * @param name The name of the effect.
  73740. * @param options The required width/height ratio to downsize to before computing the render pass.
  73741. * @param camera The camera to apply the render pass to.
  73742. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73743. * @param engine The engine which the post process will be applied. (default: current engine)
  73744. * @param reusable If the post process can be reused on the same frame. (default: false)
  73745. */
  73746. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73747. /** @hidden */
  73748. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73749. }
  73750. }
  73751. declare module BABYLON {
  73752. /** @hidden */
  73753. export var filterPixelShader: {
  73754. name: string;
  73755. shader: string;
  73756. };
  73757. }
  73758. declare module BABYLON {
  73759. /**
  73760. * Applies a kernel filter to the image
  73761. */
  73762. export class FilterPostProcess extends PostProcess {
  73763. /** The matrix to be applied to the image */
  73764. kernelMatrix: Matrix;
  73765. /**
  73766. * Gets a string identifying the name of the class
  73767. * @returns "FilterPostProcess" string
  73768. */
  73769. getClassName(): string;
  73770. /**
  73771. *
  73772. * @param name The name of the effect.
  73773. * @param kernelMatrix The matrix to be applied to the image
  73774. * @param options The required width/height ratio to downsize to before computing the render pass.
  73775. * @param camera The camera to apply the render pass to.
  73776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73777. * @param engine The engine which the post process will be applied. (default: current engine)
  73778. * @param reusable If the post process can be reused on the same frame. (default: false)
  73779. */
  73780. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73781. /** @hidden */
  73782. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73783. }
  73784. }
  73785. declare module BABYLON {
  73786. /** @hidden */
  73787. export var fxaaPixelShader: {
  73788. name: string;
  73789. shader: string;
  73790. };
  73791. }
  73792. declare module BABYLON {
  73793. /** @hidden */
  73794. export var fxaaVertexShader: {
  73795. name: string;
  73796. shader: string;
  73797. };
  73798. }
  73799. declare module BABYLON {
  73800. /**
  73801. * Fxaa post process
  73802. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73803. */
  73804. export class FxaaPostProcess extends PostProcess {
  73805. /**
  73806. * Gets a string identifying the name of the class
  73807. * @returns "FxaaPostProcess" string
  73808. */
  73809. getClassName(): string;
  73810. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73811. private _getDefines;
  73812. /** @hidden */
  73813. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73814. }
  73815. }
  73816. declare module BABYLON {
  73817. /** @hidden */
  73818. export var grainPixelShader: {
  73819. name: string;
  73820. shader: string;
  73821. };
  73822. }
  73823. declare module BABYLON {
  73824. /**
  73825. * The GrainPostProcess adds noise to the image at mid luminance levels
  73826. */
  73827. export class GrainPostProcess extends PostProcess {
  73828. /**
  73829. * The intensity of the grain added (default: 30)
  73830. */
  73831. intensity: number;
  73832. /**
  73833. * If the grain should be randomized on every frame
  73834. */
  73835. animated: boolean;
  73836. /**
  73837. * Gets a string identifying the name of the class
  73838. * @returns "GrainPostProcess" string
  73839. */
  73840. getClassName(): string;
  73841. /**
  73842. * Creates a new instance of @see GrainPostProcess
  73843. * @param name The name of the effect.
  73844. * @param options The required width/height ratio to downsize to before computing the render pass.
  73845. * @param camera The camera to apply the render pass to.
  73846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73847. * @param engine The engine which the post process will be applied. (default: current engine)
  73848. * @param reusable If the post process can be reused on the same frame. (default: false)
  73849. * @param textureType Type of textures used when performing the post process. (default: 0)
  73850. * @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)
  73851. */
  73852. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73853. /** @hidden */
  73854. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73855. }
  73856. }
  73857. declare module BABYLON {
  73858. /** @hidden */
  73859. export var highlightsPixelShader: {
  73860. name: string;
  73861. shader: string;
  73862. };
  73863. }
  73864. declare module BABYLON {
  73865. /**
  73866. * Extracts highlights from the image
  73867. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73868. */
  73869. export class HighlightsPostProcess extends PostProcess {
  73870. /**
  73871. * Gets a string identifying the name of the class
  73872. * @returns "HighlightsPostProcess" string
  73873. */
  73874. getClassName(): string;
  73875. /**
  73876. * Extracts highlights from the image
  73877. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73878. * @param name The name of the effect.
  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 samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73882. * @param engine The engine which the post process will be applied. (default: current engine)
  73883. * @param reusable If the post process can be reused on the same frame. (default: false)
  73884. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73885. */
  73886. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73887. }
  73888. }
  73889. declare module BABYLON {
  73890. /**
  73891. * Contains all parameters needed for the prepass to perform
  73892. * motion blur
  73893. */
  73894. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  73895. /**
  73896. * Is motion blur enabled
  73897. */
  73898. enabled: boolean;
  73899. /**
  73900. * Name of the configuration
  73901. */
  73902. name: string;
  73903. /**
  73904. * Textures that should be present in the MRT for this effect to work
  73905. */
  73906. readonly texturesRequired: number[];
  73907. }
  73908. }
  73909. declare module BABYLON {
  73910. interface Scene {
  73911. /** @hidden (Backing field) */
  73912. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73913. /**
  73914. * Gets or Sets the current geometry buffer associated to the scene.
  73915. */
  73916. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73917. /**
  73918. * Enables a GeometryBufferRender and associates it with the scene
  73919. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73920. * @returns the GeometryBufferRenderer
  73921. */
  73922. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73923. /**
  73924. * Disables the GeometryBufferRender associated with the scene
  73925. */
  73926. disableGeometryBufferRenderer(): void;
  73927. }
  73928. /**
  73929. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73930. * in several rendering techniques.
  73931. */
  73932. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73933. /**
  73934. * The component name helpful to identify the component in the list of scene components.
  73935. */
  73936. readonly name: string;
  73937. /**
  73938. * The scene the component belongs to.
  73939. */
  73940. scene: Scene;
  73941. /**
  73942. * Creates a new instance of the component for the given scene
  73943. * @param scene Defines the scene to register the component in
  73944. */
  73945. constructor(scene: Scene);
  73946. /**
  73947. * Registers the component in a given scene
  73948. */
  73949. register(): void;
  73950. /**
  73951. * Rebuilds the elements related to this component in case of
  73952. * context lost for instance.
  73953. */
  73954. rebuild(): void;
  73955. /**
  73956. * Disposes the component and the associated ressources
  73957. */
  73958. dispose(): void;
  73959. private _gatherRenderTargets;
  73960. }
  73961. }
  73962. declare module BABYLON {
  73963. /** @hidden */
  73964. export var motionBlurPixelShader: {
  73965. name: string;
  73966. shader: string;
  73967. };
  73968. }
  73969. declare module BABYLON {
  73970. /**
  73971. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73972. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73973. * As an example, all you have to do is to create the post-process:
  73974. * var mb = new BABYLON.MotionBlurPostProcess(
  73975. * 'mb', // The name of the effect.
  73976. * scene, // The scene containing the objects to blur according to their velocity.
  73977. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73978. * camera // The camera to apply the render pass to.
  73979. * );
  73980. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73981. */
  73982. export class MotionBlurPostProcess extends PostProcess {
  73983. /**
  73984. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73985. */
  73986. motionStrength: number;
  73987. /**
  73988. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73989. */
  73990. get motionBlurSamples(): number;
  73991. /**
  73992. * Sets the number of iterations to be used for motion blur quality
  73993. */
  73994. set motionBlurSamples(samples: number);
  73995. private _motionBlurSamples;
  73996. /**
  73997. * Gets wether or not the motion blur post-process is in object based mode.
  73998. */
  73999. get isObjectBased(): boolean;
  74000. /**
  74001. * Sets wether or not the motion blur post-process is in object based mode.
  74002. */
  74003. set isObjectBased(value: boolean);
  74004. private _isObjectBased;
  74005. private _forceGeometryBuffer;
  74006. private _geometryBufferRenderer;
  74007. private _prePassRenderer;
  74008. private _invViewProjection;
  74009. private _previousViewProjection;
  74010. /**
  74011. * Gets a string identifying the name of the class
  74012. * @returns "MotionBlurPostProcess" string
  74013. */
  74014. getClassName(): string;
  74015. /**
  74016. * Creates a new instance MotionBlurPostProcess
  74017. * @param name The name of the effect.
  74018. * @param scene The scene containing the objects to blur according to their velocity.
  74019. * @param options The required width/height ratio to downsize to before computing the render pass.
  74020. * @param camera The camera to apply the render pass to.
  74021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74022. * @param engine The engine which the post process will be applied. (default: current engine)
  74023. * @param reusable If the post process can be reused on the same frame. (default: false)
  74024. * @param textureType Type of textures used when performing the post process. (default: 0)
  74025. * @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)
  74026. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74027. */
  74028. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74029. /**
  74030. * Excludes the given skinned mesh from computing bones velocities.
  74031. * 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.
  74032. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74033. */
  74034. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74035. /**
  74036. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74037. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74038. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74039. */
  74040. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74041. /**
  74042. * Disposes the post process.
  74043. * @param camera The camera to dispose the post process on.
  74044. */
  74045. dispose(camera?: Camera): void;
  74046. /**
  74047. * Called on the mode changed (object based or screen based).
  74048. */
  74049. private _applyMode;
  74050. /**
  74051. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74052. */
  74053. private _onApplyObjectBased;
  74054. /**
  74055. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74056. */
  74057. private _onApplyScreenBased;
  74058. /**
  74059. * Called on the effect must be updated (changed mode, samples count, etc.).
  74060. */
  74061. private _updateEffect;
  74062. /** @hidden */
  74063. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74064. }
  74065. }
  74066. declare module BABYLON {
  74067. /** @hidden */
  74068. export var refractionPixelShader: {
  74069. name: string;
  74070. shader: string;
  74071. };
  74072. }
  74073. declare module BABYLON {
  74074. /**
  74075. * Post process which applies a refractin texture
  74076. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74077. */
  74078. export class RefractionPostProcess extends PostProcess {
  74079. private _refTexture;
  74080. private _ownRefractionTexture;
  74081. /** the base color of the refraction (used to taint the rendering) */
  74082. color: Color3;
  74083. /** simulated refraction depth */
  74084. depth: number;
  74085. /** the coefficient of the base color (0 to remove base color tainting) */
  74086. colorLevel: number;
  74087. /** Gets the url used to load the refraction texture */
  74088. refractionTextureUrl: string;
  74089. /**
  74090. * Gets or sets the refraction texture
  74091. * Please note that you are responsible for disposing the texture if you set it manually
  74092. */
  74093. get refractionTexture(): Texture;
  74094. set refractionTexture(value: Texture);
  74095. /**
  74096. * Gets a string identifying the name of the class
  74097. * @returns "RefractionPostProcess" string
  74098. */
  74099. getClassName(): string;
  74100. /**
  74101. * Initializes the RefractionPostProcess
  74102. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74103. * @param name The name of the effect.
  74104. * @param refractionTextureUrl Url of the refraction texture to use
  74105. * @param color the base color of the refraction (used to taint the rendering)
  74106. * @param depth simulated refraction depth
  74107. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74108. * @param camera The camera to apply the render pass to.
  74109. * @param options The required width/height ratio to downsize to before computing the render pass.
  74110. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74111. * @param engine The engine which the post process will be applied. (default: current engine)
  74112. * @param reusable If the post process can be reused on the same frame. (default: false)
  74113. */
  74114. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74115. /**
  74116. * Disposes of the post process
  74117. * @param camera Camera to dispose post process on
  74118. */
  74119. dispose(camera: Camera): void;
  74120. /** @hidden */
  74121. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74122. }
  74123. }
  74124. declare module BABYLON {
  74125. /** @hidden */
  74126. export var sharpenPixelShader: {
  74127. name: string;
  74128. shader: string;
  74129. };
  74130. }
  74131. declare module BABYLON {
  74132. /**
  74133. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74134. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74135. */
  74136. export class SharpenPostProcess extends PostProcess {
  74137. /**
  74138. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74139. */
  74140. colorAmount: number;
  74141. /**
  74142. * How much sharpness should be applied (default: 0.3)
  74143. */
  74144. edgeAmount: number;
  74145. /**
  74146. * Gets a string identifying the name of the class
  74147. * @returns "SharpenPostProcess" string
  74148. */
  74149. getClassName(): string;
  74150. /**
  74151. * Creates a new instance ConvolutionPostProcess
  74152. * @param name The name of the effect.
  74153. * @param options The required width/height ratio to downsize to before computing the render pass.
  74154. * @param camera The camera to apply the render pass to.
  74155. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74156. * @param engine The engine which the post process will be applied. (default: current engine)
  74157. * @param reusable If the post process can be reused on the same frame. (default: false)
  74158. * @param textureType Type of textures used when performing the post process. (default: 0)
  74159. * @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)
  74160. */
  74161. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74162. /** @hidden */
  74163. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74164. }
  74165. }
  74166. declare module BABYLON {
  74167. /**
  74168. * PostProcessRenderPipeline
  74169. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74170. */
  74171. export class PostProcessRenderPipeline {
  74172. private engine;
  74173. private _renderEffects;
  74174. private _renderEffectsForIsolatedPass;
  74175. /**
  74176. * List of inspectable custom properties (used by the Inspector)
  74177. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74178. */
  74179. inspectableCustomProperties: IInspectable[];
  74180. /**
  74181. * @hidden
  74182. */
  74183. protected _cameras: Camera[];
  74184. /** @hidden */
  74185. _name: string;
  74186. /**
  74187. * Gets pipeline name
  74188. */
  74189. get name(): string;
  74190. /** Gets the list of attached cameras */
  74191. get cameras(): Camera[];
  74192. /**
  74193. * Initializes a PostProcessRenderPipeline
  74194. * @param engine engine to add the pipeline to
  74195. * @param name name of the pipeline
  74196. */
  74197. constructor(engine: Engine, name: string);
  74198. /**
  74199. * Gets the class name
  74200. * @returns "PostProcessRenderPipeline"
  74201. */
  74202. getClassName(): string;
  74203. /**
  74204. * If all the render effects in the pipeline are supported
  74205. */
  74206. get isSupported(): boolean;
  74207. /**
  74208. * Adds an effect to the pipeline
  74209. * @param renderEffect the effect to add
  74210. */
  74211. addEffect(renderEffect: PostProcessRenderEffect): void;
  74212. /** @hidden */
  74213. _rebuild(): void;
  74214. /** @hidden */
  74215. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74216. /** @hidden */
  74217. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74218. /** @hidden */
  74219. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74220. /** @hidden */
  74221. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74222. /** @hidden */
  74223. _attachCameras(cameras: Camera, unique: boolean): void;
  74224. /** @hidden */
  74225. _attachCameras(cameras: Camera[], unique: boolean): void;
  74226. /** @hidden */
  74227. _detachCameras(cameras: Camera): void;
  74228. /** @hidden */
  74229. _detachCameras(cameras: Nullable<Camera[]>): void;
  74230. /** @hidden */
  74231. _update(): void;
  74232. /** @hidden */
  74233. _reset(): void;
  74234. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74235. /**
  74236. * Sets the required values to the prepass renderer.
  74237. * @param prePassRenderer defines the prepass renderer to setup.
  74238. * @returns true if the pre pass is needed.
  74239. */
  74240. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74241. /**
  74242. * Disposes of the pipeline
  74243. */
  74244. dispose(): void;
  74245. }
  74246. }
  74247. declare module BABYLON {
  74248. /**
  74249. * PostProcessRenderPipelineManager class
  74250. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74251. */
  74252. export class PostProcessRenderPipelineManager {
  74253. private _renderPipelines;
  74254. /**
  74255. * Initializes a PostProcessRenderPipelineManager
  74256. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74257. */
  74258. constructor();
  74259. /**
  74260. * Gets the list of supported render pipelines
  74261. */
  74262. get supportedPipelines(): PostProcessRenderPipeline[];
  74263. /**
  74264. * Adds a pipeline to the manager
  74265. * @param renderPipeline The pipeline to add
  74266. */
  74267. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74268. /**
  74269. * Attaches a camera to the pipeline
  74270. * @param renderPipelineName The name of the pipeline to attach to
  74271. * @param cameras the camera to attach
  74272. * @param unique if the camera can be attached multiple times to the pipeline
  74273. */
  74274. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74275. /**
  74276. * Detaches a camera from the pipeline
  74277. * @param renderPipelineName The name of the pipeline to detach from
  74278. * @param cameras the camera to detach
  74279. */
  74280. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74281. /**
  74282. * Enables an effect by name on a pipeline
  74283. * @param renderPipelineName the name of the pipeline to enable the effect in
  74284. * @param renderEffectName the name of the effect to enable
  74285. * @param cameras the cameras that the effect should be enabled on
  74286. */
  74287. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74288. /**
  74289. * Disables an effect by name on a pipeline
  74290. * @param renderPipelineName the name of the pipeline to disable the effect in
  74291. * @param renderEffectName the name of the effect to disable
  74292. * @param cameras the cameras that the effect should be disabled on
  74293. */
  74294. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74295. /**
  74296. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74297. */
  74298. update(): void;
  74299. /** @hidden */
  74300. _rebuild(): void;
  74301. /**
  74302. * Disposes of the manager and pipelines
  74303. */
  74304. dispose(): void;
  74305. }
  74306. }
  74307. declare module BABYLON {
  74308. interface Scene {
  74309. /** @hidden (Backing field) */
  74310. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74311. /**
  74312. * Gets the postprocess render pipeline manager
  74313. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74314. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74315. */
  74316. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74317. }
  74318. /**
  74319. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74320. */
  74321. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74322. /**
  74323. * The component name helpfull to identify the component in the list of scene components.
  74324. */
  74325. readonly name: string;
  74326. /**
  74327. * The scene the component belongs to.
  74328. */
  74329. scene: Scene;
  74330. /**
  74331. * Creates a new instance of the component for the given scene
  74332. * @param scene Defines the scene to register the component in
  74333. */
  74334. constructor(scene: Scene);
  74335. /**
  74336. * Registers the component in a given scene
  74337. */
  74338. register(): void;
  74339. /**
  74340. * Rebuilds the elements related to this component in case of
  74341. * context lost for instance.
  74342. */
  74343. rebuild(): void;
  74344. /**
  74345. * Disposes the component and the associated ressources
  74346. */
  74347. dispose(): void;
  74348. private _gatherRenderTargets;
  74349. }
  74350. }
  74351. declare module BABYLON {
  74352. /**
  74353. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74354. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74355. */
  74356. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74357. private _scene;
  74358. private _camerasToBeAttached;
  74359. /**
  74360. * ID of the sharpen post process,
  74361. */
  74362. private readonly SharpenPostProcessId;
  74363. /**
  74364. * @ignore
  74365. * ID of the image processing post process;
  74366. */
  74367. readonly ImageProcessingPostProcessId: string;
  74368. /**
  74369. * @ignore
  74370. * ID of the Fast Approximate Anti-Aliasing post process;
  74371. */
  74372. readonly FxaaPostProcessId: string;
  74373. /**
  74374. * ID of the chromatic aberration post process,
  74375. */
  74376. private readonly ChromaticAberrationPostProcessId;
  74377. /**
  74378. * ID of the grain post process
  74379. */
  74380. private readonly GrainPostProcessId;
  74381. /**
  74382. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74383. */
  74384. sharpen: SharpenPostProcess;
  74385. private _sharpenEffect;
  74386. private bloom;
  74387. /**
  74388. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74389. */
  74390. depthOfField: DepthOfFieldEffect;
  74391. /**
  74392. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74393. */
  74394. fxaa: FxaaPostProcess;
  74395. /**
  74396. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74397. */
  74398. imageProcessing: ImageProcessingPostProcess;
  74399. /**
  74400. * Chromatic aberration post process which will shift rgb colors in the image
  74401. */
  74402. chromaticAberration: ChromaticAberrationPostProcess;
  74403. private _chromaticAberrationEffect;
  74404. /**
  74405. * Grain post process which add noise to the image
  74406. */
  74407. grain: GrainPostProcess;
  74408. private _grainEffect;
  74409. /**
  74410. * Glow post process which adds a glow to emissive areas of the image
  74411. */
  74412. private _glowLayer;
  74413. /**
  74414. * Animations which can be used to tweak settings over a period of time
  74415. */
  74416. animations: Animation[];
  74417. private _imageProcessingConfigurationObserver;
  74418. private _sharpenEnabled;
  74419. private _bloomEnabled;
  74420. private _depthOfFieldEnabled;
  74421. private _depthOfFieldBlurLevel;
  74422. private _fxaaEnabled;
  74423. private _imageProcessingEnabled;
  74424. private _defaultPipelineTextureType;
  74425. private _bloomScale;
  74426. private _chromaticAberrationEnabled;
  74427. private _grainEnabled;
  74428. private _buildAllowed;
  74429. /**
  74430. * This is triggered each time the pipeline has been built.
  74431. */
  74432. onBuildObservable: Observable<DefaultRenderingPipeline>;
  74433. /**
  74434. * Gets active scene
  74435. */
  74436. get scene(): Scene;
  74437. /**
  74438. * Enable or disable the sharpen process from the pipeline
  74439. */
  74440. set sharpenEnabled(enabled: boolean);
  74441. get sharpenEnabled(): boolean;
  74442. private _resizeObserver;
  74443. private _hardwareScaleLevel;
  74444. private _bloomKernel;
  74445. /**
  74446. * Specifies the size of the bloom blur kernel, relative to the final output size
  74447. */
  74448. get bloomKernel(): number;
  74449. set bloomKernel(value: number);
  74450. /**
  74451. * Specifies the weight of the bloom in the final rendering
  74452. */
  74453. private _bloomWeight;
  74454. /**
  74455. * Specifies the luma threshold for the area that will be blurred by the bloom
  74456. */
  74457. private _bloomThreshold;
  74458. private _hdr;
  74459. /**
  74460. * The strength of the bloom.
  74461. */
  74462. set bloomWeight(value: number);
  74463. get bloomWeight(): number;
  74464. /**
  74465. * The strength of the bloom.
  74466. */
  74467. set bloomThreshold(value: number);
  74468. get bloomThreshold(): number;
  74469. /**
  74470. * The scale of the bloom, lower value will provide better performance.
  74471. */
  74472. set bloomScale(value: number);
  74473. get bloomScale(): number;
  74474. /**
  74475. * Enable or disable the bloom from the pipeline
  74476. */
  74477. set bloomEnabled(enabled: boolean);
  74478. get bloomEnabled(): boolean;
  74479. private _rebuildBloom;
  74480. /**
  74481. * If the depth of field is enabled.
  74482. */
  74483. get depthOfFieldEnabled(): boolean;
  74484. set depthOfFieldEnabled(enabled: boolean);
  74485. /**
  74486. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74487. */
  74488. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74489. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74490. /**
  74491. * If the anti aliasing is enabled.
  74492. */
  74493. set fxaaEnabled(enabled: boolean);
  74494. get fxaaEnabled(): boolean;
  74495. private _samples;
  74496. /**
  74497. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74498. */
  74499. set samples(sampleCount: number);
  74500. get samples(): number;
  74501. /**
  74502. * If image processing is enabled.
  74503. */
  74504. set imageProcessingEnabled(enabled: boolean);
  74505. get imageProcessingEnabled(): boolean;
  74506. /**
  74507. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74508. */
  74509. set glowLayerEnabled(enabled: boolean);
  74510. get glowLayerEnabled(): boolean;
  74511. /**
  74512. * Gets the glow layer (or null if not defined)
  74513. */
  74514. get glowLayer(): Nullable<GlowLayer>;
  74515. /**
  74516. * Enable or disable the chromaticAberration process from the pipeline
  74517. */
  74518. set chromaticAberrationEnabled(enabled: boolean);
  74519. get chromaticAberrationEnabled(): boolean;
  74520. /**
  74521. * Enable or disable the grain process from the pipeline
  74522. */
  74523. set grainEnabled(enabled: boolean);
  74524. get grainEnabled(): boolean;
  74525. /**
  74526. * @constructor
  74527. * @param name - The rendering pipeline name (default: "")
  74528. * @param hdr - If high dynamic range textures should be used (default: true)
  74529. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74530. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74531. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74532. */
  74533. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74534. /**
  74535. * Get the class name
  74536. * @returns "DefaultRenderingPipeline"
  74537. */
  74538. getClassName(): string;
  74539. /**
  74540. * Force the compilation of the entire pipeline.
  74541. */
  74542. prepare(): void;
  74543. private _hasCleared;
  74544. private _prevPostProcess;
  74545. private _prevPrevPostProcess;
  74546. private _setAutoClearAndTextureSharing;
  74547. private _depthOfFieldSceneObserver;
  74548. private _buildPipeline;
  74549. private _disposePostProcesses;
  74550. /**
  74551. * Adds a camera to the pipeline
  74552. * @param camera the camera to be added
  74553. */
  74554. addCamera(camera: Camera): void;
  74555. /**
  74556. * Removes a camera from the pipeline
  74557. * @param camera the camera to remove
  74558. */
  74559. removeCamera(camera: Camera): void;
  74560. /**
  74561. * Dispose of the pipeline and stop all post processes
  74562. */
  74563. dispose(): void;
  74564. /**
  74565. * Serialize the rendering pipeline (Used when exporting)
  74566. * @returns the serialized object
  74567. */
  74568. serialize(): any;
  74569. /**
  74570. * Parse the serialized pipeline
  74571. * @param source Source pipeline.
  74572. * @param scene The scene to load the pipeline to.
  74573. * @param rootUrl The URL of the serialized pipeline.
  74574. * @returns An instantiated pipeline from the serialized object.
  74575. */
  74576. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74577. }
  74578. }
  74579. declare module BABYLON {
  74580. /** @hidden */
  74581. export var lensHighlightsPixelShader: {
  74582. name: string;
  74583. shader: string;
  74584. };
  74585. }
  74586. declare module BABYLON {
  74587. /** @hidden */
  74588. export var depthOfFieldPixelShader: {
  74589. name: string;
  74590. shader: string;
  74591. };
  74592. }
  74593. declare module BABYLON {
  74594. /**
  74595. * BABYLON.JS Chromatic Aberration GLSL Shader
  74596. * Author: Olivier Guyot
  74597. * Separates very slightly R, G and B colors on the edges of the screen
  74598. * Inspired by Francois Tarlier & Martins Upitis
  74599. */
  74600. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74601. /**
  74602. * @ignore
  74603. * The chromatic aberration PostProcess id in the pipeline
  74604. */
  74605. LensChromaticAberrationEffect: string;
  74606. /**
  74607. * @ignore
  74608. * The highlights enhancing PostProcess id in the pipeline
  74609. */
  74610. HighlightsEnhancingEffect: string;
  74611. /**
  74612. * @ignore
  74613. * The depth-of-field PostProcess id in the pipeline
  74614. */
  74615. LensDepthOfFieldEffect: string;
  74616. private _scene;
  74617. private _depthTexture;
  74618. private _grainTexture;
  74619. private _chromaticAberrationPostProcess;
  74620. private _highlightsPostProcess;
  74621. private _depthOfFieldPostProcess;
  74622. private _edgeBlur;
  74623. private _grainAmount;
  74624. private _chromaticAberration;
  74625. private _distortion;
  74626. private _highlightsGain;
  74627. private _highlightsThreshold;
  74628. private _dofDistance;
  74629. private _dofAperture;
  74630. private _dofDarken;
  74631. private _dofPentagon;
  74632. private _blurNoise;
  74633. /**
  74634. * @constructor
  74635. *
  74636. * Effect parameters are as follow:
  74637. * {
  74638. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74639. * edge_blur: number; // from 0 to x (1 for realism)
  74640. * distortion: number; // from 0 to x (1 for realism)
  74641. * grain_amount: number; // from 0 to 1
  74642. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74643. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74644. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74645. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74646. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74647. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74648. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74649. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74650. * }
  74651. * Note: if an effect parameter is unset, effect is disabled
  74652. *
  74653. * @param name The rendering pipeline name
  74654. * @param parameters - An object containing all parameters (see above)
  74655. * @param scene The scene linked to this pipeline
  74656. * @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)
  74657. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74658. */
  74659. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74660. /**
  74661. * Get the class name
  74662. * @returns "LensRenderingPipeline"
  74663. */
  74664. getClassName(): string;
  74665. /**
  74666. * Gets associated scene
  74667. */
  74668. get scene(): Scene;
  74669. /**
  74670. * Gets or sets the edge blur
  74671. */
  74672. get edgeBlur(): number;
  74673. set edgeBlur(value: number);
  74674. /**
  74675. * Gets or sets the grain amount
  74676. */
  74677. get grainAmount(): number;
  74678. set grainAmount(value: number);
  74679. /**
  74680. * Gets or sets the chromatic aberration amount
  74681. */
  74682. get chromaticAberration(): number;
  74683. set chromaticAberration(value: number);
  74684. /**
  74685. * Gets or sets the depth of field aperture
  74686. */
  74687. get dofAperture(): number;
  74688. set dofAperture(value: number);
  74689. /**
  74690. * Gets or sets the edge distortion
  74691. */
  74692. get edgeDistortion(): number;
  74693. set edgeDistortion(value: number);
  74694. /**
  74695. * Gets or sets the depth of field distortion
  74696. */
  74697. get dofDistortion(): number;
  74698. set dofDistortion(value: number);
  74699. /**
  74700. * Gets or sets the darken out of focus amount
  74701. */
  74702. get darkenOutOfFocus(): number;
  74703. set darkenOutOfFocus(value: number);
  74704. /**
  74705. * Gets or sets a boolean indicating if blur noise is enabled
  74706. */
  74707. get blurNoise(): boolean;
  74708. set blurNoise(value: boolean);
  74709. /**
  74710. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74711. */
  74712. get pentagonBokeh(): boolean;
  74713. set pentagonBokeh(value: boolean);
  74714. /**
  74715. * Gets or sets the highlight grain amount
  74716. */
  74717. get highlightsGain(): number;
  74718. set highlightsGain(value: number);
  74719. /**
  74720. * Gets or sets the highlight threshold
  74721. */
  74722. get highlightsThreshold(): number;
  74723. set highlightsThreshold(value: number);
  74724. /**
  74725. * Sets the amount of blur at the edges
  74726. * @param amount blur amount
  74727. */
  74728. setEdgeBlur(amount: number): void;
  74729. /**
  74730. * Sets edge blur to 0
  74731. */
  74732. disableEdgeBlur(): void;
  74733. /**
  74734. * Sets the amout of grain
  74735. * @param amount Amount of grain
  74736. */
  74737. setGrainAmount(amount: number): void;
  74738. /**
  74739. * Set grain amount to 0
  74740. */
  74741. disableGrain(): void;
  74742. /**
  74743. * Sets the chromatic aberration amount
  74744. * @param amount amount of chromatic aberration
  74745. */
  74746. setChromaticAberration(amount: number): void;
  74747. /**
  74748. * Sets chromatic aberration amount to 0
  74749. */
  74750. disableChromaticAberration(): void;
  74751. /**
  74752. * Sets the EdgeDistortion amount
  74753. * @param amount amount of EdgeDistortion
  74754. */
  74755. setEdgeDistortion(amount: number): void;
  74756. /**
  74757. * Sets edge distortion to 0
  74758. */
  74759. disableEdgeDistortion(): void;
  74760. /**
  74761. * Sets the FocusDistance amount
  74762. * @param amount amount of FocusDistance
  74763. */
  74764. setFocusDistance(amount: number): void;
  74765. /**
  74766. * Disables depth of field
  74767. */
  74768. disableDepthOfField(): void;
  74769. /**
  74770. * Sets the Aperture amount
  74771. * @param amount amount of Aperture
  74772. */
  74773. setAperture(amount: number): void;
  74774. /**
  74775. * Sets the DarkenOutOfFocus amount
  74776. * @param amount amount of DarkenOutOfFocus
  74777. */
  74778. setDarkenOutOfFocus(amount: number): void;
  74779. private _pentagonBokehIsEnabled;
  74780. /**
  74781. * Creates a pentagon bokeh effect
  74782. */
  74783. enablePentagonBokeh(): void;
  74784. /**
  74785. * Disables the pentagon bokeh effect
  74786. */
  74787. disablePentagonBokeh(): void;
  74788. /**
  74789. * Enables noise blur
  74790. */
  74791. enableNoiseBlur(): void;
  74792. /**
  74793. * Disables noise blur
  74794. */
  74795. disableNoiseBlur(): void;
  74796. /**
  74797. * Sets the HighlightsGain amount
  74798. * @param amount amount of HighlightsGain
  74799. */
  74800. setHighlightsGain(amount: number): void;
  74801. /**
  74802. * Sets the HighlightsThreshold amount
  74803. * @param amount amount of HighlightsThreshold
  74804. */
  74805. setHighlightsThreshold(amount: number): void;
  74806. /**
  74807. * Disables highlights
  74808. */
  74809. disableHighlights(): void;
  74810. /**
  74811. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74812. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74813. */
  74814. dispose(disableDepthRender?: boolean): void;
  74815. private _createChromaticAberrationPostProcess;
  74816. private _createHighlightsPostProcess;
  74817. private _createDepthOfFieldPostProcess;
  74818. private _createGrainTexture;
  74819. }
  74820. }
  74821. declare module BABYLON {
  74822. /**
  74823. * Contains all parameters needed for the prepass to perform
  74824. * screen space subsurface scattering
  74825. */
  74826. export class SSAO2Configuration implements PrePassEffectConfiguration {
  74827. /**
  74828. * Is subsurface enabled
  74829. */
  74830. enabled: boolean;
  74831. /**
  74832. * Name of the configuration
  74833. */
  74834. name: string;
  74835. /**
  74836. * Textures that should be present in the MRT for this effect to work
  74837. */
  74838. readonly texturesRequired: number[];
  74839. }
  74840. }
  74841. declare module BABYLON {
  74842. /** @hidden */
  74843. export var ssao2PixelShader: {
  74844. name: string;
  74845. shader: string;
  74846. };
  74847. }
  74848. declare module BABYLON {
  74849. /** @hidden */
  74850. export var ssaoCombinePixelShader: {
  74851. name: string;
  74852. shader: string;
  74853. };
  74854. }
  74855. declare module BABYLON {
  74856. /**
  74857. * Render pipeline to produce ssao effect
  74858. */
  74859. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74860. /**
  74861. * @ignore
  74862. * The PassPostProcess id in the pipeline that contains the original scene color
  74863. */
  74864. SSAOOriginalSceneColorEffect: string;
  74865. /**
  74866. * @ignore
  74867. * The SSAO PostProcess id in the pipeline
  74868. */
  74869. SSAORenderEffect: string;
  74870. /**
  74871. * @ignore
  74872. * The horizontal blur PostProcess id in the pipeline
  74873. */
  74874. SSAOBlurHRenderEffect: string;
  74875. /**
  74876. * @ignore
  74877. * The vertical blur PostProcess id in the pipeline
  74878. */
  74879. SSAOBlurVRenderEffect: string;
  74880. /**
  74881. * @ignore
  74882. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74883. */
  74884. SSAOCombineRenderEffect: string;
  74885. /**
  74886. * The output strength of the SSAO post-process. Default value is 1.0.
  74887. */
  74888. totalStrength: number;
  74889. /**
  74890. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74891. */
  74892. maxZ: number;
  74893. /**
  74894. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74895. */
  74896. minZAspect: number;
  74897. private _samples;
  74898. /**
  74899. * Number of samples used for the SSAO calculations. Default value is 8
  74900. */
  74901. set samples(n: number);
  74902. get samples(): number;
  74903. private _textureSamples;
  74904. /**
  74905. * Number of samples to use for antialiasing
  74906. */
  74907. set textureSamples(n: number);
  74908. get textureSamples(): number;
  74909. /**
  74910. * Force rendering the geometry through geometry buffer
  74911. */
  74912. private _forceGeometryBuffer;
  74913. /**
  74914. * Ratio object used for SSAO ratio and blur ratio
  74915. */
  74916. private _ratio;
  74917. /**
  74918. * Dynamically generated sphere sampler.
  74919. */
  74920. private _sampleSphere;
  74921. /**
  74922. * Blur filter offsets
  74923. */
  74924. private _samplerOffsets;
  74925. private _expensiveBlur;
  74926. /**
  74927. * If bilateral blur should be used
  74928. */
  74929. set expensiveBlur(b: boolean);
  74930. get expensiveBlur(): boolean;
  74931. /**
  74932. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74933. */
  74934. radius: number;
  74935. /**
  74936. * The base color of the SSAO post-process
  74937. * The final result is "base + ssao" between [0, 1]
  74938. */
  74939. base: number;
  74940. /**
  74941. * Support test.
  74942. */
  74943. static get IsSupported(): boolean;
  74944. private _scene;
  74945. private _randomTexture;
  74946. private _originalColorPostProcess;
  74947. private _ssaoPostProcess;
  74948. private _blurHPostProcess;
  74949. private _blurVPostProcess;
  74950. private _ssaoCombinePostProcess;
  74951. private _prePassRenderer;
  74952. /**
  74953. * Gets active scene
  74954. */
  74955. get scene(): Scene;
  74956. /**
  74957. * @constructor
  74958. * @param name The rendering pipeline name
  74959. * @param scene The scene linked to this pipeline
  74960. * @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 }
  74961. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74962. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74963. */
  74964. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74965. /**
  74966. * Get the class name
  74967. * @returns "SSAO2RenderingPipeline"
  74968. */
  74969. getClassName(): string;
  74970. /**
  74971. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74972. */
  74973. dispose(disableGeometryBufferRenderer?: boolean): void;
  74974. private _createBlurPostProcess;
  74975. /** @hidden */
  74976. _rebuild(): void;
  74977. private _bits;
  74978. private _radicalInverse_VdC;
  74979. private _hammersley;
  74980. private _hemisphereSample_uniform;
  74981. private _generateHemisphere;
  74982. private _getDefinesForSSAO;
  74983. private static readonly ORTHO_DEPTH_PROJECTION;
  74984. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  74985. private _createSSAOPostProcess;
  74986. private _createSSAOCombinePostProcess;
  74987. private _createRandomTexture;
  74988. /**
  74989. * Serialize the rendering pipeline (Used when exporting)
  74990. * @returns the serialized object
  74991. */
  74992. serialize(): any;
  74993. /**
  74994. * Parse the serialized pipeline
  74995. * @param source Source pipeline.
  74996. * @param scene The scene to load the pipeline to.
  74997. * @param rootUrl The URL of the serialized pipeline.
  74998. * @returns An instantiated pipeline from the serialized object.
  74999. */
  75000. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75001. }
  75002. }
  75003. declare module BABYLON {
  75004. /** @hidden */
  75005. export var ssaoPixelShader: {
  75006. name: string;
  75007. shader: string;
  75008. };
  75009. }
  75010. declare module BABYLON {
  75011. /**
  75012. * Render pipeline to produce ssao effect
  75013. */
  75014. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75015. /**
  75016. * @ignore
  75017. * The PassPostProcess id in the pipeline that contains the original scene color
  75018. */
  75019. SSAOOriginalSceneColorEffect: string;
  75020. /**
  75021. * @ignore
  75022. * The SSAO PostProcess id in the pipeline
  75023. */
  75024. SSAORenderEffect: string;
  75025. /**
  75026. * @ignore
  75027. * The horizontal blur PostProcess id in the pipeline
  75028. */
  75029. SSAOBlurHRenderEffect: string;
  75030. /**
  75031. * @ignore
  75032. * The vertical blur PostProcess id in the pipeline
  75033. */
  75034. SSAOBlurVRenderEffect: string;
  75035. /**
  75036. * @ignore
  75037. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75038. */
  75039. SSAOCombineRenderEffect: string;
  75040. /**
  75041. * The output strength of the SSAO post-process. Default value is 1.0.
  75042. */
  75043. totalStrength: number;
  75044. /**
  75045. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75046. */
  75047. radius: number;
  75048. /**
  75049. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75050. * Must not be equal to fallOff and superior to fallOff.
  75051. * Default value is 0.0075
  75052. */
  75053. area: number;
  75054. /**
  75055. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75056. * Must not be equal to area and inferior to area.
  75057. * Default value is 0.000001
  75058. */
  75059. fallOff: number;
  75060. /**
  75061. * The base color of the SSAO post-process
  75062. * The final result is "base + ssao" between [0, 1]
  75063. */
  75064. base: number;
  75065. private _scene;
  75066. private _depthTexture;
  75067. private _randomTexture;
  75068. private _originalColorPostProcess;
  75069. private _ssaoPostProcess;
  75070. private _blurHPostProcess;
  75071. private _blurVPostProcess;
  75072. private _ssaoCombinePostProcess;
  75073. private _firstUpdate;
  75074. /**
  75075. * Gets active scene
  75076. */
  75077. get scene(): Scene;
  75078. /**
  75079. * @constructor
  75080. * @param name - The rendering pipeline name
  75081. * @param scene - The scene linked to this pipeline
  75082. * @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 }
  75083. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75084. */
  75085. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75086. /**
  75087. * Get the class name
  75088. * @returns "SSAORenderingPipeline"
  75089. */
  75090. getClassName(): string;
  75091. /**
  75092. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75093. */
  75094. dispose(disableDepthRender?: boolean): void;
  75095. private _createBlurPostProcess;
  75096. /** @hidden */
  75097. _rebuild(): void;
  75098. private _createSSAOPostProcess;
  75099. private _createSSAOCombinePostProcess;
  75100. private _createRandomTexture;
  75101. }
  75102. }
  75103. declare module BABYLON {
  75104. /**
  75105. * Contains all parameters needed for the prepass to perform
  75106. * screen space reflections
  75107. */
  75108. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75109. /**
  75110. * Is ssr enabled
  75111. */
  75112. enabled: boolean;
  75113. /**
  75114. * Name of the configuration
  75115. */
  75116. name: string;
  75117. /**
  75118. * Textures that should be present in the MRT for this effect to work
  75119. */
  75120. readonly texturesRequired: number[];
  75121. }
  75122. }
  75123. declare module BABYLON {
  75124. /** @hidden */
  75125. export var screenSpaceReflectionPixelShader: {
  75126. name: string;
  75127. shader: string;
  75128. };
  75129. }
  75130. declare module BABYLON {
  75131. /**
  75132. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75133. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75134. */
  75135. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75136. /**
  75137. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75138. */
  75139. threshold: number;
  75140. /**
  75141. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75142. */
  75143. strength: number;
  75144. /**
  75145. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75146. */
  75147. reflectionSpecularFalloffExponent: number;
  75148. /**
  75149. * 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]
  75150. */
  75151. step: number;
  75152. /**
  75153. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75154. */
  75155. roughnessFactor: number;
  75156. private _forceGeometryBuffer;
  75157. private _geometryBufferRenderer;
  75158. private _prePassRenderer;
  75159. private _enableSmoothReflections;
  75160. private _reflectionSamples;
  75161. private _smoothSteps;
  75162. /**
  75163. * Gets a string identifying the name of the class
  75164. * @returns "ScreenSpaceReflectionPostProcess" string
  75165. */
  75166. getClassName(): string;
  75167. /**
  75168. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75169. * @param name The name of the effect.
  75170. * @param scene The scene containing the objects to calculate reflections.
  75171. * @param options The required width/height ratio to downsize to before computing the render pass.
  75172. * @param camera The camera to apply the render pass to.
  75173. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75174. * @param engine The engine which the post process will be applied. (default: current engine)
  75175. * @param reusable If the post process can be reused on the same frame. (default: false)
  75176. * @param textureType Type of textures used when performing the post process. (default: 0)
  75177. * @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)
  75178. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75179. */
  75180. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75181. /**
  75182. * Gets wether or not smoothing reflections is enabled.
  75183. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75184. */
  75185. get enableSmoothReflections(): boolean;
  75186. /**
  75187. * Sets wether or not smoothing reflections is enabled.
  75188. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75189. */
  75190. set enableSmoothReflections(enabled: boolean);
  75191. /**
  75192. * Gets the number of samples taken while computing reflections. More samples count is high,
  75193. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75194. */
  75195. get reflectionSamples(): number;
  75196. /**
  75197. * Sets the number of samples taken while computing reflections. More samples count is high,
  75198. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75199. */
  75200. set reflectionSamples(samples: number);
  75201. /**
  75202. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75203. * more the post-process will require GPU power and can generate a drop in FPS.
  75204. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75205. */
  75206. get smoothSteps(): number;
  75207. set smoothSteps(steps: number);
  75208. private _updateEffectDefines;
  75209. /** @hidden */
  75210. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75211. }
  75212. }
  75213. declare module BABYLON {
  75214. /** @hidden */
  75215. export var standardPixelShader: {
  75216. name: string;
  75217. shader: string;
  75218. };
  75219. }
  75220. declare module BABYLON {
  75221. /**
  75222. * Standard rendering pipeline
  75223. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75224. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75225. */
  75226. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75227. /**
  75228. * Public members
  75229. */
  75230. /**
  75231. * Post-process which contains the original scene color before the pipeline applies all the effects
  75232. */
  75233. originalPostProcess: Nullable<PostProcess>;
  75234. /**
  75235. * Post-process used to down scale an image x4
  75236. */
  75237. downSampleX4PostProcess: Nullable<PostProcess>;
  75238. /**
  75239. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75240. */
  75241. brightPassPostProcess: Nullable<PostProcess>;
  75242. /**
  75243. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75244. */
  75245. blurHPostProcesses: PostProcess[];
  75246. /**
  75247. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75248. */
  75249. blurVPostProcesses: PostProcess[];
  75250. /**
  75251. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75252. */
  75253. textureAdderPostProcess: Nullable<PostProcess>;
  75254. /**
  75255. * Post-process used to create volumetric lighting effect
  75256. */
  75257. volumetricLightPostProcess: Nullable<PostProcess>;
  75258. /**
  75259. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75260. */
  75261. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75262. /**
  75263. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75264. */
  75265. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75266. /**
  75267. * Post-process used to merge the volumetric light effect and the real scene color
  75268. */
  75269. volumetricLightMergePostProces: Nullable<PostProcess>;
  75270. /**
  75271. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75272. */
  75273. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75274. /**
  75275. * Base post-process used to calculate the average luminance of the final image for HDR
  75276. */
  75277. luminancePostProcess: Nullable<PostProcess>;
  75278. /**
  75279. * Post-processes used to create down sample post-processes in order to get
  75280. * the average luminance of the final image for HDR
  75281. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75282. */
  75283. luminanceDownSamplePostProcesses: PostProcess[];
  75284. /**
  75285. * Post-process used to create a HDR effect (light adaptation)
  75286. */
  75287. hdrPostProcess: Nullable<PostProcess>;
  75288. /**
  75289. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75290. */
  75291. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75292. /**
  75293. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75294. */
  75295. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75296. /**
  75297. * Post-process used to merge the final HDR post-process and the real scene color
  75298. */
  75299. hdrFinalPostProcess: Nullable<PostProcess>;
  75300. /**
  75301. * Post-process used to create a lens flare effect
  75302. */
  75303. lensFlarePostProcess: Nullable<PostProcess>;
  75304. /**
  75305. * Post-process that merges the result of the lens flare post-process and the real scene color
  75306. */
  75307. lensFlareComposePostProcess: Nullable<PostProcess>;
  75308. /**
  75309. * Post-process used to create a motion blur effect
  75310. */
  75311. motionBlurPostProcess: Nullable<PostProcess>;
  75312. /**
  75313. * Post-process used to create a depth of field effect
  75314. */
  75315. depthOfFieldPostProcess: Nullable<PostProcess>;
  75316. /**
  75317. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75318. */
  75319. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75320. /**
  75321. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75322. */
  75323. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75324. /**
  75325. * Represents the brightness threshold in order to configure the illuminated surfaces
  75326. */
  75327. brightThreshold: number;
  75328. /**
  75329. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75330. */
  75331. blurWidth: number;
  75332. /**
  75333. * Sets if the blur for highlighted surfaces must be only horizontal
  75334. */
  75335. horizontalBlur: boolean;
  75336. /**
  75337. * Gets the overall exposure used by the pipeline
  75338. */
  75339. get exposure(): number;
  75340. /**
  75341. * Sets the overall exposure used by the pipeline
  75342. */
  75343. set exposure(value: number);
  75344. /**
  75345. * Texture used typically to simulate "dirty" on camera lens
  75346. */
  75347. lensTexture: Nullable<Texture>;
  75348. /**
  75349. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75350. */
  75351. volumetricLightCoefficient: number;
  75352. /**
  75353. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75354. */
  75355. volumetricLightPower: number;
  75356. /**
  75357. * Used the set the blur intensity to smooth the volumetric lights
  75358. */
  75359. volumetricLightBlurScale: number;
  75360. /**
  75361. * Light (spot or directional) used to generate the volumetric lights rays
  75362. * The source light must have a shadow generate so the pipeline can get its
  75363. * depth map
  75364. */
  75365. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75366. /**
  75367. * For eye adaptation, represents the minimum luminance the eye can see
  75368. */
  75369. hdrMinimumLuminance: number;
  75370. /**
  75371. * For eye adaptation, represents the decrease luminance speed
  75372. */
  75373. hdrDecreaseRate: number;
  75374. /**
  75375. * For eye adaptation, represents the increase luminance speed
  75376. */
  75377. hdrIncreaseRate: number;
  75378. /**
  75379. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75380. */
  75381. get hdrAutoExposure(): boolean;
  75382. /**
  75383. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75384. */
  75385. set hdrAutoExposure(value: boolean);
  75386. /**
  75387. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75388. */
  75389. lensColorTexture: Nullable<Texture>;
  75390. /**
  75391. * The overall strengh for the lens flare effect
  75392. */
  75393. lensFlareStrength: number;
  75394. /**
  75395. * Dispersion coefficient for lens flare ghosts
  75396. */
  75397. lensFlareGhostDispersal: number;
  75398. /**
  75399. * Main lens flare halo width
  75400. */
  75401. lensFlareHaloWidth: number;
  75402. /**
  75403. * Based on the lens distortion effect, defines how much the lens flare result
  75404. * is distorted
  75405. */
  75406. lensFlareDistortionStrength: number;
  75407. /**
  75408. * Configures the blur intensity used for for lens flare (halo)
  75409. */
  75410. lensFlareBlurWidth: number;
  75411. /**
  75412. * Lens star texture must be used to simulate rays on the flares and is available
  75413. * in the documentation
  75414. */
  75415. lensStarTexture: Nullable<Texture>;
  75416. /**
  75417. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75418. * flare effect by taking account of the dirt texture
  75419. */
  75420. lensFlareDirtTexture: Nullable<Texture>;
  75421. /**
  75422. * Represents the focal length for the depth of field effect
  75423. */
  75424. depthOfFieldDistance: number;
  75425. /**
  75426. * Represents the blur intensity for the blurred part of the depth of field effect
  75427. */
  75428. depthOfFieldBlurWidth: number;
  75429. /**
  75430. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75431. */
  75432. get motionStrength(): number;
  75433. /**
  75434. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75435. */
  75436. set motionStrength(strength: number);
  75437. /**
  75438. * Gets wether or not the motion blur post-process is object based or screen based.
  75439. */
  75440. get objectBasedMotionBlur(): boolean;
  75441. /**
  75442. * Sets wether or not the motion blur post-process should be object based or screen based
  75443. */
  75444. set objectBasedMotionBlur(value: boolean);
  75445. /**
  75446. * List of animations for the pipeline (IAnimatable implementation)
  75447. */
  75448. animations: Animation[];
  75449. /**
  75450. * Private members
  75451. */
  75452. private _scene;
  75453. private _currentDepthOfFieldSource;
  75454. private _basePostProcess;
  75455. private _fixedExposure;
  75456. private _currentExposure;
  75457. private _hdrAutoExposure;
  75458. private _hdrCurrentLuminance;
  75459. private _motionStrength;
  75460. private _isObjectBasedMotionBlur;
  75461. private _floatTextureType;
  75462. private _camerasToBeAttached;
  75463. private _ratio;
  75464. private _bloomEnabled;
  75465. private _depthOfFieldEnabled;
  75466. private _vlsEnabled;
  75467. private _lensFlareEnabled;
  75468. private _hdrEnabled;
  75469. private _motionBlurEnabled;
  75470. private _fxaaEnabled;
  75471. private _screenSpaceReflectionsEnabled;
  75472. private _motionBlurSamples;
  75473. private _volumetricLightStepsCount;
  75474. private _samples;
  75475. /**
  75476. * @ignore
  75477. * Specifies if the bloom pipeline is enabled
  75478. */
  75479. get BloomEnabled(): boolean;
  75480. set BloomEnabled(enabled: boolean);
  75481. /**
  75482. * @ignore
  75483. * Specifies if the depth of field pipeline is enabed
  75484. */
  75485. get DepthOfFieldEnabled(): boolean;
  75486. set DepthOfFieldEnabled(enabled: boolean);
  75487. /**
  75488. * @ignore
  75489. * Specifies if the lens flare pipeline is enabed
  75490. */
  75491. get LensFlareEnabled(): boolean;
  75492. set LensFlareEnabled(enabled: boolean);
  75493. /**
  75494. * @ignore
  75495. * Specifies if the HDR pipeline is enabled
  75496. */
  75497. get HDREnabled(): boolean;
  75498. set HDREnabled(enabled: boolean);
  75499. /**
  75500. * @ignore
  75501. * Specifies if the volumetric lights scattering effect is enabled
  75502. */
  75503. get VLSEnabled(): boolean;
  75504. set VLSEnabled(enabled: boolean);
  75505. /**
  75506. * @ignore
  75507. * Specifies if the motion blur effect is enabled
  75508. */
  75509. get MotionBlurEnabled(): boolean;
  75510. set MotionBlurEnabled(enabled: boolean);
  75511. /**
  75512. * Specifies if anti-aliasing is enabled
  75513. */
  75514. get fxaaEnabled(): boolean;
  75515. set fxaaEnabled(enabled: boolean);
  75516. /**
  75517. * Specifies if screen space reflections are enabled.
  75518. */
  75519. get screenSpaceReflectionsEnabled(): boolean;
  75520. set screenSpaceReflectionsEnabled(enabled: boolean);
  75521. /**
  75522. * Specifies the number of steps used to calculate the volumetric lights
  75523. * Typically in interval [50, 200]
  75524. */
  75525. get volumetricLightStepsCount(): number;
  75526. set volumetricLightStepsCount(count: number);
  75527. /**
  75528. * Specifies the number of samples used for the motion blur effect
  75529. * Typically in interval [16, 64]
  75530. */
  75531. get motionBlurSamples(): number;
  75532. set motionBlurSamples(samples: number);
  75533. /**
  75534. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75535. */
  75536. get samples(): number;
  75537. set samples(sampleCount: number);
  75538. /**
  75539. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75540. * @constructor
  75541. * @param name The rendering pipeline name
  75542. * @param scene The scene linked to this pipeline
  75543. * @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)
  75544. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75545. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75546. */
  75547. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75548. private _buildPipeline;
  75549. private _createDownSampleX4PostProcess;
  75550. private _createBrightPassPostProcess;
  75551. private _createBlurPostProcesses;
  75552. private _createTextureAdderPostProcess;
  75553. private _createVolumetricLightPostProcess;
  75554. private _createLuminancePostProcesses;
  75555. private _createHdrPostProcess;
  75556. private _createLensFlarePostProcess;
  75557. private _createDepthOfFieldPostProcess;
  75558. private _createMotionBlurPostProcess;
  75559. private _getDepthTexture;
  75560. private _disposePostProcesses;
  75561. /**
  75562. * Dispose of the pipeline and stop all post processes
  75563. */
  75564. dispose(): void;
  75565. /**
  75566. * Serialize the rendering pipeline (Used when exporting)
  75567. * @returns the serialized object
  75568. */
  75569. serialize(): any;
  75570. /**
  75571. * Parse the serialized pipeline
  75572. * @param source Source pipeline.
  75573. * @param scene The scene to load the pipeline to.
  75574. * @param rootUrl The URL of the serialized pipeline.
  75575. * @returns An instantiated pipeline from the serialized object.
  75576. */
  75577. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75578. /**
  75579. * Luminance steps
  75580. */
  75581. static LuminanceSteps: number;
  75582. }
  75583. }
  75584. declare module BABYLON {
  75585. /** @hidden */
  75586. export var stereoscopicInterlacePixelShader: {
  75587. name: string;
  75588. shader: string;
  75589. };
  75590. }
  75591. declare module BABYLON {
  75592. /**
  75593. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75594. */
  75595. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75596. private _stepSize;
  75597. private _passedProcess;
  75598. /**
  75599. * Gets a string identifying the name of the class
  75600. * @returns "StereoscopicInterlacePostProcessI" string
  75601. */
  75602. getClassName(): string;
  75603. /**
  75604. * Initializes a StereoscopicInterlacePostProcessI
  75605. * @param name The name of the effect.
  75606. * @param rigCameras The rig cameras to be appled to the post process
  75607. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75608. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75610. * @param engine The engine which the post process will be applied. (default: current engine)
  75611. * @param reusable If the post process can be reused on the same frame. (default: false)
  75612. */
  75613. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75614. }
  75615. /**
  75616. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75617. */
  75618. export class StereoscopicInterlacePostProcess extends PostProcess {
  75619. private _stepSize;
  75620. private _passedProcess;
  75621. /**
  75622. * Gets a string identifying the name of the class
  75623. * @returns "StereoscopicInterlacePostProcess" string
  75624. */
  75625. getClassName(): string;
  75626. /**
  75627. * Initializes a StereoscopicInterlacePostProcess
  75628. * @param name The name of the effect.
  75629. * @param rigCameras The rig cameras to be appled to the post process
  75630. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75632. * @param engine The engine which the post process will be applied. (default: current engine)
  75633. * @param reusable If the post process can be reused on the same frame. (default: false)
  75634. */
  75635. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75636. }
  75637. }
  75638. declare module BABYLON {
  75639. /** @hidden */
  75640. export var tonemapPixelShader: {
  75641. name: string;
  75642. shader: string;
  75643. };
  75644. }
  75645. declare module BABYLON {
  75646. /** Defines operator used for tonemapping */
  75647. export enum TonemappingOperator {
  75648. /** Hable */
  75649. Hable = 0,
  75650. /** Reinhard */
  75651. Reinhard = 1,
  75652. /** HejiDawson */
  75653. HejiDawson = 2,
  75654. /** Photographic */
  75655. Photographic = 3
  75656. }
  75657. /**
  75658. * Defines a post process to apply tone mapping
  75659. */
  75660. export class TonemapPostProcess extends PostProcess {
  75661. private _operator;
  75662. /** Defines the required exposure adjustement */
  75663. exposureAdjustment: number;
  75664. /**
  75665. * Gets a string identifying the name of the class
  75666. * @returns "TonemapPostProcess" string
  75667. */
  75668. getClassName(): string;
  75669. /**
  75670. * Creates a new TonemapPostProcess
  75671. * @param name defines the name of the postprocess
  75672. * @param _operator defines the operator to use
  75673. * @param exposureAdjustment defines the required exposure adjustement
  75674. * @param camera defines the camera to use (can be null)
  75675. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75676. * @param engine defines the hosting engine (can be ignore if camera is set)
  75677. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75678. */
  75679. constructor(name: string, _operator: TonemappingOperator,
  75680. /** Defines the required exposure adjustement */
  75681. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75682. }
  75683. }
  75684. declare module BABYLON {
  75685. /** @hidden */
  75686. export var volumetricLightScatteringPixelShader: {
  75687. name: string;
  75688. shader: string;
  75689. };
  75690. }
  75691. declare module BABYLON {
  75692. /** @hidden */
  75693. export var volumetricLightScatteringPassVertexShader: {
  75694. name: string;
  75695. shader: string;
  75696. };
  75697. }
  75698. declare module BABYLON {
  75699. /** @hidden */
  75700. export var volumetricLightScatteringPassPixelShader: {
  75701. name: string;
  75702. shader: string;
  75703. };
  75704. }
  75705. declare module BABYLON {
  75706. /**
  75707. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75708. */
  75709. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75710. private _volumetricLightScatteringPass;
  75711. private _volumetricLightScatteringRTT;
  75712. private _viewPort;
  75713. private _screenCoordinates;
  75714. private _cachedDefines;
  75715. /**
  75716. * If not undefined, the mesh position is computed from the attached node position
  75717. */
  75718. attachedNode: {
  75719. position: Vector3;
  75720. };
  75721. /**
  75722. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75723. */
  75724. customMeshPosition: Vector3;
  75725. /**
  75726. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75727. */
  75728. useCustomMeshPosition: boolean;
  75729. /**
  75730. * If the post-process should inverse the light scattering direction
  75731. */
  75732. invert: boolean;
  75733. /**
  75734. * The internal mesh used by the post-process
  75735. */
  75736. mesh: Mesh;
  75737. /**
  75738. * @hidden
  75739. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75740. */
  75741. get useDiffuseColor(): boolean;
  75742. set useDiffuseColor(useDiffuseColor: boolean);
  75743. /**
  75744. * Array containing the excluded meshes not rendered in the internal pass
  75745. */
  75746. excludedMeshes: AbstractMesh[];
  75747. /**
  75748. * Controls the overall intensity of the post-process
  75749. */
  75750. exposure: number;
  75751. /**
  75752. * Dissipates each sample's contribution in range [0, 1]
  75753. */
  75754. decay: number;
  75755. /**
  75756. * Controls the overall intensity of each sample
  75757. */
  75758. weight: number;
  75759. /**
  75760. * Controls the density of each sample
  75761. */
  75762. density: number;
  75763. /**
  75764. * @constructor
  75765. * @param name The post-process name
  75766. * @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)
  75767. * @param camera The camera that the post-process will be attached to
  75768. * @param mesh The mesh used to create the light scattering
  75769. * @param samples The post-process quality, default 100
  75770. * @param samplingModeThe post-process filtering mode
  75771. * @param engine The babylon engine
  75772. * @param reusable If the post-process is reusable
  75773. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75774. */
  75775. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75776. /**
  75777. * Returns the string "VolumetricLightScatteringPostProcess"
  75778. * @returns "VolumetricLightScatteringPostProcess"
  75779. */
  75780. getClassName(): string;
  75781. private _isReady;
  75782. /**
  75783. * Sets the new light position for light scattering effect
  75784. * @param position The new custom light position
  75785. */
  75786. setCustomMeshPosition(position: Vector3): void;
  75787. /**
  75788. * Returns the light position for light scattering effect
  75789. * @return Vector3 The custom light position
  75790. */
  75791. getCustomMeshPosition(): Vector3;
  75792. /**
  75793. * Disposes the internal assets and detaches the post-process from the camera
  75794. */
  75795. dispose(camera: Camera): void;
  75796. /**
  75797. * Returns the render target texture used by the post-process
  75798. * @return the render target texture used by the post-process
  75799. */
  75800. getPass(): RenderTargetTexture;
  75801. private _meshExcluded;
  75802. private _createPass;
  75803. private _updateMeshScreenCoordinates;
  75804. /**
  75805. * Creates a default mesh for the Volumeric Light Scattering post-process
  75806. * @param name The mesh name
  75807. * @param scene The scene where to create the mesh
  75808. * @return the default mesh
  75809. */
  75810. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75811. }
  75812. }
  75813. declare module BABYLON {
  75814. /** @hidden */
  75815. export var screenSpaceCurvaturePixelShader: {
  75816. name: string;
  75817. shader: string;
  75818. };
  75819. }
  75820. declare module BABYLON {
  75821. /**
  75822. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75823. */
  75824. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75825. /**
  75826. * Defines how much ridge the curvature effect displays.
  75827. */
  75828. ridge: number;
  75829. /**
  75830. * Defines how much valley the curvature effect displays.
  75831. */
  75832. valley: number;
  75833. private _geometryBufferRenderer;
  75834. /**
  75835. * Gets a string identifying the name of the class
  75836. * @returns "ScreenSpaceCurvaturePostProcess" string
  75837. */
  75838. getClassName(): string;
  75839. /**
  75840. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75841. * @param name The name of the effect.
  75842. * @param scene The scene containing the objects to blur according to their velocity.
  75843. * @param options The required width/height ratio to downsize to before computing the render pass.
  75844. * @param camera The camera to apply the render pass to.
  75845. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75846. * @param engine The engine which the post process will be applied. (default: current engine)
  75847. * @param reusable If the post process can be reused on the same frame. (default: false)
  75848. * @param textureType Type of textures used when performing the post process. (default: 0)
  75849. * @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)
  75850. */
  75851. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75852. /**
  75853. * Support test.
  75854. */
  75855. static get IsSupported(): boolean;
  75856. /** @hidden */
  75857. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75858. }
  75859. }
  75860. declare module BABYLON {
  75861. interface Scene {
  75862. /** @hidden (Backing field) */
  75863. _boundingBoxRenderer: BoundingBoxRenderer;
  75864. /** @hidden (Backing field) */
  75865. _forceShowBoundingBoxes: boolean;
  75866. /**
  75867. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75868. */
  75869. forceShowBoundingBoxes: boolean;
  75870. /**
  75871. * Gets the bounding box renderer associated with the scene
  75872. * @returns a BoundingBoxRenderer
  75873. */
  75874. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75875. }
  75876. interface AbstractMesh {
  75877. /** @hidden (Backing field) */
  75878. _showBoundingBox: boolean;
  75879. /**
  75880. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75881. */
  75882. showBoundingBox: boolean;
  75883. }
  75884. /**
  75885. * Component responsible of rendering the bounding box of the meshes in a scene.
  75886. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75887. */
  75888. export class BoundingBoxRenderer implements ISceneComponent {
  75889. /**
  75890. * The component name helpfull to identify the component in the list of scene components.
  75891. */
  75892. readonly name: string;
  75893. /**
  75894. * The scene the component belongs to.
  75895. */
  75896. scene: Scene;
  75897. /**
  75898. * Color of the bounding box lines placed in front of an object
  75899. */
  75900. frontColor: Color3;
  75901. /**
  75902. * Color of the bounding box lines placed behind an object
  75903. */
  75904. backColor: Color3;
  75905. /**
  75906. * Defines if the renderer should show the back lines or not
  75907. */
  75908. showBackLines: boolean;
  75909. /**
  75910. * Observable raised before rendering a bounding box
  75911. */
  75912. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75913. /**
  75914. * Observable raised after rendering a bounding box
  75915. */
  75916. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75917. /**
  75918. * Observable raised after resources are created
  75919. */
  75920. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  75921. /**
  75922. * When false, no bounding boxes will be rendered
  75923. */
  75924. enabled: boolean;
  75925. /**
  75926. * @hidden
  75927. */
  75928. renderList: SmartArray<BoundingBox>;
  75929. private _colorShader;
  75930. private _vertexBuffers;
  75931. private _indexBuffer;
  75932. private _fillIndexBuffer;
  75933. private _fillIndexData;
  75934. /**
  75935. * Instantiates a new bounding box renderer in a scene.
  75936. * @param scene the scene the renderer renders in
  75937. */
  75938. constructor(scene: Scene);
  75939. /**
  75940. * Registers the component in a given scene
  75941. */
  75942. register(): void;
  75943. private _evaluateSubMesh;
  75944. private _preActiveMesh;
  75945. private _prepareResources;
  75946. private _createIndexBuffer;
  75947. /**
  75948. * Rebuilds the elements related to this component in case of
  75949. * context lost for instance.
  75950. */
  75951. rebuild(): void;
  75952. /**
  75953. * @hidden
  75954. */
  75955. reset(): void;
  75956. /**
  75957. * Render the bounding boxes of a specific rendering group
  75958. * @param renderingGroupId defines the rendering group to render
  75959. */
  75960. render(renderingGroupId: number): void;
  75961. /**
  75962. * In case of occlusion queries, we can render the occlusion bounding box through this method
  75963. * @param mesh Define the mesh to render the occlusion bounding box for
  75964. */
  75965. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  75966. /**
  75967. * Dispose and release the resources attached to this renderer.
  75968. */
  75969. dispose(): void;
  75970. }
  75971. }
  75972. declare module BABYLON {
  75973. interface Scene {
  75974. /** @hidden (Backing field) */
  75975. _depthRenderer: {
  75976. [id: string]: DepthRenderer;
  75977. };
  75978. /**
  75979. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  75980. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  75981. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  75982. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  75983. * @returns the created depth renderer
  75984. */
  75985. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  75986. /**
  75987. * Disables a depth renderer for a given camera
  75988. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  75989. */
  75990. disableDepthRenderer(camera?: Nullable<Camera>): void;
  75991. }
  75992. /**
  75993. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  75994. * in several rendering techniques.
  75995. */
  75996. export class DepthRendererSceneComponent implements ISceneComponent {
  75997. /**
  75998. * The component name helpfull to identify the component in the list of scene components.
  75999. */
  76000. readonly name: string;
  76001. /**
  76002. * The scene the component belongs to.
  76003. */
  76004. scene: Scene;
  76005. /**
  76006. * Creates a new instance of the component for the given scene
  76007. * @param scene Defines the scene to register the component in
  76008. */
  76009. constructor(scene: Scene);
  76010. /**
  76011. * Registers the component in a given scene
  76012. */
  76013. register(): void;
  76014. /**
  76015. * Rebuilds the elements related to this component in case of
  76016. * context lost for instance.
  76017. */
  76018. rebuild(): void;
  76019. /**
  76020. * Disposes the component and the associated ressources
  76021. */
  76022. dispose(): void;
  76023. private _gatherRenderTargets;
  76024. private _gatherActiveCameraRenderTargets;
  76025. }
  76026. }
  76027. declare module BABYLON {
  76028. interface AbstractScene {
  76029. /** @hidden (Backing field) */
  76030. _prePassRenderer: Nullable<PrePassRenderer>;
  76031. /**
  76032. * Gets or Sets the current prepass renderer associated to the scene.
  76033. */
  76034. prePassRenderer: Nullable<PrePassRenderer>;
  76035. /**
  76036. * Enables the prepass and associates it with the scene
  76037. * @returns the PrePassRenderer
  76038. */
  76039. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76040. /**
  76041. * Disables the prepass associated with the scene
  76042. */
  76043. disablePrePassRenderer(): void;
  76044. }
  76045. /**
  76046. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76047. * in several rendering techniques.
  76048. */
  76049. export class PrePassRendererSceneComponent implements ISceneComponent {
  76050. /**
  76051. * The component name helpful to identify the component in the list of scene components.
  76052. */
  76053. readonly name: string;
  76054. /**
  76055. * The scene the component belongs to.
  76056. */
  76057. scene: Scene;
  76058. /**
  76059. * Creates a new instance of the component for the given scene
  76060. * @param scene Defines the scene to register the component in
  76061. */
  76062. constructor(scene: Scene);
  76063. /**
  76064. * Registers the component in a given scene
  76065. */
  76066. register(): void;
  76067. private _beforeCameraDraw;
  76068. private _afterCameraDraw;
  76069. private _beforeClearStage;
  76070. private _beforeRenderingMeshStage;
  76071. private _afterRenderingMeshStage;
  76072. /**
  76073. * Rebuilds the elements related to this component in case of
  76074. * context lost for instance.
  76075. */
  76076. rebuild(): void;
  76077. /**
  76078. * Disposes the component and the associated ressources
  76079. */
  76080. dispose(): void;
  76081. }
  76082. }
  76083. declare module BABYLON {
  76084. /** @hidden */
  76085. export var fibonacci: {
  76086. name: string;
  76087. shader: string;
  76088. };
  76089. }
  76090. declare module BABYLON {
  76091. /** @hidden */
  76092. export var diffusionProfile: {
  76093. name: string;
  76094. shader: string;
  76095. };
  76096. }
  76097. declare module BABYLON {
  76098. /** @hidden */
  76099. export var subSurfaceScatteringPixelShader: {
  76100. name: string;
  76101. shader: string;
  76102. };
  76103. }
  76104. declare module BABYLON {
  76105. /**
  76106. * Sub surface scattering post process
  76107. */
  76108. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76109. /**
  76110. * Gets a string identifying the name of the class
  76111. * @returns "SubSurfaceScatteringPostProcess" string
  76112. */
  76113. getClassName(): string;
  76114. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76115. }
  76116. }
  76117. declare module BABYLON {
  76118. /**
  76119. * Contains all parameters needed for the prepass to perform
  76120. * screen space subsurface scattering
  76121. */
  76122. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76123. /** @hidden */
  76124. static _SceneComponentInitialization: (scene: Scene) => void;
  76125. private _ssDiffusionS;
  76126. private _ssFilterRadii;
  76127. private _ssDiffusionD;
  76128. /**
  76129. * Post process to attach for screen space subsurface scattering
  76130. */
  76131. postProcess: SubSurfaceScatteringPostProcess;
  76132. /**
  76133. * Diffusion profile color for subsurface scattering
  76134. */
  76135. get ssDiffusionS(): number[];
  76136. /**
  76137. * Diffusion profile max color channel value for subsurface scattering
  76138. */
  76139. get ssDiffusionD(): number[];
  76140. /**
  76141. * Diffusion profile filter radius for subsurface scattering
  76142. */
  76143. get ssFilterRadii(): number[];
  76144. /**
  76145. * Is subsurface enabled
  76146. */
  76147. enabled: boolean;
  76148. /**
  76149. * Name of the configuration
  76150. */
  76151. name: string;
  76152. /**
  76153. * Diffusion profile colors for subsurface scattering
  76154. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76155. * See ...
  76156. * Note that you can only store up to 5 of them
  76157. */
  76158. ssDiffusionProfileColors: Color3[];
  76159. /**
  76160. * Defines the ratio real world => scene units.
  76161. * Used for subsurface scattering
  76162. */
  76163. metersPerUnit: number;
  76164. /**
  76165. * Textures that should be present in the MRT for this effect to work
  76166. */
  76167. readonly texturesRequired: number[];
  76168. private _scene;
  76169. /**
  76170. * Builds a subsurface configuration object
  76171. * @param scene The scene
  76172. */
  76173. constructor(scene: Scene);
  76174. /**
  76175. * Adds a new diffusion profile.
  76176. * Useful for more realistic subsurface scattering on diverse materials.
  76177. * @param color The color of the diffusion profile. Should be the average color of the material.
  76178. * @return The index of the diffusion profile for the material subsurface configuration
  76179. */
  76180. addDiffusionProfile(color: Color3): number;
  76181. /**
  76182. * Creates the sss post process
  76183. * @return The created post process
  76184. */
  76185. createPostProcess(): SubSurfaceScatteringPostProcess;
  76186. /**
  76187. * Deletes all diffusion profiles.
  76188. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76189. */
  76190. clearAllDiffusionProfiles(): void;
  76191. /**
  76192. * Disposes this object
  76193. */
  76194. dispose(): void;
  76195. /**
  76196. * @hidden
  76197. * https://zero-radiance.github.io/post/sampling-diffusion/
  76198. *
  76199. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76200. * ------------------------------------------------------------------------------------
  76201. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76202. * PDF[r, phi, s] = r * R[r, phi, s]
  76203. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76204. * ------------------------------------------------------------------------------------
  76205. * We importance sample the color channel with the widest scattering distance.
  76206. */
  76207. getDiffusionProfileParameters(color: Color3): number;
  76208. /**
  76209. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76210. * 'u' is the random number (the value of the CDF): [0, 1).
  76211. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76212. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76213. */
  76214. private _sampleBurleyDiffusionProfile;
  76215. }
  76216. }
  76217. declare module BABYLON {
  76218. interface AbstractScene {
  76219. /** @hidden (Backing field) */
  76220. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76221. /**
  76222. * Gets or Sets the current prepass renderer associated to the scene.
  76223. */
  76224. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76225. /**
  76226. * Enables the subsurface effect for prepass
  76227. * @returns the SubSurfaceConfiguration
  76228. */
  76229. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76230. /**
  76231. * Disables the subsurface effect for prepass
  76232. */
  76233. disableSubSurfaceForPrePass(): void;
  76234. }
  76235. /**
  76236. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76237. * in several rendering techniques.
  76238. */
  76239. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76240. /**
  76241. * The component name helpful to identify the component in the list of scene components.
  76242. */
  76243. readonly name: string;
  76244. /**
  76245. * The scene the component belongs to.
  76246. */
  76247. scene: Scene;
  76248. /**
  76249. * Creates a new instance of the component for the given scene
  76250. * @param scene Defines the scene to register the component in
  76251. */
  76252. constructor(scene: Scene);
  76253. /**
  76254. * Registers the component in a given scene
  76255. */
  76256. register(): void;
  76257. /**
  76258. * Serializes the component data to the specified json object
  76259. * @param serializationObject The object to serialize to
  76260. */
  76261. serialize(serializationObject: any): void;
  76262. /**
  76263. * Adds all the elements from the container to the scene
  76264. * @param container the container holding the elements
  76265. */
  76266. addFromContainer(container: AbstractScene): void;
  76267. /**
  76268. * Removes all the elements in the container from the scene
  76269. * @param container contains the elements to remove
  76270. * @param dispose if the removed element should be disposed (default: false)
  76271. */
  76272. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76273. /**
  76274. * Rebuilds the elements related to this component in case of
  76275. * context lost for instance.
  76276. */
  76277. rebuild(): void;
  76278. /**
  76279. * Disposes the component and the associated ressources
  76280. */
  76281. dispose(): void;
  76282. }
  76283. }
  76284. declare module BABYLON {
  76285. /** @hidden */
  76286. export var outlinePixelShader: {
  76287. name: string;
  76288. shader: string;
  76289. };
  76290. }
  76291. declare module BABYLON {
  76292. /** @hidden */
  76293. export var outlineVertexShader: {
  76294. name: string;
  76295. shader: string;
  76296. };
  76297. }
  76298. declare module BABYLON {
  76299. interface Scene {
  76300. /** @hidden */
  76301. _outlineRenderer: OutlineRenderer;
  76302. /**
  76303. * Gets the outline renderer associated with the scene
  76304. * @returns a OutlineRenderer
  76305. */
  76306. getOutlineRenderer(): OutlineRenderer;
  76307. }
  76308. interface AbstractMesh {
  76309. /** @hidden (Backing field) */
  76310. _renderOutline: boolean;
  76311. /**
  76312. * Gets or sets a boolean indicating if the outline must be rendered as well
  76313. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76314. */
  76315. renderOutline: boolean;
  76316. /** @hidden (Backing field) */
  76317. _renderOverlay: boolean;
  76318. /**
  76319. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76320. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76321. */
  76322. renderOverlay: boolean;
  76323. }
  76324. /**
  76325. * This class is responsible to draw bothe outline/overlay of meshes.
  76326. * It should not be used directly but through the available method on mesh.
  76327. */
  76328. export class OutlineRenderer implements ISceneComponent {
  76329. /**
  76330. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76331. */
  76332. private static _StencilReference;
  76333. /**
  76334. * The name of the component. Each component must have a unique name.
  76335. */
  76336. name: string;
  76337. /**
  76338. * The scene the component belongs to.
  76339. */
  76340. scene: Scene;
  76341. /**
  76342. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76343. */
  76344. zOffset: number;
  76345. private _engine;
  76346. private _effect;
  76347. private _cachedDefines;
  76348. private _savedDepthWrite;
  76349. /**
  76350. * Instantiates a new outline renderer. (There could be only one per scene).
  76351. * @param scene Defines the scene it belongs to
  76352. */
  76353. constructor(scene: Scene);
  76354. /**
  76355. * Register the component to one instance of a scene.
  76356. */
  76357. register(): void;
  76358. /**
  76359. * Rebuilds the elements related to this component in case of
  76360. * context lost for instance.
  76361. */
  76362. rebuild(): void;
  76363. /**
  76364. * Disposes the component and the associated ressources.
  76365. */
  76366. dispose(): void;
  76367. /**
  76368. * Renders the outline in the canvas.
  76369. * @param subMesh Defines the sumesh to render
  76370. * @param batch Defines the batch of meshes in case of instances
  76371. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76372. */
  76373. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76374. /**
  76375. * Returns whether or not the outline renderer is ready for a given submesh.
  76376. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76377. * @param subMesh Defines the submesh to check readyness for
  76378. * @param useInstances Defines wheter wee are trying to render instances or not
  76379. * @returns true if ready otherwise false
  76380. */
  76381. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76382. private _beforeRenderingMesh;
  76383. private _afterRenderingMesh;
  76384. }
  76385. }
  76386. declare module BABYLON {
  76387. /**
  76388. * Defines the basic options interface of a Sprite Frame Source Size.
  76389. */
  76390. export interface ISpriteJSONSpriteSourceSize {
  76391. /**
  76392. * number of the original width of the Frame
  76393. */
  76394. w: number;
  76395. /**
  76396. * number of the original height of the Frame
  76397. */
  76398. h: number;
  76399. }
  76400. /**
  76401. * Defines the basic options interface of a Sprite Frame Data.
  76402. */
  76403. export interface ISpriteJSONSpriteFrameData {
  76404. /**
  76405. * number of the x offset of the Frame
  76406. */
  76407. x: number;
  76408. /**
  76409. * number of the y offset of the Frame
  76410. */
  76411. y: number;
  76412. /**
  76413. * number of the width of the Frame
  76414. */
  76415. w: number;
  76416. /**
  76417. * number of the height of the Frame
  76418. */
  76419. h: number;
  76420. }
  76421. /**
  76422. * Defines the basic options interface of a JSON Sprite.
  76423. */
  76424. export interface ISpriteJSONSprite {
  76425. /**
  76426. * string name of the Frame
  76427. */
  76428. filename: string;
  76429. /**
  76430. * ISpriteJSONSpriteFrame basic object of the frame data
  76431. */
  76432. frame: ISpriteJSONSpriteFrameData;
  76433. /**
  76434. * boolean to flag is the frame was rotated.
  76435. */
  76436. rotated: boolean;
  76437. /**
  76438. * boolean to flag is the frame was trimmed.
  76439. */
  76440. trimmed: boolean;
  76441. /**
  76442. * ISpriteJSONSpriteFrame basic object of the source data
  76443. */
  76444. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76445. /**
  76446. * ISpriteJSONSpriteFrame basic object of the source data
  76447. */
  76448. sourceSize: ISpriteJSONSpriteSourceSize;
  76449. }
  76450. /**
  76451. * Defines the basic options interface of a JSON atlas.
  76452. */
  76453. export interface ISpriteJSONAtlas {
  76454. /**
  76455. * Array of objects that contain the frame data.
  76456. */
  76457. frames: Array<ISpriteJSONSprite>;
  76458. /**
  76459. * object basic object containing the sprite meta data.
  76460. */
  76461. meta?: object;
  76462. }
  76463. }
  76464. declare module BABYLON {
  76465. /** @hidden */
  76466. export var spriteMapPixelShader: {
  76467. name: string;
  76468. shader: string;
  76469. };
  76470. }
  76471. declare module BABYLON {
  76472. /** @hidden */
  76473. export var spriteMapVertexShader: {
  76474. name: string;
  76475. shader: string;
  76476. };
  76477. }
  76478. declare module BABYLON {
  76479. /**
  76480. * Defines the basic options interface of a SpriteMap
  76481. */
  76482. export interface ISpriteMapOptions {
  76483. /**
  76484. * Vector2 of the number of cells in the grid.
  76485. */
  76486. stageSize?: Vector2;
  76487. /**
  76488. * Vector2 of the size of the output plane in World Units.
  76489. */
  76490. outputSize?: Vector2;
  76491. /**
  76492. * Vector3 of the position of the output plane in World Units.
  76493. */
  76494. outputPosition?: Vector3;
  76495. /**
  76496. * Vector3 of the rotation of the output plane.
  76497. */
  76498. outputRotation?: Vector3;
  76499. /**
  76500. * number of layers that the system will reserve in resources.
  76501. */
  76502. layerCount?: number;
  76503. /**
  76504. * number of max animation frames a single cell will reserve in resources.
  76505. */
  76506. maxAnimationFrames?: number;
  76507. /**
  76508. * number cell index of the base tile when the system compiles.
  76509. */
  76510. baseTile?: number;
  76511. /**
  76512. * boolean flip the sprite after its been repositioned by the framing data.
  76513. */
  76514. flipU?: boolean;
  76515. /**
  76516. * Vector3 scalar of the global RGB values of the SpriteMap.
  76517. */
  76518. colorMultiply?: Vector3;
  76519. }
  76520. /**
  76521. * Defines the IDisposable interface in order to be cleanable from resources.
  76522. */
  76523. export interface ISpriteMap extends IDisposable {
  76524. /**
  76525. * String name of the SpriteMap.
  76526. */
  76527. name: string;
  76528. /**
  76529. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76530. */
  76531. atlasJSON: ISpriteJSONAtlas;
  76532. /**
  76533. * Texture of the SpriteMap.
  76534. */
  76535. spriteSheet: Texture;
  76536. /**
  76537. * The parameters to initialize the SpriteMap with.
  76538. */
  76539. options: ISpriteMapOptions;
  76540. }
  76541. /**
  76542. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76543. */
  76544. export class SpriteMap implements ISpriteMap {
  76545. /** The Name of the spriteMap */
  76546. name: string;
  76547. /** The JSON file with the frame and meta data */
  76548. atlasJSON: ISpriteJSONAtlas;
  76549. /** The systems Sprite Sheet Texture */
  76550. spriteSheet: Texture;
  76551. /** Arguments passed with the Constructor */
  76552. options: ISpriteMapOptions;
  76553. /** Public Sprite Storage array, parsed from atlasJSON */
  76554. sprites: Array<ISpriteJSONSprite>;
  76555. /** Returns the Number of Sprites in the System */
  76556. get spriteCount(): number;
  76557. /** Returns the Position of Output Plane*/
  76558. get position(): Vector3;
  76559. /** Returns the Position of Output Plane*/
  76560. set position(v: Vector3);
  76561. /** Returns the Rotation of Output Plane*/
  76562. get rotation(): Vector3;
  76563. /** Returns the Rotation of Output Plane*/
  76564. set rotation(v: Vector3);
  76565. /** Sets the AnimationMap*/
  76566. get animationMap(): RawTexture;
  76567. /** Sets the AnimationMap*/
  76568. set animationMap(v: RawTexture);
  76569. /** Scene that the SpriteMap was created in */
  76570. private _scene;
  76571. /** Texture Buffer of Float32 that holds tile frame data*/
  76572. private _frameMap;
  76573. /** Texture Buffers of Float32 that holds tileMap data*/
  76574. private _tileMaps;
  76575. /** Texture Buffer of Float32 that holds Animation Data*/
  76576. private _animationMap;
  76577. /** Custom ShaderMaterial Central to the System*/
  76578. private _material;
  76579. /** Custom ShaderMaterial Central to the System*/
  76580. private _output;
  76581. /** Systems Time Ticker*/
  76582. private _time;
  76583. /**
  76584. * Creates a new SpriteMap
  76585. * @param name defines the SpriteMaps Name
  76586. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76587. * @param spriteSheet is the Texture that the Sprites are on.
  76588. * @param options a basic deployment configuration
  76589. * @param scene The Scene that the map is deployed on
  76590. */
  76591. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76592. /**
  76593. * Returns tileID location
  76594. * @returns Vector2 the cell position ID
  76595. */
  76596. getTileID(): Vector2;
  76597. /**
  76598. * Gets the UV location of the mouse over the SpriteMap.
  76599. * @returns Vector2 the UV position of the mouse interaction
  76600. */
  76601. getMousePosition(): Vector2;
  76602. /**
  76603. * Creates the "frame" texture Buffer
  76604. * -------------------------------------
  76605. * Structure of frames
  76606. * "filename": "Falling-Water-2.png",
  76607. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76608. * "rotated": true,
  76609. * "trimmed": true,
  76610. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76611. * "sourceSize": {"w":32,"h":32}
  76612. * @returns RawTexture of the frameMap
  76613. */
  76614. private _createFrameBuffer;
  76615. /**
  76616. * Creates the tileMap texture Buffer
  76617. * @param buffer normally and array of numbers, or a false to generate from scratch
  76618. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76619. * @returns RawTexture of the tileMap
  76620. */
  76621. private _createTileBuffer;
  76622. /**
  76623. * Modifies the data of the tileMaps
  76624. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76625. * @param pos is the iVector2 Coordinates of the Tile
  76626. * @param tile The SpriteIndex of the new Tile
  76627. */
  76628. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76629. /**
  76630. * Creates the animationMap texture Buffer
  76631. * @param buffer normally and array of numbers, or a false to generate from scratch
  76632. * @returns RawTexture of the animationMap
  76633. */
  76634. private _createTileAnimationBuffer;
  76635. /**
  76636. * Modifies the data of the animationMap
  76637. * @param cellID is the Index of the Sprite
  76638. * @param _frame is the target Animation frame
  76639. * @param toCell is the Target Index of the next frame of the animation
  76640. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76641. * @param speed is a global scalar of the time variable on the map.
  76642. */
  76643. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76644. /**
  76645. * Exports the .tilemaps file
  76646. */
  76647. saveTileMaps(): void;
  76648. /**
  76649. * Imports the .tilemaps file
  76650. * @param url of the .tilemaps file
  76651. */
  76652. loadTileMaps(url: string): void;
  76653. /**
  76654. * Release associated resources
  76655. */
  76656. dispose(): void;
  76657. }
  76658. }
  76659. declare module BABYLON {
  76660. /**
  76661. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76662. * @see https://doc.babylonjs.com/babylon101/sprites
  76663. */
  76664. export class SpritePackedManager extends SpriteManager {
  76665. /** defines the packed manager's name */
  76666. name: string;
  76667. /**
  76668. * Creates a new sprite manager from a packed sprite sheet
  76669. * @param name defines the manager's name
  76670. * @param imgUrl defines the sprite sheet url
  76671. * @param capacity defines the maximum allowed number of sprites
  76672. * @param scene defines the hosting scene
  76673. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76674. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76675. * @param samplingMode defines the smapling mode to use with spritesheet
  76676. * @param fromPacked set to true; do not alter
  76677. */
  76678. constructor(
  76679. /** defines the packed manager's name */
  76680. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76681. }
  76682. }
  76683. declare module BABYLON {
  76684. /**
  76685. * Defines the list of states available for a task inside a AssetsManager
  76686. */
  76687. export enum AssetTaskState {
  76688. /**
  76689. * Initialization
  76690. */
  76691. INIT = 0,
  76692. /**
  76693. * Running
  76694. */
  76695. RUNNING = 1,
  76696. /**
  76697. * Done
  76698. */
  76699. DONE = 2,
  76700. /**
  76701. * Error
  76702. */
  76703. ERROR = 3
  76704. }
  76705. /**
  76706. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76707. */
  76708. export abstract class AbstractAssetTask {
  76709. /**
  76710. * Task name
  76711. */ name: string;
  76712. /**
  76713. * Callback called when the task is successful
  76714. */
  76715. onSuccess: (task: any) => void;
  76716. /**
  76717. * Callback called when the task is not successful
  76718. */
  76719. onError: (task: any, message?: string, exception?: any) => void;
  76720. /**
  76721. * Creates a new AssetsManager
  76722. * @param name defines the name of the task
  76723. */
  76724. constructor(
  76725. /**
  76726. * Task name
  76727. */ name: string);
  76728. private _isCompleted;
  76729. private _taskState;
  76730. private _errorObject;
  76731. /**
  76732. * Get if the task is completed
  76733. */
  76734. get isCompleted(): boolean;
  76735. /**
  76736. * Gets the current state of the task
  76737. */
  76738. get taskState(): AssetTaskState;
  76739. /**
  76740. * Gets the current error object (if task is in error)
  76741. */
  76742. get errorObject(): {
  76743. message?: string;
  76744. exception?: any;
  76745. };
  76746. /**
  76747. * Internal only
  76748. * @hidden
  76749. */
  76750. _setErrorObject(message?: string, exception?: any): void;
  76751. /**
  76752. * Execute the current task
  76753. * @param scene defines the scene where you want your assets to be loaded
  76754. * @param onSuccess is a callback called when the task is successfully executed
  76755. * @param onError is a callback called if an error occurs
  76756. */
  76757. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76758. /**
  76759. * Execute the current task
  76760. * @param scene defines the scene where you want your assets to be loaded
  76761. * @param onSuccess is a callback called when the task is successfully executed
  76762. * @param onError is a callback called if an error occurs
  76763. */
  76764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76765. /**
  76766. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76767. * This can be used with failed tasks that have the reason for failure fixed.
  76768. */
  76769. reset(): void;
  76770. private onErrorCallback;
  76771. private onDoneCallback;
  76772. }
  76773. /**
  76774. * Define the interface used by progress events raised during assets loading
  76775. */
  76776. export interface IAssetsProgressEvent {
  76777. /**
  76778. * Defines the number of remaining tasks to process
  76779. */
  76780. remainingCount: number;
  76781. /**
  76782. * Defines the total number of tasks
  76783. */
  76784. totalCount: number;
  76785. /**
  76786. * Defines the task that was just processed
  76787. */
  76788. task: AbstractAssetTask;
  76789. }
  76790. /**
  76791. * Class used to share progress information about assets loading
  76792. */
  76793. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76794. /**
  76795. * Defines the number of remaining tasks to process
  76796. */
  76797. remainingCount: number;
  76798. /**
  76799. * Defines the total number of tasks
  76800. */
  76801. totalCount: number;
  76802. /**
  76803. * Defines the task that was just processed
  76804. */
  76805. task: AbstractAssetTask;
  76806. /**
  76807. * Creates a AssetsProgressEvent
  76808. * @param remainingCount defines the number of remaining tasks to process
  76809. * @param totalCount defines the total number of tasks
  76810. * @param task defines the task that was just processed
  76811. */
  76812. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76813. }
  76814. /**
  76815. * Define a task used by AssetsManager to load assets into a container
  76816. */
  76817. export class ContainerAssetTask extends AbstractAssetTask {
  76818. /**
  76819. * Defines the name of the task
  76820. */
  76821. name: string;
  76822. /**
  76823. * Defines the list of mesh's names you want to load
  76824. */
  76825. meshesNames: any;
  76826. /**
  76827. * Defines the root url to use as a base to load your meshes and associated resources
  76828. */
  76829. rootUrl: string;
  76830. /**
  76831. * Defines the filename or File of the scene to load from
  76832. */
  76833. sceneFilename: string | File;
  76834. /**
  76835. * Get the loaded asset container
  76836. */
  76837. loadedContainer: AssetContainer;
  76838. /**
  76839. * Gets the list of loaded meshes
  76840. */
  76841. loadedMeshes: Array<AbstractMesh>;
  76842. /**
  76843. * Gets the list of loaded particle systems
  76844. */
  76845. loadedParticleSystems: Array<IParticleSystem>;
  76846. /**
  76847. * Gets the list of loaded skeletons
  76848. */
  76849. loadedSkeletons: Array<Skeleton>;
  76850. /**
  76851. * Gets the list of loaded animation groups
  76852. */
  76853. loadedAnimationGroups: Array<AnimationGroup>;
  76854. /**
  76855. * Callback called when the task is successful
  76856. */
  76857. onSuccess: (task: ContainerAssetTask) => void;
  76858. /**
  76859. * Callback called when the task is successful
  76860. */
  76861. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76862. /**
  76863. * Creates a new ContainerAssetTask
  76864. * @param name defines the name of the task
  76865. * @param meshesNames defines the list of mesh's names you want to load
  76866. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76867. * @param sceneFilename defines the filename or File of the scene to load from
  76868. */
  76869. constructor(
  76870. /**
  76871. * Defines the name of the task
  76872. */
  76873. name: string,
  76874. /**
  76875. * Defines the list of mesh's names you want to load
  76876. */
  76877. meshesNames: any,
  76878. /**
  76879. * Defines the root url to use as a base to load your meshes and associated resources
  76880. */
  76881. rootUrl: string,
  76882. /**
  76883. * Defines the filename or File of the scene to load from
  76884. */
  76885. sceneFilename: string | File);
  76886. /**
  76887. * Execute the current task
  76888. * @param scene defines the scene where you want your assets to be loaded
  76889. * @param onSuccess is a callback called when the task is successfully executed
  76890. * @param onError is a callback called if an error occurs
  76891. */
  76892. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76893. }
  76894. /**
  76895. * Define a task used by AssetsManager to load meshes
  76896. */
  76897. export class MeshAssetTask extends AbstractAssetTask {
  76898. /**
  76899. * Defines the name of the task
  76900. */
  76901. name: string;
  76902. /**
  76903. * Defines the list of mesh's names you want to load
  76904. */
  76905. meshesNames: any;
  76906. /**
  76907. * Defines the root url to use as a base to load your meshes and associated resources
  76908. */
  76909. rootUrl: string;
  76910. /**
  76911. * Defines the filename or File of the scene to load from
  76912. */
  76913. sceneFilename: string | File;
  76914. /**
  76915. * Gets the list of loaded meshes
  76916. */
  76917. loadedMeshes: Array<AbstractMesh>;
  76918. /**
  76919. * Gets the list of loaded particle systems
  76920. */
  76921. loadedParticleSystems: Array<IParticleSystem>;
  76922. /**
  76923. * Gets the list of loaded skeletons
  76924. */
  76925. loadedSkeletons: Array<Skeleton>;
  76926. /**
  76927. * Gets the list of loaded animation groups
  76928. */
  76929. loadedAnimationGroups: Array<AnimationGroup>;
  76930. /**
  76931. * Callback called when the task is successful
  76932. */
  76933. onSuccess: (task: MeshAssetTask) => void;
  76934. /**
  76935. * Callback called when the task is successful
  76936. */
  76937. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  76938. /**
  76939. * Creates a new MeshAssetTask
  76940. * @param name defines the name of the task
  76941. * @param meshesNames defines the list of mesh's names you want to load
  76942. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76943. * @param sceneFilename defines the filename or File of the scene to load from
  76944. */
  76945. constructor(
  76946. /**
  76947. * Defines the name of the task
  76948. */
  76949. name: string,
  76950. /**
  76951. * Defines the list of mesh's names you want to load
  76952. */
  76953. meshesNames: any,
  76954. /**
  76955. * Defines the root url to use as a base to load your meshes and associated resources
  76956. */
  76957. rootUrl: string,
  76958. /**
  76959. * Defines the filename or File of the scene to load from
  76960. */
  76961. sceneFilename: string | File);
  76962. /**
  76963. * Execute the current task
  76964. * @param scene defines the scene where you want your assets to be loaded
  76965. * @param onSuccess is a callback called when the task is successfully executed
  76966. * @param onError is a callback called if an error occurs
  76967. */
  76968. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76969. }
  76970. /**
  76971. * Define a task used by AssetsManager to load text content
  76972. */
  76973. export class TextFileAssetTask extends AbstractAssetTask {
  76974. /**
  76975. * Defines the name of the task
  76976. */
  76977. name: string;
  76978. /**
  76979. * Defines the location of the file to load
  76980. */
  76981. url: string;
  76982. /**
  76983. * Gets the loaded text string
  76984. */
  76985. text: string;
  76986. /**
  76987. * Callback called when the task is successful
  76988. */
  76989. onSuccess: (task: TextFileAssetTask) => void;
  76990. /**
  76991. * Callback called when the task is successful
  76992. */
  76993. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  76994. /**
  76995. * Creates a new TextFileAssetTask object
  76996. * @param name defines the name of the task
  76997. * @param url defines the location of the file to load
  76998. */
  76999. constructor(
  77000. /**
  77001. * Defines the name of the task
  77002. */
  77003. name: string,
  77004. /**
  77005. * Defines the location of the file to load
  77006. */
  77007. url: string);
  77008. /**
  77009. * Execute the current task
  77010. * @param scene defines the scene where you want your assets to be loaded
  77011. * @param onSuccess is a callback called when the task is successfully executed
  77012. * @param onError is a callback called if an error occurs
  77013. */
  77014. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77015. }
  77016. /**
  77017. * Define a task used by AssetsManager to load binary data
  77018. */
  77019. export class BinaryFileAssetTask extends AbstractAssetTask {
  77020. /**
  77021. * Defines the name of the task
  77022. */
  77023. name: string;
  77024. /**
  77025. * Defines the location of the file to load
  77026. */
  77027. url: string;
  77028. /**
  77029. * Gets the lodaded data (as an array buffer)
  77030. */
  77031. data: ArrayBuffer;
  77032. /**
  77033. * Callback called when the task is successful
  77034. */
  77035. onSuccess: (task: BinaryFileAssetTask) => void;
  77036. /**
  77037. * Callback called when the task is successful
  77038. */
  77039. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77040. /**
  77041. * Creates a new BinaryFileAssetTask object
  77042. * @param name defines the name of the new task
  77043. * @param url defines the location of the file to load
  77044. */
  77045. constructor(
  77046. /**
  77047. * Defines the name of the task
  77048. */
  77049. name: string,
  77050. /**
  77051. * Defines the location of the file to load
  77052. */
  77053. url: string);
  77054. /**
  77055. * Execute the current task
  77056. * @param scene defines the scene where you want your assets to be loaded
  77057. * @param onSuccess is a callback called when the task is successfully executed
  77058. * @param onError is a callback called if an error occurs
  77059. */
  77060. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77061. }
  77062. /**
  77063. * Define a task used by AssetsManager to load images
  77064. */
  77065. export class ImageAssetTask extends AbstractAssetTask {
  77066. /**
  77067. * Defines the name of the task
  77068. */
  77069. name: string;
  77070. /**
  77071. * Defines the location of the image to load
  77072. */
  77073. url: string;
  77074. /**
  77075. * Gets the loaded images
  77076. */
  77077. image: HTMLImageElement;
  77078. /**
  77079. * Callback called when the task is successful
  77080. */
  77081. onSuccess: (task: ImageAssetTask) => void;
  77082. /**
  77083. * Callback called when the task is successful
  77084. */
  77085. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77086. /**
  77087. * Creates a new ImageAssetTask
  77088. * @param name defines the name of the task
  77089. * @param url defines the location of the image to load
  77090. */
  77091. constructor(
  77092. /**
  77093. * Defines the name of the task
  77094. */
  77095. name: string,
  77096. /**
  77097. * Defines the location of the image to load
  77098. */
  77099. url: string);
  77100. /**
  77101. * Execute the current task
  77102. * @param scene defines the scene where you want your assets to be loaded
  77103. * @param onSuccess is a callback called when the task is successfully executed
  77104. * @param onError is a callback called if an error occurs
  77105. */
  77106. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77107. }
  77108. /**
  77109. * Defines the interface used by texture loading tasks
  77110. */
  77111. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77112. /**
  77113. * Gets the loaded texture
  77114. */
  77115. texture: TEX;
  77116. }
  77117. /**
  77118. * Define a task used by AssetsManager to load 2D textures
  77119. */
  77120. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77121. /**
  77122. * Defines the name of the task
  77123. */
  77124. name: string;
  77125. /**
  77126. * Defines the location of the file to load
  77127. */
  77128. url: string;
  77129. /**
  77130. * Defines if mipmap should not be generated (default is false)
  77131. */
  77132. noMipmap?: boolean | undefined;
  77133. /**
  77134. * Defines if texture must be inverted on Y axis (default is true)
  77135. */
  77136. invertY: boolean;
  77137. /**
  77138. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77139. */
  77140. samplingMode: number;
  77141. /**
  77142. * Gets the loaded texture
  77143. */
  77144. texture: Texture;
  77145. /**
  77146. * Callback called when the task is successful
  77147. */
  77148. onSuccess: (task: TextureAssetTask) => void;
  77149. /**
  77150. * Callback called when the task is successful
  77151. */
  77152. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77153. /**
  77154. * Creates a new TextureAssetTask object
  77155. * @param name defines the name of the task
  77156. * @param url defines the location of the file to load
  77157. * @param noMipmap defines if mipmap should not be generated (default is false)
  77158. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77159. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77160. */
  77161. constructor(
  77162. /**
  77163. * Defines the name of the task
  77164. */
  77165. name: string,
  77166. /**
  77167. * Defines the location of the file to load
  77168. */
  77169. url: string,
  77170. /**
  77171. * Defines if mipmap should not be generated (default is false)
  77172. */
  77173. noMipmap?: boolean | undefined,
  77174. /**
  77175. * Defines if texture must be inverted on Y axis (default is true)
  77176. */
  77177. invertY?: boolean,
  77178. /**
  77179. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77180. */
  77181. samplingMode?: number);
  77182. /**
  77183. * Execute the current task
  77184. * @param scene defines the scene where you want your assets to be loaded
  77185. * @param onSuccess is a callback called when the task is successfully executed
  77186. * @param onError is a callback called if an error occurs
  77187. */
  77188. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77189. }
  77190. /**
  77191. * Define a task used by AssetsManager to load cube textures
  77192. */
  77193. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77194. /**
  77195. * Defines the name of the task
  77196. */
  77197. name: string;
  77198. /**
  77199. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77200. */
  77201. url: string;
  77202. /**
  77203. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77204. */
  77205. extensions?: string[] | undefined;
  77206. /**
  77207. * Defines if mipmaps should not be generated (default is false)
  77208. */
  77209. noMipmap?: boolean | undefined;
  77210. /**
  77211. * Defines the explicit list of files (undefined by default)
  77212. */
  77213. files?: string[] | undefined;
  77214. /**
  77215. * Gets the loaded texture
  77216. */
  77217. texture: CubeTexture;
  77218. /**
  77219. * Callback called when the task is successful
  77220. */
  77221. onSuccess: (task: CubeTextureAssetTask) => void;
  77222. /**
  77223. * Callback called when the task is successful
  77224. */
  77225. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77226. /**
  77227. * Creates a new CubeTextureAssetTask
  77228. * @param name defines the name of the task
  77229. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77230. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77231. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77232. * @param files defines the explicit list of files (undefined by default)
  77233. */
  77234. constructor(
  77235. /**
  77236. * Defines the name of the task
  77237. */
  77238. name: string,
  77239. /**
  77240. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77241. */
  77242. url: string,
  77243. /**
  77244. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77245. */
  77246. extensions?: string[] | undefined,
  77247. /**
  77248. * Defines if mipmaps should not be generated (default is false)
  77249. */
  77250. noMipmap?: boolean | undefined,
  77251. /**
  77252. * Defines the explicit list of files (undefined by default)
  77253. */
  77254. files?: string[] | undefined);
  77255. /**
  77256. * Execute the current task
  77257. * @param scene defines the scene where you want your assets to be loaded
  77258. * @param onSuccess is a callback called when the task is successfully executed
  77259. * @param onError is a callback called if an error occurs
  77260. */
  77261. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77262. }
  77263. /**
  77264. * Define a task used by AssetsManager to load HDR cube textures
  77265. */
  77266. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77267. /**
  77268. * Defines the name of the task
  77269. */
  77270. name: string;
  77271. /**
  77272. * Defines the location of the file to load
  77273. */
  77274. url: string;
  77275. /**
  77276. * Defines the desired size (the more it increases the longer the generation will be)
  77277. */
  77278. size: number;
  77279. /**
  77280. * Defines if mipmaps should not be generated (default is false)
  77281. */
  77282. noMipmap: boolean;
  77283. /**
  77284. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77285. */
  77286. generateHarmonics: boolean;
  77287. /**
  77288. * 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)
  77289. */
  77290. gammaSpace: boolean;
  77291. /**
  77292. * Internal Use Only
  77293. */
  77294. reserved: boolean;
  77295. /**
  77296. * Gets the loaded texture
  77297. */
  77298. texture: HDRCubeTexture;
  77299. /**
  77300. * Callback called when the task is successful
  77301. */
  77302. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77303. /**
  77304. * Callback called when the task is successful
  77305. */
  77306. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77307. /**
  77308. * Creates a new HDRCubeTextureAssetTask object
  77309. * @param name defines the name of the task
  77310. * @param url defines the location of the file to load
  77311. * @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.
  77312. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77313. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77314. * @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)
  77315. * @param reserved Internal use only
  77316. */
  77317. constructor(
  77318. /**
  77319. * Defines the name of the task
  77320. */
  77321. name: string,
  77322. /**
  77323. * Defines the location of the file to load
  77324. */
  77325. url: string,
  77326. /**
  77327. * Defines the desired size (the more it increases the longer the generation will be)
  77328. */
  77329. size: number,
  77330. /**
  77331. * Defines if mipmaps should not be generated (default is false)
  77332. */
  77333. noMipmap?: boolean,
  77334. /**
  77335. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77336. */
  77337. generateHarmonics?: boolean,
  77338. /**
  77339. * 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)
  77340. */
  77341. gammaSpace?: boolean,
  77342. /**
  77343. * Internal Use Only
  77344. */
  77345. reserved?: boolean);
  77346. /**
  77347. * Execute the current task
  77348. * @param scene defines the scene where you want your assets to be loaded
  77349. * @param onSuccess is a callback called when the task is successfully executed
  77350. * @param onError is a callback called if an error occurs
  77351. */
  77352. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77353. }
  77354. /**
  77355. * Define a task used by AssetsManager to load Equirectangular cube textures
  77356. */
  77357. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77358. /**
  77359. * Defines the name of the task
  77360. */
  77361. name: string;
  77362. /**
  77363. * Defines the location of the file to load
  77364. */
  77365. url: string;
  77366. /**
  77367. * Defines the desired size (the more it increases the longer the generation will be)
  77368. */
  77369. size: number;
  77370. /**
  77371. * Defines if mipmaps should not be generated (default is false)
  77372. */
  77373. noMipmap: boolean;
  77374. /**
  77375. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77376. * but the standard material would require them in Gamma space) (default is true)
  77377. */
  77378. gammaSpace: boolean;
  77379. /**
  77380. * Gets the loaded texture
  77381. */
  77382. texture: EquiRectangularCubeTexture;
  77383. /**
  77384. * Callback called when the task is successful
  77385. */
  77386. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77387. /**
  77388. * Callback called when the task is successful
  77389. */
  77390. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77391. /**
  77392. * Creates a new EquiRectangularCubeTextureAssetTask object
  77393. * @param name defines the name of the task
  77394. * @param url defines the location of the file to load
  77395. * @param size defines the desired size (the more it increases the longer the generation will be)
  77396. * If the size is omitted this implies you are using a preprocessed cubemap.
  77397. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77398. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77399. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77400. * (default is true)
  77401. */
  77402. constructor(
  77403. /**
  77404. * Defines the name of the task
  77405. */
  77406. name: string,
  77407. /**
  77408. * Defines the location of the file to load
  77409. */
  77410. url: string,
  77411. /**
  77412. * Defines the desired size (the more it increases the longer the generation will be)
  77413. */
  77414. size: number,
  77415. /**
  77416. * Defines if mipmaps should not be generated (default is false)
  77417. */
  77418. noMipmap?: boolean,
  77419. /**
  77420. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77421. * but the standard material would require them in Gamma space) (default is true)
  77422. */
  77423. gammaSpace?: boolean);
  77424. /**
  77425. * Execute the current task
  77426. * @param scene defines the scene where you want your assets to be loaded
  77427. * @param onSuccess is a callback called when the task is successfully executed
  77428. * @param onError is a callback called if an error occurs
  77429. */
  77430. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77431. }
  77432. /**
  77433. * This class can be used to easily import assets into a scene
  77434. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77435. */
  77436. export class AssetsManager {
  77437. private _scene;
  77438. private _isLoading;
  77439. protected _tasks: AbstractAssetTask[];
  77440. protected _waitingTasksCount: number;
  77441. protected _totalTasksCount: number;
  77442. /**
  77443. * Callback called when all tasks are processed
  77444. */
  77445. onFinish: (tasks: AbstractAssetTask[]) => void;
  77446. /**
  77447. * Callback called when a task is successful
  77448. */
  77449. onTaskSuccess: (task: AbstractAssetTask) => void;
  77450. /**
  77451. * Callback called when a task had an error
  77452. */
  77453. onTaskError: (task: AbstractAssetTask) => void;
  77454. /**
  77455. * Callback called when a task is done (whatever the result is)
  77456. */
  77457. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77458. /**
  77459. * Observable called when all tasks are processed
  77460. */
  77461. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77462. /**
  77463. * Observable called when a task had an error
  77464. */
  77465. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77466. /**
  77467. * Observable called when all tasks were executed
  77468. */
  77469. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77470. /**
  77471. * Observable called when a task is done (whatever the result is)
  77472. */
  77473. onProgressObservable: Observable<IAssetsProgressEvent>;
  77474. /**
  77475. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77476. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77477. */
  77478. useDefaultLoadingScreen: boolean;
  77479. /**
  77480. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77481. * when all assets have been downloaded.
  77482. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77483. */
  77484. autoHideLoadingUI: boolean;
  77485. /**
  77486. * Creates a new AssetsManager
  77487. * @param scene defines the scene to work on
  77488. */
  77489. constructor(scene: Scene);
  77490. /**
  77491. * Add a ContainerAssetTask to the list of active tasks
  77492. * @param taskName defines the name of the new task
  77493. * @param meshesNames defines the name of meshes to load
  77494. * @param rootUrl defines the root url to use to locate files
  77495. * @param sceneFilename defines the filename of the scene file
  77496. * @returns a new ContainerAssetTask object
  77497. */
  77498. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77499. /**
  77500. * Add a MeshAssetTask to the list of active tasks
  77501. * @param taskName defines the name of the new task
  77502. * @param meshesNames defines the name of meshes to load
  77503. * @param rootUrl defines the root url to use to locate files
  77504. * @param sceneFilename defines the filename of the scene file
  77505. * @returns a new MeshAssetTask object
  77506. */
  77507. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77508. /**
  77509. * Add a TextFileAssetTask to the list of active tasks
  77510. * @param taskName defines the name of the new task
  77511. * @param url defines the url of the file to load
  77512. * @returns a new TextFileAssetTask object
  77513. */
  77514. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77515. /**
  77516. * Add a BinaryFileAssetTask to the list of active tasks
  77517. * @param taskName defines the name of the new task
  77518. * @param url defines the url of the file to load
  77519. * @returns a new BinaryFileAssetTask object
  77520. */
  77521. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77522. /**
  77523. * Add a ImageAssetTask to the list of active tasks
  77524. * @param taskName defines the name of the new task
  77525. * @param url defines the url of the file to load
  77526. * @returns a new ImageAssetTask object
  77527. */
  77528. addImageTask(taskName: string, url: string): ImageAssetTask;
  77529. /**
  77530. * Add a TextureAssetTask to the list of active tasks
  77531. * @param taskName defines the name of the new task
  77532. * @param url defines the url of the file to load
  77533. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77534. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77535. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77536. * @returns a new TextureAssetTask object
  77537. */
  77538. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77539. /**
  77540. * Add a CubeTextureAssetTask to the list of active tasks
  77541. * @param taskName defines the name of the new task
  77542. * @param url defines the url of the file to load
  77543. * @param extensions defines the extension to use to load the cube map (can be null)
  77544. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77545. * @param files defines the list of files to load (can be null)
  77546. * @returns a new CubeTextureAssetTask object
  77547. */
  77548. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77549. /**
  77550. *
  77551. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77552. * @param taskName defines the name of the new task
  77553. * @param url defines the url of the file to load
  77554. * @param size defines the size you want for the cubemap (can be null)
  77555. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77556. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77557. * @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)
  77558. * @param reserved Internal use only
  77559. * @returns a new HDRCubeTextureAssetTask object
  77560. */
  77561. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77562. /**
  77563. *
  77564. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77565. * @param taskName defines the name of the new task
  77566. * @param url defines the url of the file to load
  77567. * @param size defines the size you want for the cubemap (can be null)
  77568. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77569. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77570. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77571. * @returns a new EquiRectangularCubeTextureAssetTask object
  77572. */
  77573. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77574. /**
  77575. * Remove a task from the assets manager.
  77576. * @param task the task to remove
  77577. */
  77578. removeTask(task: AbstractAssetTask): void;
  77579. private _decreaseWaitingTasksCount;
  77580. private _runTask;
  77581. /**
  77582. * Reset the AssetsManager and remove all tasks
  77583. * @return the current instance of the AssetsManager
  77584. */
  77585. reset(): AssetsManager;
  77586. /**
  77587. * Start the loading process
  77588. * @return the current instance of the AssetsManager
  77589. */
  77590. load(): AssetsManager;
  77591. /**
  77592. * Start the loading process as an async operation
  77593. * @return a promise returning the list of failed tasks
  77594. */
  77595. loadAsync(): Promise<void>;
  77596. }
  77597. }
  77598. declare module BABYLON {
  77599. /**
  77600. * Wrapper class for promise with external resolve and reject.
  77601. */
  77602. export class Deferred<T> {
  77603. /**
  77604. * The promise associated with this deferred object.
  77605. */
  77606. readonly promise: Promise<T>;
  77607. private _resolve;
  77608. private _reject;
  77609. /**
  77610. * The resolve method of the promise associated with this deferred object.
  77611. */
  77612. get resolve(): (value: T | PromiseLike<T>) => void;
  77613. /**
  77614. * The reject method of the promise associated with this deferred object.
  77615. */
  77616. get reject(): (reason?: any) => void;
  77617. /**
  77618. * Constructor for this deferred object.
  77619. */
  77620. constructor();
  77621. }
  77622. }
  77623. declare module BABYLON {
  77624. /**
  77625. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77626. */
  77627. export class MeshExploder {
  77628. private _centerMesh;
  77629. private _meshes;
  77630. private _meshesOrigins;
  77631. private _toCenterVectors;
  77632. private _scaledDirection;
  77633. private _newPosition;
  77634. private _centerPosition;
  77635. /**
  77636. * Explodes meshes from a center mesh.
  77637. * @param meshes The meshes to explode.
  77638. * @param centerMesh The mesh to be center of explosion.
  77639. */
  77640. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77641. private _setCenterMesh;
  77642. /**
  77643. * Get class name
  77644. * @returns "MeshExploder"
  77645. */
  77646. getClassName(): string;
  77647. /**
  77648. * "Exploded meshes"
  77649. * @returns Array of meshes with the centerMesh at index 0.
  77650. */
  77651. getMeshes(): Array<Mesh>;
  77652. /**
  77653. * Explodes meshes giving a specific direction
  77654. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77655. */
  77656. explode(direction?: number): void;
  77657. }
  77658. }
  77659. declare module BABYLON {
  77660. /**
  77661. * Class used to help managing file picking and drag'n'drop
  77662. */
  77663. export class FilesInput {
  77664. /**
  77665. * List of files ready to be loaded
  77666. */
  77667. static get FilesToLoad(): {
  77668. [key: string]: File;
  77669. };
  77670. /**
  77671. * Callback called when a file is processed
  77672. */
  77673. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  77674. /**
  77675. * Function used when loading the scene file
  77676. */
  77677. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  77678. private _engine;
  77679. private _currentScene;
  77680. private _sceneLoadedCallback;
  77681. private _progressCallback;
  77682. private _additionalRenderLoopLogicCallback;
  77683. private _textureLoadingCallback;
  77684. private _startingProcessingFilesCallback;
  77685. private _onReloadCallback;
  77686. private _errorCallback;
  77687. private _elementToMonitor;
  77688. private _sceneFileToLoad;
  77689. private _filesToLoad;
  77690. /**
  77691. * Creates a new FilesInput
  77692. * @param engine defines the rendering engine
  77693. * @param scene defines the hosting scene
  77694. * @param sceneLoadedCallback callback called when scene is loaded
  77695. * @param progressCallback callback called to track progress
  77696. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77697. * @param textureLoadingCallback callback called when a texture is loading
  77698. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77699. * @param onReloadCallback callback called when a reload is requested
  77700. * @param errorCallback callback call if an error occurs
  77701. */
  77702. 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>);
  77703. private _dragEnterHandler;
  77704. private _dragOverHandler;
  77705. private _dropHandler;
  77706. /**
  77707. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77708. * @param elementToMonitor defines the DOM element to track
  77709. */
  77710. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77711. /** Gets the current list of files to load */
  77712. get filesToLoad(): File[];
  77713. /**
  77714. * Release all associated resources
  77715. */
  77716. dispose(): void;
  77717. private renderFunction;
  77718. private drag;
  77719. private drop;
  77720. private _traverseFolder;
  77721. private _processFiles;
  77722. /**
  77723. * Load files from a drop event
  77724. * @param event defines the drop event to use as source
  77725. */
  77726. loadFiles(event: any): void;
  77727. private _processReload;
  77728. /**
  77729. * Reload the current scene from the loaded files
  77730. */
  77731. reload(): void;
  77732. }
  77733. }
  77734. declare module BABYLON {
  77735. /**
  77736. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77737. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77738. */
  77739. export class SceneOptimization {
  77740. /**
  77741. * Defines the priority of this optimization (0 by default which means first in the list)
  77742. */
  77743. priority: number;
  77744. /**
  77745. * Gets a string describing the action executed by the current optimization
  77746. * @returns description string
  77747. */
  77748. getDescription(): string;
  77749. /**
  77750. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77751. * @param scene defines the current scene where to apply this optimization
  77752. * @param optimizer defines the current optimizer
  77753. * @returns true if everything that can be done was applied
  77754. */
  77755. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77756. /**
  77757. * Creates the SceneOptimization object
  77758. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77759. * @param desc defines the description associated with the optimization
  77760. */
  77761. constructor(
  77762. /**
  77763. * Defines the priority of this optimization (0 by default which means first in the list)
  77764. */
  77765. priority?: number);
  77766. }
  77767. /**
  77768. * Defines an optimization used to reduce the size of render target textures
  77769. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77770. */
  77771. export class TextureOptimization extends SceneOptimization {
  77772. /**
  77773. * Defines the priority of this optimization (0 by default which means first in the list)
  77774. */
  77775. priority: number;
  77776. /**
  77777. * 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
  77778. */
  77779. maximumSize: number;
  77780. /**
  77781. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77782. */
  77783. step: number;
  77784. /**
  77785. * Gets a string describing the action executed by the current optimization
  77786. * @returns description string
  77787. */
  77788. getDescription(): string;
  77789. /**
  77790. * Creates the TextureOptimization object
  77791. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77792. * @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
  77793. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77794. */
  77795. constructor(
  77796. /**
  77797. * Defines the priority of this optimization (0 by default which means first in the list)
  77798. */
  77799. priority?: number,
  77800. /**
  77801. * 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
  77802. */
  77803. maximumSize?: number,
  77804. /**
  77805. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77806. */
  77807. step?: number);
  77808. /**
  77809. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77810. * @param scene defines the current scene where to apply this optimization
  77811. * @param optimizer defines the current optimizer
  77812. * @returns true if everything that can be done was applied
  77813. */
  77814. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77815. }
  77816. /**
  77817. * Defines an optimization used to increase or decrease the rendering resolution
  77818. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77819. */
  77820. export class HardwareScalingOptimization extends SceneOptimization {
  77821. /**
  77822. * Defines the priority of this optimization (0 by default which means first in the list)
  77823. */
  77824. priority: number;
  77825. /**
  77826. * Defines the maximum scale to use (2 by default)
  77827. */
  77828. maximumScale: number;
  77829. /**
  77830. * Defines the step to use between two passes (0.5 by default)
  77831. */
  77832. step: number;
  77833. private _currentScale;
  77834. private _directionOffset;
  77835. /**
  77836. * Gets a string describing the action executed by the current optimization
  77837. * @return description string
  77838. */
  77839. getDescription(): string;
  77840. /**
  77841. * Creates the HardwareScalingOptimization object
  77842. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77843. * @param maximumScale defines the maximum scale to use (2 by default)
  77844. * @param step defines the step to use between two passes (0.5 by default)
  77845. */
  77846. constructor(
  77847. /**
  77848. * Defines the priority of this optimization (0 by default which means first in the list)
  77849. */
  77850. priority?: number,
  77851. /**
  77852. * Defines the maximum scale to use (2 by default)
  77853. */
  77854. maximumScale?: number,
  77855. /**
  77856. * Defines the step to use between two passes (0.5 by default)
  77857. */
  77858. step?: number);
  77859. /**
  77860. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77861. * @param scene defines the current scene where to apply this optimization
  77862. * @param optimizer defines the current optimizer
  77863. * @returns true if everything that can be done was applied
  77864. */
  77865. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77866. }
  77867. /**
  77868. * Defines an optimization used to remove shadows
  77869. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77870. */
  77871. export class ShadowsOptimization extends SceneOptimization {
  77872. /**
  77873. * Gets a string describing the action executed by the current optimization
  77874. * @return description string
  77875. */
  77876. getDescription(): string;
  77877. /**
  77878. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77879. * @param scene defines the current scene where to apply this optimization
  77880. * @param optimizer defines the current optimizer
  77881. * @returns true if everything that can be done was applied
  77882. */
  77883. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77884. }
  77885. /**
  77886. * Defines an optimization used to turn post-processes off
  77887. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77888. */
  77889. export class PostProcessesOptimization extends SceneOptimization {
  77890. /**
  77891. * Gets a string describing the action executed by the current optimization
  77892. * @return description string
  77893. */
  77894. getDescription(): string;
  77895. /**
  77896. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77897. * @param scene defines the current scene where to apply this optimization
  77898. * @param optimizer defines the current optimizer
  77899. * @returns true if everything that can be done was applied
  77900. */
  77901. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77902. }
  77903. /**
  77904. * Defines an optimization used to turn lens flares off
  77905. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77906. */
  77907. export class LensFlaresOptimization extends SceneOptimization {
  77908. /**
  77909. * Gets a string describing the action executed by the current optimization
  77910. * @return description string
  77911. */
  77912. getDescription(): string;
  77913. /**
  77914. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77915. * @param scene defines the current scene where to apply this optimization
  77916. * @param optimizer defines the current optimizer
  77917. * @returns true if everything that can be done was applied
  77918. */
  77919. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77920. }
  77921. /**
  77922. * Defines an optimization based on user defined callback.
  77923. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77924. */
  77925. export class CustomOptimization extends SceneOptimization {
  77926. /**
  77927. * Callback called to apply the custom optimization.
  77928. */
  77929. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  77930. /**
  77931. * Callback called to get custom description
  77932. */
  77933. onGetDescription: () => string;
  77934. /**
  77935. * Gets a string describing the action executed by the current optimization
  77936. * @returns description string
  77937. */
  77938. getDescription(): string;
  77939. /**
  77940. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77941. * @param scene defines the current scene where to apply this optimization
  77942. * @param optimizer defines the current optimizer
  77943. * @returns true if everything that can be done was applied
  77944. */
  77945. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77946. }
  77947. /**
  77948. * Defines an optimization used to turn particles off
  77949. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77950. */
  77951. export class ParticlesOptimization extends SceneOptimization {
  77952. /**
  77953. * Gets a string describing the action executed by the current optimization
  77954. * @return description string
  77955. */
  77956. getDescription(): string;
  77957. /**
  77958. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77959. * @param scene defines the current scene where to apply this optimization
  77960. * @param optimizer defines the current optimizer
  77961. * @returns true if everything that can be done was applied
  77962. */
  77963. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77964. }
  77965. /**
  77966. * Defines an optimization used to turn render targets off
  77967. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77968. */
  77969. export class RenderTargetsOptimization extends SceneOptimization {
  77970. /**
  77971. * Gets a string describing the action executed by the current optimization
  77972. * @return description string
  77973. */
  77974. getDescription(): string;
  77975. /**
  77976. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77977. * @param scene defines the current scene where to apply this optimization
  77978. * @param optimizer defines the current optimizer
  77979. * @returns true if everything that can be done was applied
  77980. */
  77981. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77982. }
  77983. /**
  77984. * Defines an optimization used to merge meshes with compatible materials
  77985. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77986. */
  77987. export class MergeMeshesOptimization extends SceneOptimization {
  77988. private static _UpdateSelectionTree;
  77989. /**
  77990. * Gets or sets a boolean which defines if optimization octree has to be updated
  77991. */
  77992. static get UpdateSelectionTree(): boolean;
  77993. /**
  77994. * Gets or sets a boolean which defines if optimization octree has to be updated
  77995. */
  77996. static set UpdateSelectionTree(value: boolean);
  77997. /**
  77998. * Gets a string describing the action executed by the current optimization
  77999. * @return description string
  78000. */
  78001. getDescription(): string;
  78002. private _canBeMerged;
  78003. /**
  78004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78005. * @param scene defines the current scene where to apply this optimization
  78006. * @param optimizer defines the current optimizer
  78007. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78008. * @returns true if everything that can be done was applied
  78009. */
  78010. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78011. }
  78012. /**
  78013. * Defines a list of options used by SceneOptimizer
  78014. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78015. */
  78016. export class SceneOptimizerOptions {
  78017. /**
  78018. * Defines the target frame rate to reach (60 by default)
  78019. */
  78020. targetFrameRate: number;
  78021. /**
  78022. * Defines the interval between two checkes (2000ms by default)
  78023. */
  78024. trackerDuration: number;
  78025. /**
  78026. * Gets the list of optimizations to apply
  78027. */
  78028. optimizations: SceneOptimization[];
  78029. /**
  78030. * Creates a new list of options used by SceneOptimizer
  78031. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78032. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78033. */
  78034. constructor(
  78035. /**
  78036. * Defines the target frame rate to reach (60 by default)
  78037. */
  78038. targetFrameRate?: number,
  78039. /**
  78040. * Defines the interval between two checkes (2000ms by default)
  78041. */
  78042. trackerDuration?: number);
  78043. /**
  78044. * Add a new optimization
  78045. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78046. * @returns the current SceneOptimizerOptions
  78047. */
  78048. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78049. /**
  78050. * Add a new custom optimization
  78051. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78052. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78053. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78054. * @returns the current SceneOptimizerOptions
  78055. */
  78056. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78057. /**
  78058. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78059. * @param targetFrameRate defines the target frame rate (60 by default)
  78060. * @returns a SceneOptimizerOptions object
  78061. */
  78062. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78063. /**
  78064. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78065. * @param targetFrameRate defines the target frame rate (60 by default)
  78066. * @returns a SceneOptimizerOptions object
  78067. */
  78068. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78069. /**
  78070. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78071. * @param targetFrameRate defines the target frame rate (60 by default)
  78072. * @returns a SceneOptimizerOptions object
  78073. */
  78074. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78075. }
  78076. /**
  78077. * Class used to run optimizations in order to reach a target frame rate
  78078. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78079. */
  78080. export class SceneOptimizer implements IDisposable {
  78081. private _isRunning;
  78082. private _options;
  78083. private _scene;
  78084. private _currentPriorityLevel;
  78085. private _targetFrameRate;
  78086. private _trackerDuration;
  78087. private _currentFrameRate;
  78088. private _sceneDisposeObserver;
  78089. private _improvementMode;
  78090. /**
  78091. * Defines an observable called when the optimizer reaches the target frame rate
  78092. */
  78093. onSuccessObservable: Observable<SceneOptimizer>;
  78094. /**
  78095. * Defines an observable called when the optimizer enables an optimization
  78096. */
  78097. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78098. /**
  78099. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78100. */
  78101. onFailureObservable: Observable<SceneOptimizer>;
  78102. /**
  78103. * Gets a boolean indicating if the optimizer is in improvement mode
  78104. */
  78105. get isInImprovementMode(): boolean;
  78106. /**
  78107. * Gets the current priority level (0 at start)
  78108. */
  78109. get currentPriorityLevel(): number;
  78110. /**
  78111. * Gets the current frame rate checked by the SceneOptimizer
  78112. */
  78113. get currentFrameRate(): number;
  78114. /**
  78115. * Gets or sets the current target frame rate (60 by default)
  78116. */
  78117. get targetFrameRate(): number;
  78118. /**
  78119. * Gets or sets the current target frame rate (60 by default)
  78120. */
  78121. set targetFrameRate(value: number);
  78122. /**
  78123. * Gets or sets the current interval between two checks (every 2000ms by default)
  78124. */
  78125. get trackerDuration(): number;
  78126. /**
  78127. * Gets or sets the current interval between two checks (every 2000ms by default)
  78128. */
  78129. set trackerDuration(value: number);
  78130. /**
  78131. * Gets the list of active optimizations
  78132. */
  78133. get optimizations(): SceneOptimization[];
  78134. /**
  78135. * Creates a new SceneOptimizer
  78136. * @param scene defines the scene to work on
  78137. * @param options defines the options to use with the SceneOptimizer
  78138. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78139. * @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)
  78140. */
  78141. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78142. /**
  78143. * Stops the current optimizer
  78144. */
  78145. stop(): void;
  78146. /**
  78147. * Reset the optimizer to initial step (current priority level = 0)
  78148. */
  78149. reset(): void;
  78150. /**
  78151. * Start the optimizer. By default it will try to reach a specific framerate
  78152. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78153. */
  78154. start(): void;
  78155. private _checkCurrentState;
  78156. /**
  78157. * Release all resources
  78158. */
  78159. dispose(): void;
  78160. /**
  78161. * Helper function to create a SceneOptimizer with one single line of code
  78162. * @param scene defines the scene to work on
  78163. * @param options defines the options to use with the SceneOptimizer
  78164. * @param onSuccess defines a callback to call on success
  78165. * @param onFailure defines a callback to call on failure
  78166. * @returns the new SceneOptimizer object
  78167. */
  78168. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78169. }
  78170. }
  78171. declare module BABYLON {
  78172. /**
  78173. * Class used to serialize a scene into a string
  78174. */
  78175. export class SceneSerializer {
  78176. /**
  78177. * Clear cache used by a previous serialization
  78178. */
  78179. static ClearCache(): void;
  78180. /**
  78181. * Serialize a scene into a JSON compatible object
  78182. * @param scene defines the scene to serialize
  78183. * @returns a JSON compatible object
  78184. */
  78185. static Serialize(scene: Scene): any;
  78186. /**
  78187. * Serialize a mesh into a JSON compatible object
  78188. * @param toSerialize defines the mesh to serialize
  78189. * @param withParents defines if parents must be serialized as well
  78190. * @param withChildren defines if children must be serialized as well
  78191. * @returns a JSON compatible object
  78192. */
  78193. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78194. }
  78195. }
  78196. declare module BABYLON {
  78197. /**
  78198. * This represents the different options available for the video capture.
  78199. */
  78200. export interface VideoRecorderOptions {
  78201. /** Defines the mime type of the video. */
  78202. mimeType: string;
  78203. /** Defines the FPS the video should be recorded at. */
  78204. fps: number;
  78205. /** Defines the chunk size for the recording data. */
  78206. recordChunckSize: number;
  78207. /** The audio tracks to attach to the recording. */
  78208. audioTracks?: MediaStreamTrack[];
  78209. }
  78210. /**
  78211. * This can help with recording videos from BabylonJS.
  78212. * This is based on the available WebRTC functionalities of the browser.
  78213. *
  78214. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78215. */
  78216. export class VideoRecorder {
  78217. private static readonly _defaultOptions;
  78218. /**
  78219. * Returns whether or not the VideoRecorder is available in your browser.
  78220. * @param engine Defines the Babylon Engine.
  78221. * @returns true if supported otherwise false.
  78222. */
  78223. static IsSupported(engine: Engine): boolean;
  78224. private readonly _options;
  78225. private _canvas;
  78226. private _mediaRecorder;
  78227. private _recordedChunks;
  78228. private _fileName;
  78229. private _resolve;
  78230. private _reject;
  78231. /**
  78232. * True when a recording is already in progress.
  78233. */
  78234. get isRecording(): boolean;
  78235. /**
  78236. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78237. * @param engine Defines the BabylonJS Engine you wish to record.
  78238. * @param options Defines options that can be used to customize the capture.
  78239. */
  78240. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78241. /**
  78242. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78243. */
  78244. stopRecording(): void;
  78245. /**
  78246. * Starts recording the canvas for a max duration specified in parameters.
  78247. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78248. * If null no automatic download will start and you can rely on the promise to get the data back.
  78249. * @param maxDuration Defines the maximum recording time in seconds.
  78250. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78251. * @return A promise callback at the end of the recording with the video data in Blob.
  78252. */
  78253. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78254. /**
  78255. * Releases internal resources used during the recording.
  78256. */
  78257. dispose(): void;
  78258. private _handleDataAvailable;
  78259. private _handleError;
  78260. private _handleStop;
  78261. }
  78262. }
  78263. declare module BABYLON {
  78264. /**
  78265. * Class containing a set of static utilities functions for screenshots
  78266. */
  78267. export class ScreenshotTools {
  78268. /**
  78269. * Captures a screenshot of the current rendering
  78270. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78271. * @param engine defines the rendering engine
  78272. * @param camera defines the source camera
  78273. * @param size This parameter can be set to a single number or to an object with the
  78274. * following (optional) properties: precision, width, height. If a single number is passed,
  78275. * it will be used for both width and height. If an object is passed, the screenshot size
  78276. * will be derived from the parameters. The precision property is a multiplier allowing
  78277. * rendering at a higher or lower resolution
  78278. * @param successCallback defines the callback receives a single parameter which contains the
  78279. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78280. * src parameter of an <img> to display it
  78281. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78282. * Check your browser for supported MIME types
  78283. */
  78284. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78285. /**
  78286. * Captures a screenshot of the current rendering
  78287. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78288. * @param engine defines the rendering engine
  78289. * @param camera defines the source camera
  78290. * @param size This parameter can be set to a single number or to an object with the
  78291. * following (optional) properties: precision, width, height. If a single number is passed,
  78292. * it will be used for both width and height. If an object is passed, the screenshot size
  78293. * will be derived from the parameters. The precision property is a multiplier allowing
  78294. * rendering at a higher or lower resolution
  78295. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78296. * Check your browser for supported MIME types
  78297. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78298. * to the src parameter of an <img> to display it
  78299. */
  78300. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78301. /**
  78302. * Generates an image screenshot from the specified camera.
  78303. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78304. * @param engine The engine to use for rendering
  78305. * @param camera The camera to use for rendering
  78306. * @param size This parameter can be set to a single number or to an object with the
  78307. * following (optional) properties: precision, width, height. If a single number is passed,
  78308. * it will be used for both width and height. If an object is passed, the screenshot size
  78309. * will be derived from the parameters. The precision property is a multiplier allowing
  78310. * rendering at a higher or lower resolution
  78311. * @param successCallback The callback receives a single parameter which contains the
  78312. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78313. * src parameter of an <img> to display it
  78314. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78315. * Check your browser for supported MIME types
  78316. * @param samples Texture samples (default: 1)
  78317. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78318. * @param fileName A name for for the downloaded file.
  78319. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78320. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78321. */
  78322. 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;
  78323. /**
  78324. * Generates an image screenshot from the specified camera.
  78325. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78326. * @param engine The engine to use for rendering
  78327. * @param camera The camera to use for rendering
  78328. * @param size This parameter can be set to a single number or to an object with the
  78329. * following (optional) properties: precision, width, height. If a single number is passed,
  78330. * it will be used for both width and height. If an object is passed, the screenshot size
  78331. * will be derived from the parameters. The precision property is a multiplier allowing
  78332. * rendering at a higher or lower resolution
  78333. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78334. * Check your browser for supported MIME types
  78335. * @param samples Texture samples (default: 1)
  78336. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78337. * @param fileName A name for for the downloaded file.
  78338. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78339. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78340. * to the src parameter of an <img> to display it
  78341. */
  78342. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78343. /**
  78344. * Gets height and width for screenshot size
  78345. * @private
  78346. */
  78347. private static _getScreenshotSize;
  78348. }
  78349. }
  78350. declare module BABYLON {
  78351. /**
  78352. * Interface for a data buffer
  78353. */
  78354. export interface IDataBuffer {
  78355. /**
  78356. * Reads bytes from the data buffer.
  78357. * @param byteOffset The byte offset to read
  78358. * @param byteLength The byte length to read
  78359. * @returns A promise that resolves when the bytes are read
  78360. */
  78361. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78362. /**
  78363. * The byte length of the buffer.
  78364. */
  78365. readonly byteLength: number;
  78366. }
  78367. /**
  78368. * Utility class for reading from a data buffer
  78369. */
  78370. export class DataReader {
  78371. /**
  78372. * The data buffer associated with this data reader.
  78373. */
  78374. readonly buffer: IDataBuffer;
  78375. /**
  78376. * The current byte offset from the beginning of the data buffer.
  78377. */
  78378. byteOffset: number;
  78379. private _dataView;
  78380. private _dataByteOffset;
  78381. /**
  78382. * Constructor
  78383. * @param buffer The buffer to read
  78384. */
  78385. constructor(buffer: IDataBuffer);
  78386. /**
  78387. * Loads the given byte length.
  78388. * @param byteLength The byte length to load
  78389. * @returns A promise that resolves when the load is complete
  78390. */
  78391. loadAsync(byteLength: number): Promise<void>;
  78392. /**
  78393. * Read a unsigned 32-bit integer from the currently loaded data range.
  78394. * @returns The 32-bit integer read
  78395. */
  78396. readUint32(): number;
  78397. /**
  78398. * Read a byte array from the currently loaded data range.
  78399. * @param byteLength The byte length to read
  78400. * @returns The byte array read
  78401. */
  78402. readUint8Array(byteLength: number): Uint8Array;
  78403. /**
  78404. * Read a string from the currently loaded data range.
  78405. * @param byteLength The byte length to read
  78406. * @returns The string read
  78407. */
  78408. readString(byteLength: number): string;
  78409. /**
  78410. * Skips the given byte length the currently loaded data range.
  78411. * @param byteLength The byte length to skip
  78412. */
  78413. skipBytes(byteLength: number): void;
  78414. }
  78415. }
  78416. declare module BABYLON {
  78417. /**
  78418. * Class for storing data to local storage if available or in-memory storage otherwise
  78419. */
  78420. export class DataStorage {
  78421. private static _Storage;
  78422. private static _GetStorage;
  78423. /**
  78424. * Reads a string from the data storage
  78425. * @param key The key to read
  78426. * @param defaultValue The value if the key doesn't exist
  78427. * @returns The string value
  78428. */
  78429. static ReadString(key: string, defaultValue: string): string;
  78430. /**
  78431. * Writes a string to the data storage
  78432. * @param key The key to write
  78433. * @param value The value to write
  78434. */
  78435. static WriteString(key: string, value: string): void;
  78436. /**
  78437. * Reads a boolean from the data storage
  78438. * @param key The key to read
  78439. * @param defaultValue The value if the key doesn't exist
  78440. * @returns The boolean value
  78441. */
  78442. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78443. /**
  78444. * Writes a boolean to the data storage
  78445. * @param key The key to write
  78446. * @param value The value to write
  78447. */
  78448. static WriteBoolean(key: string, value: boolean): void;
  78449. /**
  78450. * Reads a number from the data storage
  78451. * @param key The key to read
  78452. * @param defaultValue The value if the key doesn't exist
  78453. * @returns The number value
  78454. */
  78455. static ReadNumber(key: string, defaultValue: number): number;
  78456. /**
  78457. * Writes a number to the data storage
  78458. * @param key The key to write
  78459. * @param value The value to write
  78460. */
  78461. static WriteNumber(key: string, value: number): void;
  78462. }
  78463. }
  78464. declare module BABYLON {
  78465. /**
  78466. * Class used to record delta files between 2 scene states
  78467. */
  78468. export class SceneRecorder {
  78469. private _trackedScene;
  78470. private _savedJSON;
  78471. /**
  78472. * Track a given scene. This means the current scene state will be considered the original state
  78473. * @param scene defines the scene to track
  78474. */
  78475. track(scene: Scene): void;
  78476. /**
  78477. * Get the delta between current state and original state
  78478. * @returns a string containing the delta
  78479. */
  78480. getDelta(): any;
  78481. private _compareArray;
  78482. private _compareObjects;
  78483. private _compareCollections;
  78484. private static GetShadowGeneratorById;
  78485. /**
  78486. * Apply a given delta to a given scene
  78487. * @param deltaJSON defines the JSON containing the delta
  78488. * @param scene defines the scene to apply the delta to
  78489. */
  78490. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78491. private static _ApplyPropertiesToEntity;
  78492. private static _ApplyDeltaForEntity;
  78493. }
  78494. }
  78495. declare module BABYLON {
  78496. /**
  78497. * A 3D trajectory consisting of an order list of vectors describing a
  78498. * path of motion through 3D space.
  78499. */
  78500. export class Trajectory {
  78501. private _points;
  78502. private readonly _segmentLength;
  78503. /**
  78504. * Serialize to JSON.
  78505. * @returns serialized JSON string
  78506. */
  78507. serialize(): string;
  78508. /**
  78509. * Deserialize from JSON.
  78510. * @param json serialized JSON string
  78511. * @returns deserialized Trajectory
  78512. */
  78513. static Deserialize(json: string): Trajectory;
  78514. /**
  78515. * Create a new empty Trajectory.
  78516. * @param segmentLength radius of discretization for Trajectory points
  78517. */
  78518. constructor(segmentLength?: number);
  78519. /**
  78520. * Get the length of the Trajectory.
  78521. * @returns length of the Trajectory
  78522. */
  78523. getLength(): number;
  78524. /**
  78525. * Append a new point to the Trajectory.
  78526. * NOTE: This implementation has many allocations.
  78527. * @param point point to append to the Trajectory
  78528. */
  78529. add(point: DeepImmutable<Vector3>): void;
  78530. /**
  78531. * Create a new Trajectory with a segment length chosen to make it
  78532. * probable that the new Trajectory will have a specified number of
  78533. * segments. This operation is imprecise.
  78534. * @param targetResolution number of segments desired
  78535. * @returns new Trajectory with approximately the requested number of segments
  78536. */
  78537. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78538. /**
  78539. * Convert Trajectory segments into tokenized representation. This
  78540. * representation is an array of numbers where each nth number is the
  78541. * index of the token which is most similar to the nth segment of the
  78542. * Trajectory.
  78543. * @param tokens list of vectors which serve as discrete tokens
  78544. * @returns list of indices of most similar token per segment
  78545. */
  78546. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78547. private static _forwardDir;
  78548. private static _inverseFromVec;
  78549. private static _upDir;
  78550. private static _fromToVec;
  78551. private static _lookMatrix;
  78552. /**
  78553. * Transform the rotation (i.e., direction) of a segment to isolate
  78554. * the relative transformation represented by the segment. This operation
  78555. * may or may not succeed due to singularities in the equations that define
  78556. * motion relativity in this context.
  78557. * @param priorVec the origin of the prior segment
  78558. * @param fromVec the origin of the current segment
  78559. * @param toVec the destination of the current segment
  78560. * @param result reference to output variable
  78561. * @returns whether or not transformation was successful
  78562. */
  78563. private static _transformSegmentDirToRef;
  78564. private static _bestMatch;
  78565. private static _score;
  78566. private static _bestScore;
  78567. /**
  78568. * Determine which token vector is most similar to the
  78569. * segment vector.
  78570. * @param segment segment vector
  78571. * @param tokens token vector list
  78572. * @returns index of the most similar token to the segment
  78573. */
  78574. private static _tokenizeSegment;
  78575. }
  78576. /**
  78577. * Class representing a set of known, named trajectories to which Trajectories can be
  78578. * added and using which Trajectories can be recognized.
  78579. */
  78580. export class TrajectoryClassifier {
  78581. private _maximumAllowableMatchCost;
  78582. private _vector3Alphabet;
  78583. private _levenshteinAlphabet;
  78584. private _nameToDescribedTrajectory;
  78585. /**
  78586. * Serialize to JSON.
  78587. * @returns JSON serialization
  78588. */
  78589. serialize(): string;
  78590. /**
  78591. * Deserialize from JSON.
  78592. * @param json JSON serialization
  78593. * @returns deserialized TrajectorySet
  78594. */
  78595. static Deserialize(json: string): TrajectoryClassifier;
  78596. /**
  78597. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78598. * VERY naive, need to be generating these things from known
  78599. * sets. Better version later, probably eliminating this one.
  78600. * @returns auto-generated TrajectorySet
  78601. */
  78602. static Generate(): TrajectoryClassifier;
  78603. private constructor();
  78604. /**
  78605. * Add a new Trajectory to the set with a given name.
  78606. * @param trajectory new Trajectory to be added
  78607. * @param classification name to which to add the Trajectory
  78608. */
  78609. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78610. /**
  78611. * Remove a known named trajectory and all Trajectories associated with it.
  78612. * @param classification name to remove
  78613. * @returns whether anything was removed
  78614. */
  78615. deleteClassification(classification: string): boolean;
  78616. /**
  78617. * Attempt to recognize a Trajectory from among all the classifications
  78618. * already known to the classifier.
  78619. * @param trajectory Trajectory to be recognized
  78620. * @returns classification of Trajectory if recognized, null otherwise
  78621. */
  78622. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78623. }
  78624. }
  78625. declare module BABYLON {
  78626. /**
  78627. * An interface for all Hit test features
  78628. */
  78629. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78630. /**
  78631. * Triggered when new babylon (transformed) hit test results are available
  78632. */
  78633. onHitTestResultObservable: Observable<T[]>;
  78634. }
  78635. /**
  78636. * Options used for hit testing
  78637. */
  78638. export interface IWebXRLegacyHitTestOptions {
  78639. /**
  78640. * Only test when user interacted with the scene. Default - hit test every frame
  78641. */
  78642. testOnPointerDownOnly?: boolean;
  78643. /**
  78644. * The node to use to transform the local results to world coordinates
  78645. */
  78646. worldParentNode?: TransformNode;
  78647. }
  78648. /**
  78649. * Interface defining the babylon result of raycasting/hit-test
  78650. */
  78651. export interface IWebXRLegacyHitResult {
  78652. /**
  78653. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78654. */
  78655. transformationMatrix: Matrix;
  78656. /**
  78657. * The native hit test result
  78658. */
  78659. xrHitResult: XRHitResult | XRHitTestResult;
  78660. }
  78661. /**
  78662. * The currently-working hit-test module.
  78663. * Hit test (or Ray-casting) is used to interact with the real world.
  78664. * For further information read here - https://github.com/immersive-web/hit-test
  78665. */
  78666. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78667. /**
  78668. * options to use when constructing this feature
  78669. */
  78670. readonly options: IWebXRLegacyHitTestOptions;
  78671. private _direction;
  78672. private _mat;
  78673. private _onSelectEnabled;
  78674. private _origin;
  78675. /**
  78676. * The module's name
  78677. */
  78678. static readonly Name: string;
  78679. /**
  78680. * The (Babylon) version of this module.
  78681. * This is an integer representing the implementation version.
  78682. * This number does not correspond to the WebXR specs version
  78683. */
  78684. static readonly Version: number;
  78685. /**
  78686. * Populated with the last native XR Hit Results
  78687. */
  78688. lastNativeXRHitResults: XRHitResult[];
  78689. /**
  78690. * Triggered when new babylon (transformed) hit test results are available
  78691. */
  78692. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78693. /**
  78694. * Creates a new instance of the (legacy version) hit test feature
  78695. * @param _xrSessionManager an instance of WebXRSessionManager
  78696. * @param options options to use when constructing this feature
  78697. */
  78698. constructor(_xrSessionManager: WebXRSessionManager,
  78699. /**
  78700. * options to use when constructing this feature
  78701. */
  78702. options?: IWebXRLegacyHitTestOptions);
  78703. /**
  78704. * execute a hit test with an XR Ray
  78705. *
  78706. * @param xrSession a native xrSession that will execute this hit test
  78707. * @param xrRay the ray (position and direction) to use for ray-casting
  78708. * @param referenceSpace native XR reference space to use for the hit-test
  78709. * @param filter filter function that will filter the results
  78710. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78711. */
  78712. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78713. /**
  78714. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78715. * @param event the (select) event to use to select with
  78716. * @param referenceSpace the reference space to use for this hit test
  78717. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78718. */
  78719. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78720. /**
  78721. * attach this feature
  78722. * Will usually be called by the features manager
  78723. *
  78724. * @returns true if successful.
  78725. */
  78726. attach(): boolean;
  78727. /**
  78728. * detach this feature.
  78729. * Will usually be called by the features manager
  78730. *
  78731. * @returns true if successful.
  78732. */
  78733. detach(): boolean;
  78734. /**
  78735. * Dispose this feature and all of the resources attached
  78736. */
  78737. dispose(): void;
  78738. protected _onXRFrame(frame: XRFrame): void;
  78739. private _onHitTestResults;
  78740. private _onSelect;
  78741. }
  78742. }
  78743. declare module BABYLON {
  78744. /**
  78745. * Options used for hit testing (version 2)
  78746. */
  78747. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78748. /**
  78749. * Do not create a permanent hit test. Will usually be used when only
  78750. * transient inputs are needed.
  78751. */
  78752. disablePermanentHitTest?: boolean;
  78753. /**
  78754. * Enable transient (for example touch-based) hit test inspections
  78755. */
  78756. enableTransientHitTest?: boolean;
  78757. /**
  78758. * Offset ray for the permanent hit test
  78759. */
  78760. offsetRay?: Vector3;
  78761. /**
  78762. * Offset ray for the transient hit test
  78763. */
  78764. transientOffsetRay?: Vector3;
  78765. /**
  78766. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78767. */
  78768. useReferenceSpace?: boolean;
  78769. /**
  78770. * Override the default entity type(s) of the hit-test result
  78771. */
  78772. entityTypes?: XRHitTestTrackableType[];
  78773. }
  78774. /**
  78775. * Interface defining the babylon result of hit-test
  78776. */
  78777. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78778. /**
  78779. * The input source that generated this hit test (if transient)
  78780. */
  78781. inputSource?: XRInputSource;
  78782. /**
  78783. * Is this a transient hit test
  78784. */
  78785. isTransient?: boolean;
  78786. /**
  78787. * Position of the hit test result
  78788. */
  78789. position: Vector3;
  78790. /**
  78791. * Rotation of the hit test result
  78792. */
  78793. rotationQuaternion: Quaternion;
  78794. /**
  78795. * The native hit test result
  78796. */
  78797. xrHitResult: XRHitTestResult;
  78798. }
  78799. /**
  78800. * The currently-working hit-test module.
  78801. * Hit test (or Ray-casting) is used to interact with the real world.
  78802. * For further information read here - https://github.com/immersive-web/hit-test
  78803. *
  78804. * Tested on chrome (mobile) 80.
  78805. */
  78806. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78807. /**
  78808. * options to use when constructing this feature
  78809. */
  78810. readonly options: IWebXRHitTestOptions;
  78811. private _tmpMat;
  78812. private _tmpPos;
  78813. private _tmpQuat;
  78814. private _transientXrHitTestSource;
  78815. private _xrHitTestSource;
  78816. private initHitTestSource;
  78817. /**
  78818. * The module's name
  78819. */
  78820. static readonly Name: string;
  78821. /**
  78822. * The (Babylon) version of this module.
  78823. * This is an integer representing the implementation version.
  78824. * This number does not correspond to the WebXR specs version
  78825. */
  78826. static readonly Version: number;
  78827. /**
  78828. * When set to true, each hit test will have its own position/rotation objects
  78829. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78830. * the developers will clone them or copy them as they see fit.
  78831. */
  78832. autoCloneTransformation: boolean;
  78833. /**
  78834. * Triggered when new babylon (transformed) hit test results are available
  78835. * Note - this will be called when results come back from the device. It can be an empty array!!
  78836. */
  78837. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78838. /**
  78839. * Use this to temporarily pause hit test checks.
  78840. */
  78841. paused: boolean;
  78842. /**
  78843. * Creates a new instance of the hit test feature
  78844. * @param _xrSessionManager an instance of WebXRSessionManager
  78845. * @param options options to use when constructing this feature
  78846. */
  78847. constructor(_xrSessionManager: WebXRSessionManager,
  78848. /**
  78849. * options to use when constructing this feature
  78850. */
  78851. options?: IWebXRHitTestOptions);
  78852. /**
  78853. * attach this feature
  78854. * Will usually be called by the features manager
  78855. *
  78856. * @returns true if successful.
  78857. */
  78858. attach(): boolean;
  78859. /**
  78860. * detach this feature.
  78861. * Will usually be called by the features manager
  78862. *
  78863. * @returns true if successful.
  78864. */
  78865. detach(): boolean;
  78866. /**
  78867. * Dispose this feature and all of the resources attached
  78868. */
  78869. dispose(): void;
  78870. protected _onXRFrame(frame: XRFrame): void;
  78871. private _processWebXRHitTestResult;
  78872. }
  78873. }
  78874. declare module BABYLON {
  78875. /**
  78876. * Configuration options of the anchor system
  78877. */
  78878. export interface IWebXRAnchorSystemOptions {
  78879. /**
  78880. * a node that will be used to convert local to world coordinates
  78881. */
  78882. worldParentNode?: TransformNode;
  78883. /**
  78884. * If set to true a reference of the created anchors will be kept until the next session starts
  78885. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78886. */
  78887. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78888. }
  78889. /**
  78890. * A babylon container for an XR Anchor
  78891. */
  78892. export interface IWebXRAnchor {
  78893. /**
  78894. * A babylon-assigned ID for this anchor
  78895. */
  78896. id: number;
  78897. /**
  78898. * Transformation matrix to apply to an object attached to this anchor
  78899. */
  78900. transformationMatrix: Matrix;
  78901. /**
  78902. * The native anchor object
  78903. */
  78904. xrAnchor: XRAnchor;
  78905. /**
  78906. * if defined, this object will be constantly updated by the anchor's position and rotation
  78907. */
  78908. attachedNode?: TransformNode;
  78909. /**
  78910. * Remove this anchor from the scene
  78911. */
  78912. remove(): void;
  78913. }
  78914. /**
  78915. * An implementation of the anchor system for WebXR.
  78916. * For further information see https://github.com/immersive-web/anchors/
  78917. */
  78918. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  78919. private _options;
  78920. private _lastFrameDetected;
  78921. private _trackedAnchors;
  78922. private _referenceSpaceForFrameAnchors;
  78923. private _futureAnchors;
  78924. /**
  78925. * The module's name
  78926. */
  78927. static readonly Name: string;
  78928. /**
  78929. * The (Babylon) version of this module.
  78930. * This is an integer representing the implementation version.
  78931. * This number does not correspond to the WebXR specs version
  78932. */
  78933. static readonly Version: number;
  78934. /**
  78935. * Observers registered here will be executed when a new anchor was added to the session
  78936. */
  78937. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  78938. /**
  78939. * Observers registered here will be executed when an anchor was removed from the session
  78940. */
  78941. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  78942. /**
  78943. * Observers registered here will be executed when an existing anchor updates
  78944. * This can execute N times every frame
  78945. */
  78946. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  78947. /**
  78948. * Set the reference space to use for anchor creation, when not using a hit test.
  78949. * Will default to the session's reference space if not defined
  78950. */
  78951. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  78952. /**
  78953. * constructs a new anchor system
  78954. * @param _xrSessionManager an instance of WebXRSessionManager
  78955. * @param _options configuration object for this feature
  78956. */
  78957. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  78958. private _tmpVector;
  78959. private _tmpQuaternion;
  78960. private _populateTmpTransformation;
  78961. /**
  78962. * Create a new anchor point using a hit test result at a specific point in the scene
  78963. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78964. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78965. *
  78966. * @param hitTestResult The hit test result to use for this anchor creation
  78967. * @param position an optional position offset for this anchor
  78968. * @param rotationQuaternion an optional rotation offset for this anchor
  78969. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  78970. */
  78971. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  78972. /**
  78973. * Add a new anchor at a specific position and rotation
  78974. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  78975. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  78976. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  78977. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  78978. *
  78979. * @param position the position in which to add an anchor
  78980. * @param rotationQuaternion an optional rotation for the anchor transformation
  78981. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  78982. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  78983. */
  78984. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  78985. /**
  78986. * Get the list of anchors currently being tracked by the system
  78987. */
  78988. get anchors(): IWebXRAnchor[];
  78989. /**
  78990. * detach this feature.
  78991. * Will usually be called by the features manager
  78992. *
  78993. * @returns true if successful.
  78994. */
  78995. detach(): boolean;
  78996. /**
  78997. * Dispose this feature and all of the resources attached
  78998. */
  78999. dispose(): void;
  79000. protected _onXRFrame(frame: XRFrame): void;
  79001. /**
  79002. * avoiding using Array.find for global support.
  79003. * @param xrAnchor the plane to find in the array
  79004. */
  79005. private _findIndexInAnchorArray;
  79006. private _updateAnchorWithXRFrame;
  79007. private _createAnchorAtTransformation;
  79008. }
  79009. }
  79010. declare module BABYLON {
  79011. /**
  79012. * Options used in the plane detector module
  79013. */
  79014. export interface IWebXRPlaneDetectorOptions {
  79015. /**
  79016. * The node to use to transform the local results to world coordinates
  79017. */
  79018. worldParentNode?: TransformNode;
  79019. /**
  79020. * If set to true a reference of the created planes will be kept until the next session starts
  79021. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79022. */
  79023. doNotRemovePlanesOnSessionEnded?: boolean;
  79024. /**
  79025. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79026. */
  79027. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79028. }
  79029. /**
  79030. * A babylon interface for a WebXR plane.
  79031. * A Plane is actually a polygon, built from N points in space
  79032. *
  79033. * Supported in chrome 79, not supported in canary 81 ATM
  79034. */
  79035. export interface IWebXRPlane {
  79036. /**
  79037. * a babylon-assigned ID for this polygon
  79038. */
  79039. id: number;
  79040. /**
  79041. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79042. */
  79043. polygonDefinition: Array<Vector3>;
  79044. /**
  79045. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79046. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79047. */
  79048. transformationMatrix: Matrix;
  79049. /**
  79050. * the native xr-plane object
  79051. */
  79052. xrPlane: XRPlane;
  79053. }
  79054. /**
  79055. * The plane detector is used to detect planes in the real world when in AR
  79056. * For more information see https://github.com/immersive-web/real-world-geometry/
  79057. */
  79058. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79059. private _options;
  79060. private _detectedPlanes;
  79061. private _enabled;
  79062. private _lastFrameDetected;
  79063. /**
  79064. * The module's name
  79065. */
  79066. static readonly Name: string;
  79067. /**
  79068. * The (Babylon) version of this module.
  79069. * This is an integer representing the implementation version.
  79070. * This number does not correspond to the WebXR specs version
  79071. */
  79072. static readonly Version: number;
  79073. /**
  79074. * Observers registered here will be executed when a new plane was added to the session
  79075. */
  79076. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79077. /**
  79078. * Observers registered here will be executed when a plane is no longer detected in the session
  79079. */
  79080. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79081. /**
  79082. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79083. * This can execute N times every frame
  79084. */
  79085. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79086. /**
  79087. * construct a new Plane Detector
  79088. * @param _xrSessionManager an instance of xr Session manager
  79089. * @param _options configuration to use when constructing this feature
  79090. */
  79091. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79092. /**
  79093. * detach this feature.
  79094. * Will usually be called by the features manager
  79095. *
  79096. * @returns true if successful.
  79097. */
  79098. detach(): boolean;
  79099. /**
  79100. * Dispose this feature and all of the resources attached
  79101. */
  79102. dispose(): void;
  79103. /**
  79104. * Check if the needed objects are defined.
  79105. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79106. */
  79107. isCompatible(): boolean;
  79108. protected _onXRFrame(frame: XRFrame): void;
  79109. private _init;
  79110. private _updatePlaneWithXRPlane;
  79111. /**
  79112. * avoiding using Array.find for global support.
  79113. * @param xrPlane the plane to find in the array
  79114. */
  79115. private _findIndexInPlaneArray;
  79116. }
  79117. }
  79118. declare module BABYLON {
  79119. /**
  79120. * Options interface for the background remover plugin
  79121. */
  79122. export interface IWebXRBackgroundRemoverOptions {
  79123. /**
  79124. * Further background meshes to disable when entering AR
  79125. */
  79126. backgroundMeshes?: AbstractMesh[];
  79127. /**
  79128. * flags to configure the removal of the environment helper.
  79129. * If not set, the entire background will be removed. If set, flags should be set as well.
  79130. */
  79131. environmentHelperRemovalFlags?: {
  79132. /**
  79133. * Should the skybox be removed (default false)
  79134. */
  79135. skyBox?: boolean;
  79136. /**
  79137. * Should the ground be removed (default false)
  79138. */
  79139. ground?: boolean;
  79140. };
  79141. /**
  79142. * don't disable the environment helper
  79143. */
  79144. ignoreEnvironmentHelper?: boolean;
  79145. }
  79146. /**
  79147. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79148. */
  79149. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79150. /**
  79151. * read-only options to be used in this module
  79152. */
  79153. readonly options: IWebXRBackgroundRemoverOptions;
  79154. /**
  79155. * The module's name
  79156. */
  79157. static readonly Name: string;
  79158. /**
  79159. * The (Babylon) version of this module.
  79160. * This is an integer representing the implementation version.
  79161. * This number does not correspond to the WebXR specs version
  79162. */
  79163. static readonly Version: number;
  79164. /**
  79165. * registered observers will be triggered when the background state changes
  79166. */
  79167. onBackgroundStateChangedObservable: Observable<boolean>;
  79168. /**
  79169. * constructs a new background remover module
  79170. * @param _xrSessionManager the session manager for this module
  79171. * @param options read-only options to be used in this module
  79172. */
  79173. constructor(_xrSessionManager: WebXRSessionManager,
  79174. /**
  79175. * read-only options to be used in this module
  79176. */
  79177. options?: IWebXRBackgroundRemoverOptions);
  79178. /**
  79179. * attach this feature
  79180. * Will usually be called by the features manager
  79181. *
  79182. * @returns true if successful.
  79183. */
  79184. attach(): boolean;
  79185. /**
  79186. * detach this feature.
  79187. * Will usually be called by the features manager
  79188. *
  79189. * @returns true if successful.
  79190. */
  79191. detach(): boolean;
  79192. /**
  79193. * Dispose this feature and all of the resources attached
  79194. */
  79195. dispose(): void;
  79196. protected _onXRFrame(_xrFrame: XRFrame): void;
  79197. private _setBackgroundState;
  79198. }
  79199. }
  79200. declare module BABYLON {
  79201. /**
  79202. * Options for the controller physics feature
  79203. */
  79204. export class IWebXRControllerPhysicsOptions {
  79205. /**
  79206. * Should the headset get its own impostor
  79207. */
  79208. enableHeadsetImpostor?: boolean;
  79209. /**
  79210. * Optional parameters for the headset impostor
  79211. */
  79212. headsetImpostorParams?: {
  79213. /**
  79214. * The type of impostor to create. Default is sphere
  79215. */
  79216. impostorType: number;
  79217. /**
  79218. * the size of the impostor. Defaults to 10cm
  79219. */
  79220. impostorSize?: number | {
  79221. width: number;
  79222. height: number;
  79223. depth: number;
  79224. };
  79225. /**
  79226. * Friction definitions
  79227. */
  79228. friction?: number;
  79229. /**
  79230. * Restitution
  79231. */
  79232. restitution?: number;
  79233. };
  79234. /**
  79235. * The physics properties of the future impostors
  79236. */
  79237. physicsProperties?: {
  79238. /**
  79239. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79240. * Note that this requires a physics engine that supports mesh impostors!
  79241. */
  79242. useControllerMesh?: boolean;
  79243. /**
  79244. * The type of impostor to create. Default is sphere
  79245. */
  79246. impostorType?: number;
  79247. /**
  79248. * the size of the impostor. Defaults to 10cm
  79249. */
  79250. impostorSize?: number | {
  79251. width: number;
  79252. height: number;
  79253. depth: number;
  79254. };
  79255. /**
  79256. * Friction definitions
  79257. */
  79258. friction?: number;
  79259. /**
  79260. * Restitution
  79261. */
  79262. restitution?: number;
  79263. };
  79264. /**
  79265. * the xr input to use with this pointer selection
  79266. */
  79267. xrInput: WebXRInput;
  79268. }
  79269. /**
  79270. * Add physics impostor to your webxr controllers,
  79271. * including naive calculation of their linear and angular velocity
  79272. */
  79273. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79274. private readonly _options;
  79275. private _attachController;
  79276. private _controllers;
  79277. private _debugMode;
  79278. private _delta;
  79279. private _headsetImpostor?;
  79280. private _headsetMesh?;
  79281. private _lastTimestamp;
  79282. private _tmpQuaternion;
  79283. private _tmpVector;
  79284. /**
  79285. * The module's name
  79286. */
  79287. static readonly Name: string;
  79288. /**
  79289. * The (Babylon) version of this module.
  79290. * This is an integer representing the implementation version.
  79291. * This number does not correspond to the webxr specs version
  79292. */
  79293. static readonly Version: number;
  79294. /**
  79295. * Construct a new Controller Physics Feature
  79296. * @param _xrSessionManager the corresponding xr session manager
  79297. * @param _options options to create this feature with
  79298. */
  79299. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79300. /**
  79301. * @hidden
  79302. * enable debugging - will show console outputs and the impostor mesh
  79303. */
  79304. _enablePhysicsDebug(): void;
  79305. /**
  79306. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79307. * @param xrController the controller to add
  79308. */
  79309. addController(xrController: WebXRInputSource): void;
  79310. /**
  79311. * attach this feature
  79312. * Will usually be called by the features manager
  79313. *
  79314. * @returns true if successful.
  79315. */
  79316. attach(): boolean;
  79317. /**
  79318. * detach this feature.
  79319. * Will usually be called by the features manager
  79320. *
  79321. * @returns true if successful.
  79322. */
  79323. detach(): boolean;
  79324. /**
  79325. * Get the headset impostor, if enabled
  79326. * @returns the impostor
  79327. */
  79328. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79329. /**
  79330. * Get the physics impostor of a specific controller.
  79331. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79332. * @param controller the controller or the controller id of which to get the impostor
  79333. * @returns the impostor or null
  79334. */
  79335. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79336. /**
  79337. * Update the physics properties provided in the constructor
  79338. * @param newProperties the new properties object
  79339. */
  79340. setPhysicsProperties(newProperties: {
  79341. impostorType?: number;
  79342. impostorSize?: number | {
  79343. width: number;
  79344. height: number;
  79345. depth: number;
  79346. };
  79347. friction?: number;
  79348. restitution?: number;
  79349. }): void;
  79350. protected _onXRFrame(_xrFrame: any): void;
  79351. private _detachController;
  79352. }
  79353. }
  79354. declare module BABYLON {
  79355. /**
  79356. * A babylon interface for a "WebXR" feature point.
  79357. * Represents the position and confidence value of a given feature point.
  79358. */
  79359. export interface IWebXRFeaturePoint {
  79360. /**
  79361. * Represents the position of the feature point in world space.
  79362. */
  79363. position: Vector3;
  79364. /**
  79365. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79366. */
  79367. confidenceValue: number;
  79368. }
  79369. /**
  79370. * The feature point system is used to detect feature points from real world geometry.
  79371. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79372. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79373. */
  79374. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79375. private _enabled;
  79376. private _featurePointCloud;
  79377. /**
  79378. * The module's name
  79379. */
  79380. static readonly Name: string;
  79381. /**
  79382. * The (Babylon) version of this module.
  79383. * This is an integer representing the implementation version.
  79384. * This number does not correspond to the WebXR specs version
  79385. */
  79386. static readonly Version: number;
  79387. /**
  79388. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79389. * Will notify the observers about which feature points have been added.
  79390. */
  79391. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79392. /**
  79393. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79394. * Will notify the observers about which feature points have been updated.
  79395. */
  79396. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79397. /**
  79398. * The current feature point cloud maintained across frames.
  79399. */
  79400. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79401. /**
  79402. * construct the feature point system
  79403. * @param _xrSessionManager an instance of xr Session manager
  79404. */
  79405. constructor(_xrSessionManager: WebXRSessionManager);
  79406. /**
  79407. * Detach this feature.
  79408. * Will usually be called by the features manager
  79409. *
  79410. * @returns true if successful.
  79411. */
  79412. detach(): boolean;
  79413. /**
  79414. * Dispose this feature and all of the resources attached
  79415. */
  79416. dispose(): void;
  79417. /**
  79418. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79419. */
  79420. protected _onXRFrame(frame: XRFrame): void;
  79421. /**
  79422. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79423. */
  79424. private _init;
  79425. }
  79426. }
  79427. declare module BABYLON {
  79428. /**
  79429. * Configuration interface for the hand tracking feature
  79430. */
  79431. export interface IWebXRHandTrackingOptions {
  79432. /**
  79433. * The xrInput that will be used as source for new hands
  79434. */
  79435. xrInput: WebXRInput;
  79436. /**
  79437. * Configuration object for the joint meshes
  79438. */
  79439. jointMeshes?: {
  79440. /**
  79441. * Should the meshes created be invisible (defaults to false)
  79442. */
  79443. invisible?: boolean;
  79444. /**
  79445. * A source mesh to be used to create instances. Defaults to a sphere.
  79446. * This mesh will be the source for all other (25) meshes.
  79447. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79448. */
  79449. sourceMesh?: Mesh;
  79450. /**
  79451. * This function will be called after a mesh was created for a specific joint.
  79452. * Using this function you can either manipulate the instance or return a new mesh.
  79453. * When returning a new mesh the instance created before will be disposed
  79454. */
  79455. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  79456. /**
  79457. * Should the source mesh stay visible. Defaults to false
  79458. */
  79459. keepOriginalVisible?: boolean;
  79460. /**
  79461. * Scale factor for all instances (defaults to 2)
  79462. */
  79463. scaleFactor?: number;
  79464. /**
  79465. * Should each instance have its own physics impostor
  79466. */
  79467. enablePhysics?: boolean;
  79468. /**
  79469. * If enabled, override default physics properties
  79470. */
  79471. physicsProps?: {
  79472. friction?: number;
  79473. restitution?: number;
  79474. impostorType?: number;
  79475. };
  79476. /**
  79477. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  79478. */
  79479. disableDefaultHandMesh?: boolean;
  79480. /**
  79481. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  79482. */
  79483. handMeshes?: {
  79484. right: AbstractMesh;
  79485. left: AbstractMesh;
  79486. };
  79487. /**
  79488. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  79489. */
  79490. rigMapping?: {
  79491. right: string[];
  79492. left: string[];
  79493. };
  79494. };
  79495. }
  79496. /**
  79497. * Parts of the hands divided to writs and finger names
  79498. */
  79499. export const enum HandPart {
  79500. /**
  79501. * HandPart - Wrist
  79502. */
  79503. WRIST = "wrist",
  79504. /**
  79505. * HandPart - The THumb
  79506. */
  79507. THUMB = "thumb",
  79508. /**
  79509. * HandPart - Index finger
  79510. */
  79511. INDEX = "index",
  79512. /**
  79513. * HandPart - Middle finger
  79514. */
  79515. MIDDLE = "middle",
  79516. /**
  79517. * HandPart - Ring finger
  79518. */
  79519. RING = "ring",
  79520. /**
  79521. * HandPart - Little finger
  79522. */
  79523. LITTLE = "little"
  79524. }
  79525. /**
  79526. * Representing a single hand (with its corresponding native XRHand object)
  79527. */
  79528. export class WebXRHand implements IDisposable {
  79529. /** the controller to which the hand correlates */
  79530. readonly xrController: WebXRInputSource;
  79531. /** the meshes to be used to track the hand joints */
  79532. readonly trackedMeshes: AbstractMesh[];
  79533. private _handMesh?;
  79534. private _rigMapping?;
  79535. private _scene;
  79536. private _defaultHandMesh;
  79537. private _transformNodeMapping;
  79538. /**
  79539. * Hand-parts definition (key is HandPart)
  79540. */
  79541. handPartsDefinition: {
  79542. [key: string]: number[];
  79543. };
  79544. /**
  79545. * Observers will be triggered when the mesh for this hand was initialized.
  79546. */
  79547. onHandMeshReadyObservable: Observable<WebXRHand>;
  79548. /**
  79549. * Populate the HandPartsDefinition object.
  79550. * This is called as a side effect since certain browsers don't have XRHand defined.
  79551. */
  79552. private generateHandPartsDefinition;
  79553. /**
  79554. * Construct a new hand object
  79555. * @param xrController the controller to which the hand correlates
  79556. * @param trackedMeshes the meshes to be used to track the hand joints
  79557. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  79558. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  79559. * @param disableDefaultHandMesh should the default mesh creation be disabled
  79560. */
  79561. constructor(
  79562. /** the controller to which the hand correlates */
  79563. xrController: WebXRInputSource,
  79564. /** the meshes to be used to track the hand joints */
  79565. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  79566. /**
  79567. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  79568. */
  79569. get handMesh(): AbstractMesh | undefined;
  79570. /**
  79571. * Update this hand from the latest xr frame
  79572. * @param xrFrame xrFrame to update from
  79573. * @param referenceSpace The current viewer reference space
  79574. * @param scaleFactor optional scale factor for the meshes
  79575. */
  79576. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79577. /**
  79578. * Get meshes of part of the hand
  79579. * @param part the part of hand to get
  79580. * @returns An array of meshes that correlate to the hand part requested
  79581. */
  79582. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79583. /**
  79584. * Dispose this Hand object
  79585. */
  79586. dispose(): void;
  79587. private _generateDefaultHandMesh;
  79588. }
  79589. /**
  79590. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79591. */
  79592. export class WebXRHandTracking extends WebXRAbstractFeature {
  79593. /**
  79594. * options to use when constructing this feature
  79595. */
  79596. readonly options: IWebXRHandTrackingOptions;
  79597. private static _idCounter;
  79598. /**
  79599. * The module's name
  79600. */
  79601. static readonly Name: string;
  79602. /**
  79603. * The (Babylon) version of this module.
  79604. * This is an integer representing the implementation version.
  79605. * This number does not correspond to the WebXR specs version
  79606. */
  79607. static readonly Version: number;
  79608. /**
  79609. * This observable will notify registered observers when a new hand object was added and initialized
  79610. */
  79611. onHandAddedObservable: Observable<WebXRHand>;
  79612. /**
  79613. * This observable will notify its observers right before the hand object is disposed
  79614. */
  79615. onHandRemovedObservable: Observable<WebXRHand>;
  79616. private _hands;
  79617. /**
  79618. * Creates a new instance of the hit test feature
  79619. * @param _xrSessionManager an instance of WebXRSessionManager
  79620. * @param options options to use when constructing this feature
  79621. */
  79622. constructor(_xrSessionManager: WebXRSessionManager,
  79623. /**
  79624. * options to use when constructing this feature
  79625. */
  79626. options: IWebXRHandTrackingOptions);
  79627. /**
  79628. * Check if the needed objects are defined.
  79629. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79630. */
  79631. isCompatible(): boolean;
  79632. /**
  79633. * attach this feature
  79634. * Will usually be called by the features manager
  79635. *
  79636. * @returns true if successful.
  79637. */
  79638. attach(): boolean;
  79639. /**
  79640. * detach this feature.
  79641. * Will usually be called by the features manager
  79642. *
  79643. * @returns true if successful.
  79644. */
  79645. detach(): boolean;
  79646. /**
  79647. * Dispose this feature and all of the resources attached
  79648. */
  79649. dispose(): void;
  79650. /**
  79651. * Get the hand object according to the controller id
  79652. * @param controllerId the controller id to which we want to get the hand
  79653. * @returns null if not found or the WebXRHand object if found
  79654. */
  79655. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79656. /**
  79657. * Get a hand object according to the requested handedness
  79658. * @param handedness the handedness to request
  79659. * @returns null if not found or the WebXRHand object if found
  79660. */
  79661. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79662. protected _onXRFrame(_xrFrame: XRFrame): void;
  79663. private _attachHand;
  79664. private _detachHand;
  79665. }
  79666. }
  79667. declare module BABYLON {
  79668. /**
  79669. * Options used in the mesh detector module
  79670. */
  79671. export interface IWebXRMeshDetectorOptions {
  79672. /**
  79673. * The node to use to transform the local results to world coordinates
  79674. */
  79675. worldParentNode?: TransformNode;
  79676. /**
  79677. * If set to true a reference of the created meshes will be kept until the next session starts
  79678. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  79679. */
  79680. doNotRemoveMeshesOnSessionEnded?: boolean;
  79681. /**
  79682. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79683. */
  79684. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79685. /**
  79686. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  79687. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  79688. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  79689. */
  79690. convertCoordinateSystems?: boolean;
  79691. }
  79692. /**
  79693. * A babylon interface for a XR mesh's vertex data.
  79694. *
  79695. * Currently not supported by WebXR, available only with BabylonNative
  79696. */
  79697. export interface IWebXRVertexData {
  79698. /**
  79699. * A babylon-assigned ID for this mesh
  79700. */
  79701. id: number;
  79702. /**
  79703. * Data required for constructing a mesh in Babylon.js.
  79704. */
  79705. xrMesh: XRMesh;
  79706. /**
  79707. * The node to use to transform the local results to world coordinates.
  79708. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  79709. */
  79710. worldParentNode?: TransformNode;
  79711. /**
  79712. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  79713. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79714. */
  79715. positions?: Float32Array;
  79716. /**
  79717. * An array of indices in babylon space. right/left hand system is taken into account.
  79718. * Indices will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79719. */
  79720. indices?: Uint32Array;
  79721. /**
  79722. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  79723. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  79724. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  79725. */
  79726. normals?: Float32Array;
  79727. /**
  79728. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  79729. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  79730. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79731. */
  79732. transformationMatrix?: Matrix;
  79733. }
  79734. /**
  79735. * The mesh detector is used to detect meshes in the real world when in AR
  79736. */
  79737. export class WebXRMeshDetector extends WebXRAbstractFeature {
  79738. private _options;
  79739. private _detectedMeshes;
  79740. /**
  79741. * The module's name
  79742. */
  79743. static readonly Name: string;
  79744. /**
  79745. * The (Babylon) version of this module.
  79746. * This is an integer representing the implementation version.
  79747. * This number does not correspond to the WebXR specs version
  79748. */
  79749. static readonly Version: number;
  79750. /**
  79751. * Observers registered here will be executed when a new mesh was added to the session
  79752. */
  79753. onMeshAddedObservable: Observable<IWebXRVertexData>;
  79754. /**
  79755. * Observers registered here will be executed when a mesh is no longer detected in the session
  79756. */
  79757. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  79758. /**
  79759. * Observers registered here will be executed when an existing mesh updates
  79760. */
  79761. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  79762. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  79763. detach(): boolean;
  79764. dispose(): void;
  79765. protected _onXRFrame(frame: XRFrame): void;
  79766. private _init;
  79767. private _updateVertexDataWithXRMesh;
  79768. }
  79769. }
  79770. declare module BABYLON {
  79771. /**
  79772. * The motion controller class for all microsoft mixed reality controllers
  79773. */
  79774. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79775. protected readonly _mapping: {
  79776. defaultButton: {
  79777. valueNodeName: string;
  79778. unpressedNodeName: string;
  79779. pressedNodeName: string;
  79780. };
  79781. defaultAxis: {
  79782. valueNodeName: string;
  79783. minNodeName: string;
  79784. maxNodeName: string;
  79785. };
  79786. buttons: {
  79787. "xr-standard-trigger": {
  79788. rootNodeName: string;
  79789. componentProperty: string;
  79790. states: string[];
  79791. };
  79792. "xr-standard-squeeze": {
  79793. rootNodeName: string;
  79794. componentProperty: string;
  79795. states: string[];
  79796. };
  79797. "xr-standard-touchpad": {
  79798. rootNodeName: string;
  79799. labelAnchorNodeName: string;
  79800. touchPointNodeName: string;
  79801. };
  79802. "xr-standard-thumbstick": {
  79803. rootNodeName: string;
  79804. componentProperty: string;
  79805. states: string[];
  79806. };
  79807. };
  79808. axes: {
  79809. "xr-standard-touchpad": {
  79810. "x-axis": {
  79811. rootNodeName: string;
  79812. };
  79813. "y-axis": {
  79814. rootNodeName: string;
  79815. };
  79816. };
  79817. "xr-standard-thumbstick": {
  79818. "x-axis": {
  79819. rootNodeName: string;
  79820. };
  79821. "y-axis": {
  79822. rootNodeName: string;
  79823. };
  79824. };
  79825. };
  79826. };
  79827. /**
  79828. * The base url used to load the left and right controller models
  79829. */
  79830. static MODEL_BASE_URL: string;
  79831. /**
  79832. * The name of the left controller model file
  79833. */
  79834. static MODEL_LEFT_FILENAME: string;
  79835. /**
  79836. * The name of the right controller model file
  79837. */
  79838. static MODEL_RIGHT_FILENAME: string;
  79839. profileId: string;
  79840. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79841. protected _getFilenameAndPath(): {
  79842. filename: string;
  79843. path: string;
  79844. };
  79845. protected _getModelLoadingConstraints(): boolean;
  79846. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79847. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79848. protected _updateModel(): void;
  79849. }
  79850. }
  79851. declare module BABYLON {
  79852. /**
  79853. * The motion controller class for oculus touch (quest, rift).
  79854. * This class supports legacy mapping as well the standard xr mapping
  79855. */
  79856. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  79857. private _forceLegacyControllers;
  79858. private _modelRootNode;
  79859. /**
  79860. * The base url used to load the left and right controller models
  79861. */
  79862. static MODEL_BASE_URL: string;
  79863. /**
  79864. * The name of the left controller model file
  79865. */
  79866. static MODEL_LEFT_FILENAME: string;
  79867. /**
  79868. * The name of the right controller model file
  79869. */
  79870. static MODEL_RIGHT_FILENAME: string;
  79871. /**
  79872. * Base Url for the Quest controller model.
  79873. */
  79874. static QUEST_MODEL_BASE_URL: string;
  79875. profileId: string;
  79876. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  79877. protected _getFilenameAndPath(): {
  79878. filename: string;
  79879. path: string;
  79880. };
  79881. protected _getModelLoadingConstraints(): boolean;
  79882. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79883. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79884. protected _updateModel(): void;
  79885. /**
  79886. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  79887. * between the touch and touch 2.
  79888. */
  79889. private _isQuest;
  79890. }
  79891. }
  79892. declare module BABYLON {
  79893. /**
  79894. * The motion controller class for the standard HTC-Vive controllers
  79895. */
  79896. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  79897. private _modelRootNode;
  79898. /**
  79899. * The base url used to load the left and right controller models
  79900. */
  79901. static MODEL_BASE_URL: string;
  79902. /**
  79903. * File name for the controller model.
  79904. */
  79905. static MODEL_FILENAME: string;
  79906. profileId: string;
  79907. /**
  79908. * Create a new Vive motion controller object
  79909. * @param scene the scene to use to create this controller
  79910. * @param gamepadObject the corresponding gamepad object
  79911. * @param handedness the handedness of the controller
  79912. */
  79913. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79914. protected _getFilenameAndPath(): {
  79915. filename: string;
  79916. path: string;
  79917. };
  79918. protected _getModelLoadingConstraints(): boolean;
  79919. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79920. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79921. protected _updateModel(): void;
  79922. }
  79923. }
  79924. declare module BABYLON {
  79925. /**
  79926. * A cursor which tracks a point on a path
  79927. */
  79928. export class PathCursor {
  79929. private path;
  79930. /**
  79931. * Stores path cursor callbacks for when an onchange event is triggered
  79932. */
  79933. private _onchange;
  79934. /**
  79935. * The value of the path cursor
  79936. */
  79937. value: number;
  79938. /**
  79939. * The animation array of the path cursor
  79940. */
  79941. animations: Animation[];
  79942. /**
  79943. * Initializes the path cursor
  79944. * @param path The path to track
  79945. */
  79946. constructor(path: Path2);
  79947. /**
  79948. * Gets the cursor point on the path
  79949. * @returns A point on the path cursor at the cursor location
  79950. */
  79951. getPoint(): Vector3;
  79952. /**
  79953. * Moves the cursor ahead by the step amount
  79954. * @param step The amount to move the cursor forward
  79955. * @returns This path cursor
  79956. */
  79957. moveAhead(step?: number): PathCursor;
  79958. /**
  79959. * Moves the cursor behind by the step amount
  79960. * @param step The amount to move the cursor back
  79961. * @returns This path cursor
  79962. */
  79963. moveBack(step?: number): PathCursor;
  79964. /**
  79965. * Moves the cursor by the step amount
  79966. * If the step amount is greater than one, an exception is thrown
  79967. * @param step The amount to move the cursor
  79968. * @returns This path cursor
  79969. */
  79970. move(step: number): PathCursor;
  79971. /**
  79972. * Ensures that the value is limited between zero and one
  79973. * @returns This path cursor
  79974. */
  79975. private ensureLimits;
  79976. /**
  79977. * Runs onchange callbacks on change (used by the animation engine)
  79978. * @returns This path cursor
  79979. */
  79980. private raiseOnChange;
  79981. /**
  79982. * Executes a function on change
  79983. * @param f A path cursor onchange callback
  79984. * @returns This path cursor
  79985. */
  79986. onchange(f: (cursor: PathCursor) => void): PathCursor;
  79987. }
  79988. }
  79989. declare module BABYLON {
  79990. /** @hidden */
  79991. export var blurPixelShader: {
  79992. name: string;
  79993. shader: string;
  79994. };
  79995. }
  79996. declare module BABYLON {
  79997. /** @hidden */
  79998. export var pointCloudVertexDeclaration: {
  79999. name: string;
  80000. shader: string;
  80001. };
  80002. }
  80003. // Mixins
  80004. interface Window {
  80005. mozIndexedDB: IDBFactory;
  80006. webkitIndexedDB: IDBFactory;
  80007. msIndexedDB: IDBFactory;
  80008. webkitURL: typeof URL;
  80009. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80010. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80011. WebGLRenderingContext: WebGLRenderingContext;
  80012. MSGesture: MSGesture;
  80013. CANNON: any;
  80014. AudioContext: AudioContext;
  80015. webkitAudioContext: AudioContext;
  80016. PointerEvent: any;
  80017. Math: Math;
  80018. Uint8Array: Uint8ArrayConstructor;
  80019. Float32Array: Float32ArrayConstructor;
  80020. mozURL: typeof URL;
  80021. msURL: typeof URL;
  80022. VRFrameData: any; // WebVR, from specs 1.1
  80023. DracoDecoderModule: any;
  80024. setImmediate(handler: (...args: any[]) => void): number;
  80025. }
  80026. interface HTMLCanvasElement {
  80027. requestPointerLock(): void;
  80028. msRequestPointerLock?(): void;
  80029. mozRequestPointerLock?(): void;
  80030. webkitRequestPointerLock?(): void;
  80031. /** Track wether a record is in progress */
  80032. isRecording: boolean;
  80033. /** Capture Stream method defined by some browsers */
  80034. captureStream(fps?: number): MediaStream;
  80035. }
  80036. interface CanvasRenderingContext2D {
  80037. msImageSmoothingEnabled: boolean;
  80038. }
  80039. interface MouseEvent {
  80040. mozMovementX: number;
  80041. mozMovementY: number;
  80042. webkitMovementX: number;
  80043. webkitMovementY: number;
  80044. msMovementX: number;
  80045. msMovementY: number;
  80046. }
  80047. interface Navigator {
  80048. mozGetVRDevices: (any: any) => any;
  80049. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80050. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80051. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80052. webkitGetGamepads(): Gamepad[];
  80053. msGetGamepads(): Gamepad[];
  80054. webkitGamepads(): Gamepad[];
  80055. }
  80056. interface HTMLVideoElement {
  80057. mozSrcObject: any;
  80058. }
  80059. interface Math {
  80060. fround(x: number): number;
  80061. imul(a: number, b: number): number;
  80062. log2(x: number): number;
  80063. }
  80064. interface WebGLRenderingContext {
  80065. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80066. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80067. vertexAttribDivisor(index: number, divisor: number): void;
  80068. createVertexArray(): any;
  80069. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80070. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80071. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80072. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80073. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80074. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80075. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80076. // Queries
  80077. createQuery(): WebGLQuery;
  80078. deleteQuery(query: WebGLQuery): void;
  80079. beginQuery(target: number, query: WebGLQuery): void;
  80080. endQuery(target: number): void;
  80081. getQueryParameter(query: WebGLQuery, pname: number): any;
  80082. getQuery(target: number, pname: number): any;
  80083. MAX_SAMPLES: number;
  80084. RGBA8: number;
  80085. READ_FRAMEBUFFER: number;
  80086. DRAW_FRAMEBUFFER: number;
  80087. UNIFORM_BUFFER: number;
  80088. HALF_FLOAT_OES: number;
  80089. RGBA16F: number;
  80090. RGBA32F: number;
  80091. R32F: number;
  80092. RG32F: number;
  80093. RGB32F: number;
  80094. R16F: number;
  80095. RG16F: number;
  80096. RGB16F: number;
  80097. RED: number;
  80098. RG: number;
  80099. R8: number;
  80100. RG8: number;
  80101. UNSIGNED_INT_24_8: number;
  80102. DEPTH24_STENCIL8: number;
  80103. MIN: number;
  80104. MAX: number;
  80105. /* Multiple Render Targets */
  80106. drawBuffers(buffers: number[]): void;
  80107. readBuffer(src: number): void;
  80108. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80109. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80110. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  80111. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  80112. // Occlusion Query
  80113. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  80114. ANY_SAMPLES_PASSED: number;
  80115. QUERY_RESULT_AVAILABLE: number;
  80116. QUERY_RESULT: number;
  80117. }
  80118. interface WebGLProgram {
  80119. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  80120. }
  80121. interface EXT_disjoint_timer_query {
  80122. QUERY_COUNTER_BITS_EXT: number;
  80123. TIME_ELAPSED_EXT: number;
  80124. TIMESTAMP_EXT: number;
  80125. GPU_DISJOINT_EXT: number;
  80126. QUERY_RESULT_EXT: number;
  80127. QUERY_RESULT_AVAILABLE_EXT: number;
  80128. queryCounterEXT(query: WebGLQuery, target: number): void;
  80129. createQueryEXT(): WebGLQuery;
  80130. beginQueryEXT(target: number, query: WebGLQuery): void;
  80131. endQueryEXT(target: number): void;
  80132. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  80133. deleteQueryEXT(query: WebGLQuery): void;
  80134. }
  80135. interface WebGLUniformLocation {
  80136. _currentState: any;
  80137. }
  80138. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  80139. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  80140. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  80141. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  80142. interface WebGLRenderingContext {
  80143. readonly RASTERIZER_DISCARD: number;
  80144. readonly DEPTH_COMPONENT24: number;
  80145. readonly TEXTURE_3D: number;
  80146. readonly TEXTURE_2D_ARRAY: number;
  80147. readonly TEXTURE_COMPARE_FUNC: number;
  80148. readonly TEXTURE_COMPARE_MODE: number;
  80149. readonly COMPARE_REF_TO_TEXTURE: number;
  80150. readonly TEXTURE_WRAP_R: number;
  80151. readonly HALF_FLOAT: number;
  80152. readonly RGB8: number;
  80153. readonly RED_INTEGER: number;
  80154. readonly RG_INTEGER: number;
  80155. readonly RGB_INTEGER: number;
  80156. readonly RGBA_INTEGER: number;
  80157. readonly R8_SNORM: number;
  80158. readonly RG8_SNORM: number;
  80159. readonly RGB8_SNORM: number;
  80160. readonly RGBA8_SNORM: number;
  80161. readonly R8I: number;
  80162. readonly RG8I: number;
  80163. readonly RGB8I: number;
  80164. readonly RGBA8I: number;
  80165. readonly R8UI: number;
  80166. readonly RG8UI: number;
  80167. readonly RGB8UI: number;
  80168. readonly RGBA8UI: number;
  80169. readonly R16I: number;
  80170. readonly RG16I: number;
  80171. readonly RGB16I: number;
  80172. readonly RGBA16I: number;
  80173. readonly R16UI: number;
  80174. readonly RG16UI: number;
  80175. readonly RGB16UI: number;
  80176. readonly RGBA16UI: number;
  80177. readonly R32I: number;
  80178. readonly RG32I: number;
  80179. readonly RGB32I: number;
  80180. readonly RGBA32I: number;
  80181. readonly R32UI: number;
  80182. readonly RG32UI: number;
  80183. readonly RGB32UI: number;
  80184. readonly RGBA32UI: number;
  80185. readonly RGB10_A2UI: number;
  80186. readonly R11F_G11F_B10F: number;
  80187. readonly RGB9_E5: number;
  80188. readonly RGB10_A2: number;
  80189. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  80190. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  80191. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  80192. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80193. readonly DEPTH_COMPONENT32F: number;
  80194. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  80195. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  80196. 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;
  80197. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  80198. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  80199. readonly TRANSFORM_FEEDBACK: number;
  80200. readonly INTERLEAVED_ATTRIBS: number;
  80201. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  80202. createTransformFeedback(): WebGLTransformFeedback;
  80203. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  80204. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  80205. beginTransformFeedback(primitiveMode: number): void;
  80206. endTransformFeedback(): void;
  80207. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  80208. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80209. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80210. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80211. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  80212. }
  80213. interface ImageBitmap {
  80214. readonly width: number;
  80215. readonly height: number;
  80216. close(): void;
  80217. }
  80218. interface WebGLQuery extends WebGLObject {
  80219. }
  80220. declare var WebGLQuery: {
  80221. prototype: WebGLQuery;
  80222. new(): WebGLQuery;
  80223. };
  80224. interface WebGLSampler extends WebGLObject {
  80225. }
  80226. declare var WebGLSampler: {
  80227. prototype: WebGLSampler;
  80228. new(): WebGLSampler;
  80229. };
  80230. interface WebGLSync extends WebGLObject {
  80231. }
  80232. declare var WebGLSync: {
  80233. prototype: WebGLSync;
  80234. new(): WebGLSync;
  80235. };
  80236. interface WebGLTransformFeedback extends WebGLObject {
  80237. }
  80238. declare var WebGLTransformFeedback: {
  80239. prototype: WebGLTransformFeedback;
  80240. new(): WebGLTransformFeedback;
  80241. };
  80242. interface WebGLVertexArrayObject extends WebGLObject {
  80243. }
  80244. declare var WebGLVertexArrayObject: {
  80245. prototype: WebGLVertexArrayObject;
  80246. new(): WebGLVertexArrayObject;
  80247. };
  80248. interface Navigator {
  80249. readonly gpu: GPU | undefined;
  80250. }
  80251. interface GPUColorDict {
  80252. a: number;
  80253. b: number;
  80254. g: number;
  80255. r: number;
  80256. }
  80257. type GPUColor = [number, number, number, number] | GPUColorDict;
  80258. interface GPUOrigin2DDict {
  80259. x?: number;
  80260. y?: number;
  80261. }
  80262. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  80263. interface GPUOrigin3DDict {
  80264. x?: number;
  80265. y?: number;
  80266. z?: number;
  80267. }
  80268. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  80269. interface GPUExtent3DDict {
  80270. width: number;
  80271. height: number;
  80272. depth: number;
  80273. }
  80274. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  80275. type GPUBindingResource =
  80276. | GPUSampler
  80277. | GPUTextureView
  80278. | GPUBufferBinding;
  80279. type GPUExtensionName =
  80280. | "texture-compression-bc"
  80281. | "timestamp-query"
  80282. | "pipeline-statistics-query"
  80283. | "depth-clamping"
  80284. | "depth24unorm-stencil8"
  80285. | "depth32float-stencil8";
  80286. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  80287. type GPUBindingType =
  80288. | "uniform-buffer"
  80289. | "storage-buffer"
  80290. | "readonly-storage-buffer"
  80291. | "sampler"
  80292. | "comparison-sampler"
  80293. | "sampled-texture"
  80294. | "readonly-storage-texture"
  80295. | "writeonly-storage-texture";
  80296. type GPUBlendFactor =
  80297. | "zero"
  80298. | "one"
  80299. | "src-color"
  80300. | "one-minus-src-color"
  80301. | "src-alpha"
  80302. | "one-minus-src-alpha"
  80303. | "dst-color"
  80304. | "one-minus-dst-color"
  80305. | "dst-alpha"
  80306. | "one-minus-dst-alpha"
  80307. | "src-alpha-saturated"
  80308. | "blend-color"
  80309. | "one-minus-blend-color";
  80310. type GPUBlendOperation =
  80311. | "add"
  80312. | "subtract"
  80313. | "reverse-subtract"
  80314. | "min"
  80315. | "max";
  80316. type GPUCompareFunction =
  80317. | "never"
  80318. | "less"
  80319. | "equal"
  80320. | "less-equal"
  80321. | "greater"
  80322. | "not-equal"
  80323. | "greater-equal"
  80324. | "always";
  80325. type GPUCullMode = "none" | "front" | "back";
  80326. type GPUFilterMode = "nearest" | "linear";
  80327. type GPUFrontFace = "ccw" | "cw";
  80328. type GPUIndexFormat = "uint16" | "uint32";
  80329. type GPUInputStepMode = "vertex" | "instance";
  80330. type GPULoadOp = "load";
  80331. type GPUPrimitiveTopology =
  80332. | "point-list"
  80333. | "line-list"
  80334. | "line-strip"
  80335. | "triangle-list"
  80336. | "triangle-strip";
  80337. type GPUStencilOperation =
  80338. | "keep"
  80339. | "zero"
  80340. | "replace"
  80341. | "invert"
  80342. | "increment-clamp"
  80343. | "decrement-clamp"
  80344. | "increment-wrap"
  80345. | "decrement-wrap";
  80346. type GPUStoreOp = "store" | "clear";
  80347. type GPUTextureDimension = "1d" | "2d" | "3d";
  80348. type GPUTextureFormat =
  80349. | "r8unorm"
  80350. | "r8snorm"
  80351. | "r8uint"
  80352. | "r8sint"
  80353. | "r16uint"
  80354. | "r16sint"
  80355. | "r16float"
  80356. | "rg8unorm"
  80357. | "rg8snorm"
  80358. | "rg8uint"
  80359. | "rg8sint"
  80360. | "r32uint"
  80361. | "r32sint"
  80362. | "r32float"
  80363. | "rg16uint"
  80364. | "rg16sint"
  80365. | "rg16float"
  80366. | "rgba8unorm"
  80367. | "rgba8unorm-srgb"
  80368. | "rgba8snorm"
  80369. | "rgba8uint"
  80370. | "rgba8sint"
  80371. | "bgra8unorm"
  80372. | "bgra8unorm-srgb"
  80373. | "rgb9e5ufloat"
  80374. | "rgb10a2unorm"
  80375. | "rg11b10ufloat"
  80376. | "rg32uint"
  80377. | "rg32sint"
  80378. | "rg32float"
  80379. | "rgba16uint"
  80380. | "rgba16sint"
  80381. | "rgba16float"
  80382. | "rgba32uint"
  80383. | "rgba32sint"
  80384. | "rgba32float"
  80385. | "stencil8"
  80386. | "depth16unorm"
  80387. | "depth24plus"
  80388. | "depth24plus-stencil8"
  80389. | "depth32float"
  80390. | "bc1-rgba-unorm"
  80391. | "bc1-rgba-unorm-srgb"
  80392. | "bc2-rgba-unorm"
  80393. | "bc2-rgba-unorm-srgb"
  80394. | "bc3-rgba-unorm"
  80395. | "bc3-rgba-unorm-srgb"
  80396. | "bc4-r-unorm"
  80397. | "bc4-r-snorm"
  80398. | "bc5-rg-unorm"
  80399. | "bc5-rg-snorm"
  80400. | "bc6h-rgb-ufloat"
  80401. | "bc6h-rgb-float"
  80402. | "bc7-rgba-unorm"
  80403. | "bc7-rgba-unorm-srgb"
  80404. | "depth24unorm-stencil8"
  80405. | "depth32float-stencil8";
  80406. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  80407. type GPUTextureViewDimension =
  80408. | "1d"
  80409. | "2d"
  80410. | "2d-array"
  80411. | "cube"
  80412. | "cube-array"
  80413. | "3d";
  80414. type GPUVertexFormat =
  80415. | "uchar2"
  80416. | "uchar4"
  80417. | "char2"
  80418. | "char4"
  80419. | "uchar2norm"
  80420. | "uchar4norm"
  80421. | "char2norm"
  80422. | "char4norm"
  80423. | "ushort2"
  80424. | "ushort4"
  80425. | "short2"
  80426. | "short4"
  80427. | "ushort2norm"
  80428. | "ushort4norm"
  80429. | "short2norm"
  80430. | "short4norm"
  80431. | "half2"
  80432. | "half4"
  80433. | "float"
  80434. | "float2"
  80435. | "float3"
  80436. | "float4"
  80437. | "uint"
  80438. | "uint2"
  80439. | "uint3"
  80440. | "uint4"
  80441. | "int"
  80442. | "int2"
  80443. | "int3"
  80444. | "int4";
  80445. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  80446. type GPUBufferUsageFlags = number;
  80447. type GPUColorWriteFlags = number;
  80448. type GPUShaderStageFlags = number;
  80449. type GPUTextureUsageFlags = number;
  80450. type GPUMapModeFlags = number;
  80451. interface GPUBindGroupEntry {
  80452. binding: number;
  80453. resource: GPUBindingResource;
  80454. }
  80455. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  80456. layout: GPUBindGroupLayout;
  80457. entries: Iterable<GPUBindGroupEntry>;
  80458. }
  80459. interface GPUBindGroupLayoutEntry {
  80460. binding: number;
  80461. visibility: GPUShaderStageFlags;
  80462. type: GPUBindingType;
  80463. hasDynamicOffset?: boolean;
  80464. minBufferBindingSize?: number;
  80465. viewDimension?: GPUTextureViewDimension;
  80466. textureComponentType?: GPUTextureComponentType;
  80467. storageTextureFormat?: GPUTextureFormat;
  80468. }
  80469. interface GPUBindGroupLayoutDescriptor
  80470. extends GPUObjectDescriptorBase {
  80471. entries: Iterable<GPUBindGroupLayoutEntry>;
  80472. }
  80473. interface GPUBlendDescriptor {
  80474. dstFactor?: GPUBlendFactor;
  80475. operation?: GPUBlendOperation;
  80476. srcFactor?: GPUBlendFactor;
  80477. }
  80478. interface GPUColorStateDescriptor {
  80479. format: GPUTextureFormat;
  80480. alphaBlend?: GPUBlendDescriptor;
  80481. colorBlend?: GPUBlendDescriptor;
  80482. writeMask?: GPUColorWriteFlags;
  80483. }
  80484. interface GPUBufferBinding {
  80485. buffer: GPUBuffer;
  80486. offset?: number;
  80487. size?: number;
  80488. }
  80489. interface GPUTextureDataLayout {
  80490. offset?: number;
  80491. bytesPerRow: number;
  80492. rowsPerImage?: number;
  80493. }
  80494. interface GPUBufferCopyView extends GPUTextureDataLayout {
  80495. buffer: GPUBuffer;
  80496. }
  80497. interface GPUTextureCopyView {
  80498. texture: GPUTexture;
  80499. mipLevel?: number;
  80500. origin?: GPUOrigin3D;
  80501. }
  80502. interface GPUImageBitmapCopyView {
  80503. imageBitmap: ImageBitmap;
  80504. origin?: GPUOrigin2D;
  80505. }
  80506. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  80507. size: number;
  80508. usage: GPUBufferUsageFlags;
  80509. mappedAtCreation?: boolean;
  80510. }
  80511. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  80512. label?: string;
  80513. measureExecutionTime?: boolean;
  80514. }
  80515. interface GPUComputePipelineDescriptor
  80516. extends GPUPipelineDescriptorBase {
  80517. computeStage: GPUProgrammableStageDescriptor;
  80518. }
  80519. interface GPUDepthStencilStateDescriptor {
  80520. format: GPUTextureFormat;
  80521. depthWriteEnabled?: boolean;
  80522. depthCompare?: GPUCompareFunction;
  80523. stencilFront?: GPUStencilStateFaceDescriptor;
  80524. stencilBack?: GPUStencilStateFaceDescriptor;
  80525. stencilReadMask?: number;
  80526. stencilWriteMask?: number;
  80527. }
  80528. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  80529. extensions?: Iterable<GPUExtensionName>;
  80530. limits?: GPULimits;
  80531. }
  80532. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  80533. initialValue?: number;
  80534. label?: string;
  80535. signalQueue?: GPUQueue;
  80536. }
  80537. interface GPUVertexAttributeDescriptor {
  80538. format: GPUVertexFormat;
  80539. offset: number;
  80540. shaderLocation: number;
  80541. }
  80542. interface GPUVertexBufferLayoutDescriptor {
  80543. arrayStride: number;
  80544. stepMode?: GPUInputStepMode;
  80545. attributes: Iterable<GPUVertexAttributeDescriptor>;
  80546. }
  80547. interface GPUVertexStateDescriptor {
  80548. indexFormat?: GPUIndexFormat;
  80549. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  80550. }
  80551. interface GPULimits {
  80552. maxBindGroups?: number;
  80553. maxDynamicUniformBuffersPerPipelineLayout?: number;
  80554. maxDynamicStorageBuffersPerPipelineLayout?: number;
  80555. maxSampledTexturesPerShaderStage?: number;
  80556. maxSamplersPerShaderStage?: number;
  80557. maxStorageBuffersPerShaderStage?: number;
  80558. maxStorageTexturesPerShaderStage?: number;
  80559. maxUniformBuffersPerShaderStage?: number;
  80560. maxUniformBufferBindingSize?: number;
  80561. }
  80562. interface GPUPipelineDescriptorBase {
  80563. label?: string;
  80564. layout?: GPUPipelineLayout;
  80565. }
  80566. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  80567. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  80568. }
  80569. interface GPUProgrammableStageDescriptor {
  80570. module: GPUShaderModule;
  80571. entryPoint: string;
  80572. }
  80573. interface GPURasterizationStateDescriptor {
  80574. frontFace?: GPUFrontFace;
  80575. cullMode?: GPUCullMode;
  80576. clampDepth?: boolean;
  80577. depthBias?: number;
  80578. depthBiasSlopeScale?: number;
  80579. depthBiasClamp?: number;
  80580. }
  80581. interface GPURenderPassColorAttachmentDescriptor {
  80582. attachment: GPUTextureView;
  80583. resolveTarget?: GPUTextureView;
  80584. loadValue: GPULoadOp | GPUColor;
  80585. storeOp?: GPUStoreOp;
  80586. }
  80587. interface GPURenderPassDepthStencilAttachmentDescriptor {
  80588. attachment: GPUTextureView;
  80589. depthLoadValue: GPULoadOp | number;
  80590. depthStoreOp: GPUStoreOp;
  80591. depthReadOnly?: boolean;
  80592. stencilLoadValue: GPULoadOp | number;
  80593. stencilStoreOp: GPUStoreOp;
  80594. stencilReadOnly?: boolean;
  80595. }
  80596. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  80597. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  80598. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  80599. }
  80600. interface GPURenderPipelineDescriptor
  80601. extends GPUPipelineDescriptorBase {
  80602. vertexStage: GPUProgrammableStageDescriptor;
  80603. fragmentStage?: GPUProgrammableStageDescriptor;
  80604. primitiveTopology: GPUPrimitiveTopology;
  80605. rasterizationState?: GPURasterizationStateDescriptor;
  80606. colorStates: Iterable<GPUColorStateDescriptor>;
  80607. depthStencilState?: GPUDepthStencilStateDescriptor;
  80608. vertexState?: GPUVertexStateDescriptor;
  80609. sampleCount?: number;
  80610. sampleMask?: number;
  80611. alphaToCoverageEnabled?: boolean;
  80612. }
  80613. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  80614. addressModeU?: GPUAddressMode;
  80615. addressModeV?: GPUAddressMode;
  80616. addressModeW?: GPUAddressMode;
  80617. magFilter?: GPUFilterMode;
  80618. minFilter?: GPUFilterMode;
  80619. mipmapFilter?: GPUFilterMode;
  80620. lodMinClamp?: number;
  80621. lodMaxClamp?: number;
  80622. compare?: GPUCompareFunction;
  80623. maxAnisotropy?: number;
  80624. }
  80625. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  80626. code: Uint32Array | string;
  80627. label?: string;
  80628. sourceMap?: object;
  80629. }
  80630. interface GPUStencilStateFaceDescriptor {
  80631. compare?: GPUCompareFunction;
  80632. depthFailOp?: GPUStencilOperation;
  80633. passOp?: GPUStencilOperation;
  80634. failOp?: GPUStencilOperation;
  80635. }
  80636. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  80637. device: GPUDevice;
  80638. format: GPUTextureFormat;
  80639. usage?: GPUTextureUsageFlags;
  80640. }
  80641. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  80642. size: GPUExtent3D;
  80643. mipLevelCount?: number;
  80644. sampleCount?: number;
  80645. dimension?: GPUTextureDimension;
  80646. format: GPUTextureFormat;
  80647. usage: GPUTextureUsageFlags;
  80648. }
  80649. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  80650. format?: GPUTextureFormat;
  80651. dimension?: GPUTextureViewDimension;
  80652. aspect?: GPUTextureAspect;
  80653. baseArrayLayer?: number;
  80654. baseMipLevel?: number;
  80655. arrayLayerCount?: number;
  80656. mipLevelCount?: number;
  80657. }
  80658. declare class GPUAdapter {
  80659. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  80660. private __brand: void;
  80661. readonly name: string;
  80662. readonly extensions: GPUExtensionName[];
  80663. readonly limits: Required<GPULimits>;
  80664. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  80665. }
  80666. declare class GPUBindGroup implements GPUObjectBase {
  80667. private __brand: void;
  80668. label: string | undefined;
  80669. }
  80670. declare class GPUBindGroupLayout implements GPUObjectBase {
  80671. private __brand: void;
  80672. label: string | undefined;
  80673. }
  80674. declare class GPUBuffer implements GPUObjectBase {
  80675. private __brand: void;
  80676. label: string | undefined;
  80677. destroy(): void;
  80678. unmap(): void;
  80679. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  80680. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  80681. }
  80682. declare class GPUCommandBuffer implements GPUObjectBase {
  80683. private __brand: void;
  80684. label: string | undefined;
  80685. readonly executionTime: Promise<number>;
  80686. }
  80687. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  80688. declare class GPUCommandEncoder implements GPUObjectBase {
  80689. private __brand: void;
  80690. label: string | undefined;
  80691. beginComputePass(
  80692. descriptor?: GPUComputePassDescriptor
  80693. ): GPUComputePassEncoder;
  80694. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  80695. copyBufferToBuffer(
  80696. source: GPUBuffer,
  80697. sourceOffset: number,
  80698. destination: GPUBuffer,
  80699. destinationOffset: number,
  80700. size: number
  80701. ): void;
  80702. copyBufferToTexture(
  80703. source: GPUBufferCopyView,
  80704. destination: GPUTextureCopyView,
  80705. copySize: GPUExtent3D
  80706. ): void;
  80707. copyTextureToBuffer(
  80708. source: GPUTextureCopyView,
  80709. destination: GPUBufferCopyView,
  80710. copySize: GPUExtent3D
  80711. ): void;
  80712. copyTextureToTexture(
  80713. source: GPUTextureCopyView,
  80714. destination: GPUTextureCopyView,
  80715. copySize: GPUExtent3D
  80716. ): void;
  80717. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  80718. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  80719. popDebugGroup(): void;
  80720. pushDebugGroup(groupLabel: string): void;
  80721. insertDebugMarker(markerLabel: string): void;
  80722. }
  80723. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  80724. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  80725. private __brand: void;
  80726. label: string | undefined;
  80727. setBindGroup(
  80728. index: number,
  80729. bindGroup: GPUBindGroup,
  80730. dynamicOffsets?: Iterable<number>
  80731. ): void;
  80732. popDebugGroup(): void;
  80733. pushDebugGroup(groupLabel: string): void;
  80734. insertDebugMarker(markerLabel: string): void;
  80735. setPipeline(pipeline: GPUComputePipeline): void;
  80736. dispatch(x: number, y?: number, z?: number): void;
  80737. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  80738. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  80739. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  80740. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  80741. endPass(): void;
  80742. }
  80743. declare class GPUComputePipeline implements GPUPipelineBase {
  80744. private __brand: void;
  80745. label: string | undefined;
  80746. getBindGroupLayout(index: number): GPUBindGroupLayout;
  80747. }
  80748. interface GPUObjectBase {
  80749. label: string | undefined;
  80750. }
  80751. interface GPUObjectDescriptorBase {
  80752. label?: string;
  80753. }
  80754. // SwapChain / CanvasContext
  80755. declare class GPUCanvasContext {
  80756. private __brand: void;
  80757. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  80758. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  80759. }
  80760. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  80761. private __brand: void;
  80762. label: string | undefined;
  80763. readonly adapter: GPUAdapter;
  80764. readonly extensions: GPUExtensionName[];
  80765. readonly limits: Required<GPULimits>;
  80766. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  80767. createBindGroupLayout(
  80768. descriptor: GPUBindGroupLayoutDescriptor
  80769. ): GPUBindGroupLayout;
  80770. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  80771. createPipelineLayout(
  80772. descriptor: GPUPipelineLayoutDescriptor
  80773. ): GPUPipelineLayout;
  80774. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  80775. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  80776. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  80777. createComputePipeline(
  80778. descriptor: GPUComputePipelineDescriptor
  80779. ): GPUComputePipeline;
  80780. createRenderPipeline(
  80781. descriptor: GPURenderPipelineDescriptor
  80782. ): GPURenderPipeline;
  80783. createReadyComputePipeline(
  80784. descriptor: GPUComputePipelineDescriptor
  80785. ): Promise<GPUComputePipeline>;
  80786. createReadyRenderPipeline(
  80787. descriptor: GPURenderPipelineDescriptor
  80788. ): Promise<GPURenderPipeline>;
  80789. createCommandEncoder(
  80790. descriptor?: GPUCommandEncoderDescriptor
  80791. ): GPUCommandEncoder;
  80792. createRenderBundleEncoder(
  80793. descriptor: GPURenderBundleEncoderDescriptor
  80794. ): GPURenderBundleEncoder;
  80795. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  80796. defaultQueue: GPUQueue;
  80797. pushErrorScope(filter: GPUErrorFilter): void;
  80798. popErrorScope(): Promise<GPUError | null>;
  80799. onuncapturederror: Event | undefined;
  80800. readonly lost: Promise<GPUDeviceLostInfo>;
  80801. }
  80802. declare class GPUFence implements GPUObjectBase {
  80803. private __brand: void;
  80804. label: string | undefined;
  80805. getCompletedValue(): number;
  80806. onCompletion(completionValue: number): Promise<void>;
  80807. }
  80808. interface GPUPipelineBase extends GPUObjectBase {
  80809. getBindGroupLayout(index: number): GPUBindGroupLayout;
  80810. }
  80811. declare class GPUPipelineLayout implements GPUObjectBase {
  80812. private __brand: void;
  80813. label: string | undefined;
  80814. }
  80815. interface GPUProgrammablePassEncoder {
  80816. setBindGroup(
  80817. index: number,
  80818. bindGroup: GPUBindGroup,
  80819. dynamicOffsets?: Iterable<number>
  80820. ): void;
  80821. popDebugGroup(): void;
  80822. pushDebugGroup(groupLabel: string): void;
  80823. insertDebugMarker(markerLabel: string): void;
  80824. }
  80825. declare class GPUQueue implements GPUObjectBase {
  80826. private __brand: void;
  80827. label: string | undefined;
  80828. signal(fence: GPUFence, signalValue: number): void;
  80829. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  80830. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  80831. writeBuffer(buffer: GPUBuffer,
  80832. bufferOffset: number,
  80833. data: BufferSource | ArrayBuffer,
  80834. dataOffset?: number,
  80835. size?: number): void;
  80836. writeTexture(destination: GPUTextureCopyView,
  80837. data: BufferSource | ArrayBuffer,
  80838. dataLayout: GPUTextureDataLayout,
  80839. size: GPUExtent3D): void;
  80840. copyImageBitmapToTexture(
  80841. source: GPUImageBitmapCopyView,
  80842. destination: GPUTextureCopyView,
  80843. copySize: GPUExtent3D
  80844. ): void;
  80845. }
  80846. type GPUQueryType =
  80847. | "occlusion"
  80848. | "timestamp"
  80849. | "pipeline-statistics";
  80850. type GPUPipelineStatisticName =
  80851. | "vertex-shader-invocations"
  80852. | "clipper-invocations"
  80853. | "clipper-primitives-out"
  80854. | "fragment-shader-invocations"
  80855. | "compute-shader-invocations";
  80856. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  80857. type: GPUQueryType;
  80858. count: number;
  80859. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  80860. }
  80861. declare class GPUQuerySet implements GPUObjectBase {
  80862. private __brand: void;
  80863. label: string | undefined;
  80864. destroy(): void;
  80865. }
  80866. interface GPURenderEncoderBase {
  80867. setPipeline(pipeline: GPURenderPipeline): void;
  80868. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  80869. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  80870. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  80871. draw(
  80872. vertexCount: number,
  80873. instanceCount?: number,
  80874. firstVertex?: number,
  80875. firstInstance?: number
  80876. ): void;
  80877. drawIndexed(
  80878. indexCount: number,
  80879. instanceCount?: number,
  80880. firstIndex?: number,
  80881. baseVertex?: number,
  80882. firstInstance?: number
  80883. ): void;
  80884. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  80885. drawIndexedIndirect(
  80886. indirectBuffer: GPUBuffer,
  80887. indirectOffset: number
  80888. ): void;
  80889. }
  80890. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  80891. private __brand: void;
  80892. label: string | undefined;
  80893. setBindGroup(
  80894. index: number,
  80895. bindGroup: GPUBindGroup,
  80896. dynamicOffsets?: Iterable<number>
  80897. ): void;
  80898. popDebugGroup(): void;
  80899. pushDebugGroup(groupLabel: string): void;
  80900. insertDebugMarker(markerLabel: string): void;
  80901. setPipeline(pipeline: GPURenderPipeline): void;
  80902. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  80903. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  80904. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  80905. draw(
  80906. vertexCount: number,
  80907. instanceCount?: number,
  80908. firstVertex?: number,
  80909. firstInstance?: number
  80910. ): void;
  80911. drawIndexed(
  80912. indexCount: number,
  80913. instanceCount?: number,
  80914. firstIndex?: number,
  80915. baseVertex?: number,
  80916. firstInstance?: number
  80917. ): void;
  80918. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  80919. drawIndexedIndirect(
  80920. indirectBuffer: GPUBuffer,
  80921. indirectOffset: number
  80922. ): void;
  80923. setViewport(
  80924. x: number,
  80925. y: number,
  80926. width: number,
  80927. height: number,
  80928. minDepth: number,
  80929. maxDepth: number
  80930. ): void;
  80931. setScissorRect(x: number, y: number, width: number, height: number): void;
  80932. setBlendColor(color: GPUColor): void;
  80933. setStencilReference(reference: number): void;
  80934. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  80935. beginOcclusionQuery(queryIndex: number): void;
  80936. endOcclusionQuery(): void;
  80937. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  80938. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  80939. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  80940. endPass(): void;
  80941. }
  80942. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  80943. declare class GPURenderBundle implements GPUObjectBase {
  80944. private __brand: void;
  80945. label: string | undefined;
  80946. }
  80947. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  80948. private __brand: void;
  80949. label: string | undefined;
  80950. setBindGroup(
  80951. index: number,
  80952. bindGroup: GPUBindGroup,
  80953. dynamicOffsets?: Iterable<number>
  80954. ): void;
  80955. popDebugGroup(): void;
  80956. pushDebugGroup(groupLabel: string): void;
  80957. insertDebugMarker(markerLabel: string): void;
  80958. setPipeline(pipeline: GPURenderPipeline): void;
  80959. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  80960. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  80961. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  80962. draw(
  80963. vertexCount: number,
  80964. instanceCount?: number,
  80965. firstVertex?: number,
  80966. firstInstance?: number
  80967. ): void;
  80968. drawIndexed(
  80969. indexCount: number,
  80970. instanceCount?: number,
  80971. firstIndex?: number,
  80972. baseVertex?: number,
  80973. firstInstance?: number
  80974. ): void;
  80975. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  80976. drawIndexedIndirect(
  80977. indirectBuffer: GPUBuffer,
  80978. indirectOffset: number
  80979. ): void;
  80980. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  80981. }
  80982. interface GPURenderBundleEncoderDescriptor
  80983. extends GPUObjectDescriptorBase {
  80984. colorFormats: Iterable<GPUTextureFormat>;
  80985. depthStencilFormat?: GPUTextureFormat;
  80986. sampleCount?: number;
  80987. }
  80988. declare class GPURenderPipeline implements GPUPipelineBase {
  80989. private __brand: void;
  80990. label: string | undefined;
  80991. getBindGroupLayout(index: number): GPUBindGroupLayout;
  80992. }
  80993. declare class GPUSampler implements GPUObjectBase {
  80994. private __brand: void;
  80995. label: string | undefined;
  80996. }
  80997. type GPUCompilationMessageType =
  80998. | "error"
  80999. | "warning"
  81000. | "info";
  81001. interface GPUCompilationMessage {
  81002. readonly message: string;
  81003. readonly type: GPUCompilationMessageType;
  81004. readonly lineNum: number;
  81005. readonly linePos: number;
  81006. }
  81007. interface GPUCompilationInfo {
  81008. readonly messages: readonly GPUCompilationMessage[];
  81009. }
  81010. declare class GPUShaderModule implements GPUObjectBase {
  81011. private __brand: void;
  81012. label: string | undefined;
  81013. compilationInfo(): Promise<GPUCompilationInfo>;
  81014. }
  81015. declare class GPUSwapChain implements GPUObjectBase {
  81016. private __brand: void;
  81017. label: string | undefined;
  81018. getCurrentTexture(): GPUTexture;
  81019. }
  81020. declare class GPUTexture implements GPUObjectBase {
  81021. private __brand: void;
  81022. label: string | undefined;
  81023. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81024. destroy(): void;
  81025. }
  81026. declare class GPUTextureView implements GPUObjectBase {
  81027. private __brand: void;
  81028. label: string | undefined;
  81029. }
  81030. type GPUPowerPreference = "low-power" | "high-performance";
  81031. interface GPURequestAdapterOptions {
  81032. powerPreference?: GPUPowerPreference;
  81033. }
  81034. declare class GPU {
  81035. private __brand: void;
  81036. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81037. }
  81038. // ****************************************************************************
  81039. // ERROR SCOPES
  81040. // ****************************************************************************
  81041. type GPUErrorFilter = "out-of-memory" | "validation";
  81042. declare class GPUOutOfMemoryError {
  81043. private __brand: void;
  81044. constructor();
  81045. }
  81046. declare class GPUValidationError {
  81047. private __brand: void;
  81048. constructor(message: string);
  81049. readonly message: string;
  81050. }
  81051. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81052. // ****************************************************************************
  81053. // TELEMETRY
  81054. // ****************************************************************************
  81055. declare class GPUUncapturedErrorEvent extends Event {
  81056. private __brand: void;
  81057. constructor(
  81058. type: string,
  81059. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81060. );
  81061. readonly error: GPUError;
  81062. }
  81063. interface GPUUncapturedErrorEventInit extends EventInit {
  81064. error: GPUError;
  81065. }
  81066. declare class GPUDeviceLostInfo {
  81067. private __brand: void;
  81068. readonly message: string;
  81069. }
  81070. // Type definitions for WebVR API
  81071. // Project: https://w3c.github.io/webvr/
  81072. // Definitions by: six a <https://github.com/lostfictions>
  81073. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81074. interface VRDisplay extends EventTarget {
  81075. /**
  81076. * Dictionary of capabilities describing the VRDisplay.
  81077. */
  81078. readonly capabilities: VRDisplayCapabilities;
  81079. /**
  81080. * z-depth defining the far plane of the eye view frustum
  81081. * enables mapping of values in the render target depth
  81082. * attachment to scene coordinates. Initially set to 10000.0.
  81083. */
  81084. depthFar: number;
  81085. /**
  81086. * z-depth defining the near plane of the eye view frustum
  81087. * enables mapping of values in the render target depth
  81088. * attachment to scene coordinates. Initially set to 0.01.
  81089. */
  81090. depthNear: number;
  81091. /**
  81092. * An identifier for this distinct VRDisplay. Used as an
  81093. * association point in the Gamepad API.
  81094. */
  81095. readonly displayId: number;
  81096. /**
  81097. * A display name, a user-readable name identifying it.
  81098. */
  81099. readonly displayName: string;
  81100. readonly isConnected: boolean;
  81101. readonly isPresenting: boolean;
  81102. /**
  81103. * If this VRDisplay supports room-scale experiences, the optional
  81104. * stage attribute contains details on the room-scale parameters.
  81105. */
  81106. readonly stageParameters: VRStageParameters | null;
  81107. /**
  81108. * Passing the value returned by `requestAnimationFrame` to
  81109. * `cancelAnimationFrame` will unregister the callback.
  81110. * @param handle Define the hanle of the request to cancel
  81111. */
  81112. cancelAnimationFrame(handle: number): void;
  81113. /**
  81114. * Stops presenting to the VRDisplay.
  81115. * @returns a promise to know when it stopped
  81116. */
  81117. exitPresent(): Promise<void>;
  81118. /**
  81119. * Return the current VREyeParameters for the given eye.
  81120. * @param whichEye Define the eye we want the parameter for
  81121. * @returns the eye parameters
  81122. */
  81123. getEyeParameters(whichEye: string): VREyeParameters;
  81124. /**
  81125. * Populates the passed VRFrameData with the information required to render
  81126. * the current frame.
  81127. * @param frameData Define the data structure to populate
  81128. * @returns true if ok otherwise false
  81129. */
  81130. getFrameData(frameData: VRFrameData): boolean;
  81131. /**
  81132. * Get the layers currently being presented.
  81133. * @returns the list of VR layers
  81134. */
  81135. getLayers(): VRLayer[];
  81136. /**
  81137. * Return a VRPose containing the future predicted pose of the VRDisplay
  81138. * when the current frame will be presented. The value returned will not
  81139. * change until JavaScript has returned control to the browser.
  81140. *
  81141. * The VRPose will contain the position, orientation, velocity,
  81142. * and acceleration of each of these properties.
  81143. * @returns the pose object
  81144. */
  81145. getPose(): VRPose;
  81146. /**
  81147. * Return the current instantaneous pose of the VRDisplay, with no
  81148. * prediction applied.
  81149. * @returns the current instantaneous pose
  81150. */
  81151. getImmediatePose(): VRPose;
  81152. /**
  81153. * The callback passed to `requestAnimationFrame` will be called
  81154. * any time a new frame should be rendered. When the VRDisplay is
  81155. * presenting the callback will be called at the native refresh
  81156. * rate of the HMD. When not presenting this function acts
  81157. * identically to how window.requestAnimationFrame acts. Content should
  81158. * make no assumptions of frame rate or vsync behavior as the HMD runs
  81159. * asynchronously from other displays and at differing refresh rates.
  81160. * @param callback Define the eaction to run next frame
  81161. * @returns the request handle it
  81162. */
  81163. requestAnimationFrame(callback: FrameRequestCallback): number;
  81164. /**
  81165. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  81166. * Repeat calls while already presenting will update the VRLayers being displayed.
  81167. * @param layers Define the list of layer to present
  81168. * @returns a promise to know when the request has been fulfilled
  81169. */
  81170. requestPresent(layers: VRLayer[]): Promise<void>;
  81171. /**
  81172. * Reset the pose for this display, treating its current position and
  81173. * orientation as the "origin/zero" values. VRPose.position,
  81174. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  81175. * updated when calling resetPose(). This should be called in only
  81176. * sitting-space experiences.
  81177. */
  81178. resetPose(): void;
  81179. /**
  81180. * The VRLayer provided to the VRDisplay will be captured and presented
  81181. * in the HMD. Calling this function has the same effect on the source
  81182. * canvas as any other operation that uses its source image, and canvases
  81183. * created without preserveDrawingBuffer set to true will be cleared.
  81184. * @param pose Define the pose to submit
  81185. */
  81186. submitFrame(pose?: VRPose): void;
  81187. }
  81188. declare var VRDisplay: {
  81189. prototype: VRDisplay;
  81190. new(): VRDisplay;
  81191. };
  81192. interface VRLayer {
  81193. leftBounds?: number[] | Float32Array | null;
  81194. rightBounds?: number[] | Float32Array | null;
  81195. source?: HTMLCanvasElement | null;
  81196. }
  81197. interface VRDisplayCapabilities {
  81198. readonly canPresent: boolean;
  81199. readonly hasExternalDisplay: boolean;
  81200. readonly hasOrientation: boolean;
  81201. readonly hasPosition: boolean;
  81202. readonly maxLayers: number;
  81203. }
  81204. interface VREyeParameters {
  81205. /** @deprecated */
  81206. readonly fieldOfView: VRFieldOfView;
  81207. readonly offset: Float32Array;
  81208. readonly renderHeight: number;
  81209. readonly renderWidth: number;
  81210. }
  81211. interface VRFieldOfView {
  81212. readonly downDegrees: number;
  81213. readonly leftDegrees: number;
  81214. readonly rightDegrees: number;
  81215. readonly upDegrees: number;
  81216. }
  81217. interface VRFrameData {
  81218. readonly leftProjectionMatrix: Float32Array;
  81219. readonly leftViewMatrix: Float32Array;
  81220. readonly pose: VRPose;
  81221. readonly rightProjectionMatrix: Float32Array;
  81222. readonly rightViewMatrix: Float32Array;
  81223. readonly timestamp: number;
  81224. }
  81225. interface VRPose {
  81226. readonly angularAcceleration: Float32Array | null;
  81227. readonly angularVelocity: Float32Array | null;
  81228. readonly linearAcceleration: Float32Array | null;
  81229. readonly linearVelocity: Float32Array | null;
  81230. readonly orientation: Float32Array | null;
  81231. readonly position: Float32Array | null;
  81232. readonly timestamp: number;
  81233. }
  81234. interface VRStageParameters {
  81235. sittingToStandingTransform?: Float32Array;
  81236. sizeX?: number;
  81237. sizeY?: number;
  81238. }
  81239. interface Navigator {
  81240. getVRDisplays(): Promise<VRDisplay[]>;
  81241. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  81242. }
  81243. interface Window {
  81244. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  81245. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  81246. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  81247. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81248. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81249. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  81250. }
  81251. interface Gamepad {
  81252. readonly displayId: number;
  81253. }
  81254. /**
  81255. * Available session modes
  81256. */
  81257. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  81258. /**
  81259. * Reference space types
  81260. */
  81261. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  81262. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  81263. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  81264. /**
  81265. * Handedness types
  81266. */
  81267. type XRHandedness = "none" | "left" | "right";
  81268. /**
  81269. * InputSource target ray modes
  81270. */
  81271. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  81272. /**
  81273. * Eye types
  81274. */
  81275. type XREye = "none" | "left" | "right";
  81276. /**
  81277. * Type of XR events available
  81278. */
  81279. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  81280. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  81281. type XRPlaneSet = Set<XRPlane>;
  81282. type XRAnchorSet = Set<XRAnchor>;
  81283. type XREventHandler = (callback: any) => void;
  81284. interface XRLayer extends EventTarget {}
  81285. interface XRSessionInit {
  81286. optionalFeatures?: string[];
  81287. requiredFeatures?: string[];
  81288. }
  81289. interface XRSessionEvent extends Event {
  81290. readonly session: XRSession;
  81291. }
  81292. interface XRSystem {
  81293. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  81294. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  81295. }
  81296. interface XRViewport {
  81297. readonly x: number;
  81298. readonly y: number;
  81299. readonly width: number;
  81300. readonly height: number;
  81301. }
  81302. interface XRWebGLLayerInit {
  81303. antialias?: boolean;
  81304. depth?: boolean;
  81305. stencil?: boolean;
  81306. alpha?: boolean;
  81307. multiview?: boolean;
  81308. framebufferScaleFactor?: number;
  81309. }
  81310. declare class XRWebGLLayer {
  81311. static getNativeFramebufferScaleFactor(session: XRSession): number;
  81312. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  81313. readonly antialias: boolean;
  81314. readonly framebuffer: WebGLFramebuffer;
  81315. readonly framebufferWidth: number;
  81316. readonly framebufferHeight: number;
  81317. readonly ignoreDepthValues: boolean;
  81318. getViewport: (view: XRView) => XRViewport;
  81319. }
  81320. // tslint:disable-next-line no-empty-interface
  81321. interface XRSpace extends EventTarget {}
  81322. interface XRRenderState {
  81323. readonly baseLayer?: XRWebGLLayer;
  81324. readonly depthFar: number;
  81325. readonly depthNear: number;
  81326. readonly inlineVerticalFieldOfView?: number;
  81327. }
  81328. interface XRRenderStateInit extends XRRenderState {
  81329. baseLayer: XRWebGLLayer;
  81330. depthFar: number;
  81331. depthNear: number;
  81332. inlineVerticalFieldOfView?: number;
  81333. layers?: XRLayer[];
  81334. }
  81335. interface XRReferenceSpace extends XRSpace {
  81336. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  81337. onreset: XREventHandler;
  81338. }
  81339. interface XRBoundedReferenceSpace extends XRSpace {
  81340. readonly boundsGeometry: DOMPointReadOnly[];
  81341. }
  81342. interface XRInputSource {
  81343. readonly handedness: XRHandedness;
  81344. readonly targetRayMode: XRTargetRayMode;
  81345. readonly targetRaySpace: XRSpace;
  81346. readonly gripSpace?: XRSpace;
  81347. readonly gamepad?: Gamepad;
  81348. readonly profiles: Array<string>;
  81349. readonly hand?: XRHand;
  81350. }
  81351. interface XRPose {
  81352. readonly transform: XRRigidTransform;
  81353. readonly emulatedPosition: boolean;
  81354. }
  81355. interface XRWorldInformation {
  81356. detectedPlanes?: XRPlaneSet;
  81357. }
  81358. interface XRFrame {
  81359. readonly session: XRSession;
  81360. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  81361. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  81362. // AR
  81363. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  81364. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  81365. // Anchors
  81366. trackedAnchors?: XRAnchorSet;
  81367. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  81368. // World geometries
  81369. worldInformation?: XRWorldInformation;
  81370. // Hand tracking
  81371. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  81372. }
  81373. interface XRInputSourceEvent extends Event {
  81374. readonly frame: XRFrame;
  81375. readonly inputSource: XRInputSource;
  81376. }
  81377. type XRInputSourceArray = XRInputSource[];
  81378. interface XRSession {
  81379. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  81380. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  81381. /**
  81382. * Returns a list of this session's XRInputSources, each representing an input device
  81383. * used to control the camera and/or scene.
  81384. */
  81385. readonly inputSources: Array<XRInputSource>;
  81386. /**
  81387. * object which contains options affecting how the imagery is rendered.
  81388. * This includes things such as the near and far clipping planes
  81389. */
  81390. readonly renderState: XRRenderState;
  81391. readonly visibilityState: XRVisibilityState;
  81392. /**
  81393. * Removes a callback from the animation frame painting callback from
  81394. * XRSession's set of animation frame rendering callbacks, given the
  81395. * identifying handle returned by a previous call to requestAnimationFrame().
  81396. */
  81397. cancelAnimationFrame: (handle: number) => void;
  81398. /**
  81399. * Ends the WebXR session. Returns a promise which resolves when the
  81400. * session has been shut down.
  81401. */
  81402. end(): Promise<void>;
  81403. /**
  81404. * Schedules the specified method to be called the next time the user agent
  81405. * is working on rendering an animation frame for the WebXR device. Returns an
  81406. * integer value which can be used to identify the request for the purposes of
  81407. * canceling the callback using cancelAnimationFrame(). This method is comparable
  81408. * to the Window.requestAnimationFrame() method.
  81409. */
  81410. requestAnimationFrame: XRFrameRequestCallback;
  81411. /**
  81412. * Requests that a new XRReferenceSpace of the specified type be created.
  81413. * Returns a promise which resolves with the XRReferenceSpace or
  81414. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  81415. * the requested space type isn't supported by the device.
  81416. */
  81417. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  81418. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  81419. onend: XREventHandler;
  81420. oninputsourceschange: XREventHandler;
  81421. onselect: XREventHandler;
  81422. onselectstart: XREventHandler;
  81423. onselectend: XREventHandler;
  81424. onsqueeze: XREventHandler;
  81425. onsqueezestart: XREventHandler;
  81426. onsqueezeend: XREventHandler;
  81427. onvisibilitychange: XREventHandler;
  81428. // hit test
  81429. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  81430. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  81431. // legacy AR hit test
  81432. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  81433. // legacy plane detection
  81434. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  81435. }
  81436. interface XRViewerPose extends XRPose {
  81437. readonly views: Array<XRView>;
  81438. }
  81439. declare class XRRigidTransform {
  81440. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  81441. position: DOMPointReadOnly;
  81442. orientation: DOMPointReadOnly;
  81443. matrix: Float32Array;
  81444. inverse: XRRigidTransform;
  81445. }
  81446. interface XRView {
  81447. readonly eye: XREye;
  81448. readonly projectionMatrix: Float32Array;
  81449. readonly transform: XRRigidTransform;
  81450. readonly recommendedViewportScale?: number;
  81451. requestViewportScale(scale: number): void;
  81452. }
  81453. interface XRInputSourceChangeEvent extends Event {
  81454. session: XRSession;
  81455. removed: Array<XRInputSource>;
  81456. added: Array<XRInputSource>;
  81457. }
  81458. // Experimental/Draft features
  81459. declare class XRRay {
  81460. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  81461. origin: DOMPointReadOnly;
  81462. direction: DOMPointReadOnly;
  81463. matrix: Float32Array;
  81464. }
  81465. declare enum XRHitTestTrackableType {
  81466. "point",
  81467. "plane",
  81468. "mesh",
  81469. }
  81470. interface XRHitResult {
  81471. hitMatrix: Float32Array;
  81472. }
  81473. interface XRTransientInputHitTestResult {
  81474. readonly inputSource: XRInputSource;
  81475. readonly results: Array<XRHitTestResult>;
  81476. }
  81477. interface XRHitTestResult {
  81478. getPose(baseSpace: XRSpace): XRPose | undefined;
  81479. // When anchor system is enabled
  81480. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  81481. }
  81482. interface XRHitTestSource {
  81483. cancel(): void;
  81484. }
  81485. interface XRTransientInputHitTestSource {
  81486. cancel(): void;
  81487. }
  81488. interface XRHitTestOptionsInit {
  81489. space: XRSpace;
  81490. entityTypes?: Array<XRHitTestTrackableType>;
  81491. offsetRay?: XRRay;
  81492. }
  81493. interface XRTransientInputHitTestOptionsInit {
  81494. profile: string;
  81495. entityTypes?: Array<XRHitTestTrackableType>;
  81496. offsetRay?: XRRay;
  81497. }
  81498. interface XRAnchor {
  81499. anchorSpace: XRSpace;
  81500. delete(): void;
  81501. }
  81502. interface XRPlane {
  81503. orientation: "Horizontal" | "Vertical";
  81504. planeSpace: XRSpace;
  81505. polygon: Array<DOMPointReadOnly>;
  81506. lastChangedTime: number;
  81507. }
  81508. interface XRJointSpace extends XRSpace {}
  81509. interface XRJointPose extends XRPose {
  81510. radius: number | undefined;
  81511. }
  81512. interface XRHand extends Iterable<XRJointSpace> {
  81513. readonly length: number;
  81514. [index: number]: XRJointSpace;
  81515. readonly WRIST: number;
  81516. readonly THUMB_METACARPAL: number;
  81517. readonly THUMB_PHALANX_PROXIMAL: number;
  81518. readonly THUMB_PHALANX_DISTAL: number;
  81519. readonly THUMB_PHALANX_TIP: number;
  81520. readonly INDEX_METACARPAL: number;
  81521. readonly INDEX_PHALANX_PROXIMAL: number;
  81522. readonly INDEX_PHALANX_INTERMEDIATE: number;
  81523. readonly INDEX_PHALANX_DISTAL: number;
  81524. readonly INDEX_PHALANX_TIP: number;
  81525. readonly MIDDLE_METACARPAL: number;
  81526. readonly MIDDLE_PHALANX_PROXIMAL: number;
  81527. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  81528. readonly MIDDLE_PHALANX_DISTAL: number;
  81529. readonly MIDDLE_PHALANX_TIP: number;
  81530. readonly RING_METACARPAL: number;
  81531. readonly RING_PHALANX_PROXIMAL: number;
  81532. readonly RING_PHALANX_INTERMEDIATE: number;
  81533. readonly RING_PHALANX_DISTAL: number;
  81534. readonly RING_PHALANX_TIP: number;
  81535. readonly LITTLE_METACARPAL: number;
  81536. readonly LITTLE_PHALANX_PROXIMAL: number;
  81537. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  81538. readonly LITTLE_PHALANX_DISTAL: number;
  81539. readonly LITTLE_PHALANX_TIP: number;
  81540. }
  81541. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  81542. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  81543. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  81544. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  81545. interface XRSceneObject {
  81546. type: XRSceneObjectType;
  81547. }
  81548. interface XRFieldOfView {
  81549. angleLeft: number;
  81550. angleRight: number;
  81551. angleUp: number;
  81552. angleDown: number;
  81553. }
  81554. interface XRFrustum {
  81555. position: DOMPointReadOnly;
  81556. orientation: DOMPointReadOnly;
  81557. fieldOfView: XRFieldOfView;
  81558. farDistance: number;
  81559. }
  81560. interface XRPlane {
  81561. parentSceneObject?: XRSceneObject;
  81562. }
  81563. interface XRMesh {
  81564. meshSpace: XRSpace;
  81565. positions: Float32Array;
  81566. indices: Uint32Array;
  81567. normals?: Float32Array;
  81568. lastChangedTime: number;
  81569. parentSceneObject?: XRSceneObject;
  81570. }
  81571. interface XRFrustumDetectionBoundary {
  81572. type: "frustum";
  81573. frustum: XRFrustum;
  81574. }
  81575. interface XRSphereDetectionBoundary {
  81576. type: "sphere";
  81577. radius: number;
  81578. }
  81579. interface XRBoxDetectionBoundary {
  81580. type: "box";
  81581. extent: DOMPointReadOnly;
  81582. }
  81583. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  81584. interface XRGeometryDetectorOptions {
  81585. detectionBoundary?: XRDetectionBoundary;
  81586. updateInterval?: number;
  81587. }
  81588. interface XRSession {
  81589. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  81590. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  81591. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  81592. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  81593. }
  81594. interface XRFrame {
  81595. featurePointCloud?: Array<number>;
  81596. }
  81597. type XRMeshSet = Set<XRMesh>;
  81598. interface XRWorldInformation {
  81599. detectedMeshes?: XRMeshSet;
  81600. }
  81601. /**
  81602. * @ignore
  81603. */
  81604. declare module BABYLON.GLTF2.Exporter {
  81605. }
  81606. /**
  81607. * @ignore
  81608. */
  81609. declare module BABYLON.GLTF1 {
  81610. }
  81611. declare module BABYLON.GUI {
  81612. /**
  81613. * Interface used to define a control that can receive focus
  81614. */
  81615. export interface IFocusableControl {
  81616. /**
  81617. * Function called when the control receives the focus
  81618. */
  81619. onFocus(): void;
  81620. /**
  81621. * Function called when the control loses the focus
  81622. */
  81623. onBlur(): void;
  81624. /**
  81625. * Function called to let the control handle keyboard events
  81626. * @param evt defines the current keyboard event
  81627. */
  81628. processKeyboard(evt: KeyboardEvent): void;
  81629. /**
  81630. * Function called to get the list of controls that should not steal the focus from this control
  81631. * @returns an array of controls
  81632. */
  81633. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  81634. /**
  81635. * Function to focus the control programmatically
  81636. */
  81637. focus(): void;
  81638. /**
  81639. * Function to unfocus the control programmatically
  81640. */
  81641. blur(): void;
  81642. }
  81643. }
  81644. declare module BABYLON.GUI {
  81645. /**
  81646. * Class used to specific a value and its associated unit
  81647. */
  81648. export class ValueAndUnit {
  81649. /** defines the unit to store */
  81650. unit: number;
  81651. /** defines a boolean indicating if the value can be negative */
  81652. negativeValueAllowed: boolean;
  81653. private _value;
  81654. private _originalUnit;
  81655. /**
  81656. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  81657. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  81658. */
  81659. ignoreAdaptiveScaling: boolean;
  81660. /**
  81661. * Creates a new ValueAndUnit
  81662. * @param value defines the value to store
  81663. * @param unit defines the unit to store
  81664. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  81665. */
  81666. constructor(value: number,
  81667. /** defines the unit to store */
  81668. unit?: number,
  81669. /** defines a boolean indicating if the value can be negative */
  81670. negativeValueAllowed?: boolean);
  81671. /** Gets a boolean indicating if the value is a percentage */
  81672. get isPercentage(): boolean;
  81673. /** Gets a boolean indicating if the value is store as pixel */
  81674. get isPixel(): boolean;
  81675. /** Gets direct internal value */
  81676. get internalValue(): number;
  81677. /**
  81678. * Gets value as pixel
  81679. * @param host defines the root host
  81680. * @param refValue defines the reference value for percentages
  81681. * @returns the value as pixel
  81682. */
  81683. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  81684. /**
  81685. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  81686. * @param value defines the value to store
  81687. * @param unit defines the unit to store
  81688. * @returns the current ValueAndUnit
  81689. */
  81690. updateInPlace(value: number, unit?: number): ValueAndUnit;
  81691. /**
  81692. * Gets the value accordingly to its unit
  81693. * @param host defines the root host
  81694. * @returns the value
  81695. */
  81696. getValue(host: AdvancedDynamicTexture): number;
  81697. /**
  81698. * Gets a string representation of the value
  81699. * @param host defines the root host
  81700. * @param decimals defines an optional number of decimals to display
  81701. * @returns a string
  81702. */
  81703. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  81704. /**
  81705. * Store a value parsed from a string
  81706. * @param source defines the source string
  81707. * @returns true if the value was successfully parsed
  81708. */
  81709. fromString(source: string | number): boolean;
  81710. private static _Regex;
  81711. private static _UNITMODE_PERCENTAGE;
  81712. private static _UNITMODE_PIXEL;
  81713. /** UNITMODE_PERCENTAGE */
  81714. static get UNITMODE_PERCENTAGE(): number;
  81715. /** UNITMODE_PIXEL */
  81716. static get UNITMODE_PIXEL(): number;
  81717. }
  81718. }
  81719. declare module BABYLON.GUI {
  81720. /**
  81721. * Define a style used by control to automatically setup properties based on a template.
  81722. * Only support font related properties so far
  81723. */
  81724. export class Style implements BABYLON.IDisposable {
  81725. private _fontFamily;
  81726. private _fontStyle;
  81727. private _fontWeight;
  81728. /** @hidden */
  81729. _host: AdvancedDynamicTexture;
  81730. /** @hidden */
  81731. _fontSize: ValueAndUnit;
  81732. /**
  81733. * BABYLON.Observable raised when the style values are changed
  81734. */
  81735. onChangedObservable: BABYLON.Observable<Style>;
  81736. /**
  81737. * Creates a new style object
  81738. * @param host defines the AdvancedDynamicTexture which hosts this style
  81739. */
  81740. constructor(host: AdvancedDynamicTexture);
  81741. /**
  81742. * Gets or sets the font size
  81743. */
  81744. get fontSize(): string | number;
  81745. set fontSize(value: string | number);
  81746. /**
  81747. * Gets or sets the font family
  81748. */
  81749. get fontFamily(): string;
  81750. set fontFamily(value: string);
  81751. /**
  81752. * Gets or sets the font style
  81753. */
  81754. get fontStyle(): string;
  81755. set fontStyle(value: string);
  81756. /** Gets or sets font weight */
  81757. get fontWeight(): string;
  81758. set fontWeight(value: string);
  81759. /** Dispose all associated resources */
  81760. dispose(): void;
  81761. }
  81762. }
  81763. declare module BABYLON.GUI {
  81764. /**
  81765. * Class used to transport BABYLON.Vector2 information for pointer events
  81766. */
  81767. export class Vector2WithInfo extends BABYLON.Vector2 {
  81768. /** defines the current mouse button index */
  81769. buttonIndex: number;
  81770. /**
  81771. * Creates a new Vector2WithInfo
  81772. * @param source defines the vector2 data to transport
  81773. * @param buttonIndex defines the current mouse button index
  81774. */
  81775. constructor(source: BABYLON.Vector2,
  81776. /** defines the current mouse button index */
  81777. buttonIndex?: number);
  81778. }
  81779. /** Class used to provide 2D matrix features */
  81780. export class Matrix2D {
  81781. /** Gets the internal array of 6 floats used to store matrix data */
  81782. m: Float32Array;
  81783. /**
  81784. * Creates a new matrix
  81785. * @param m00 defines value for (0, 0)
  81786. * @param m01 defines value for (0, 1)
  81787. * @param m10 defines value for (1, 0)
  81788. * @param m11 defines value for (1, 1)
  81789. * @param m20 defines value for (2, 0)
  81790. * @param m21 defines value for (2, 1)
  81791. */
  81792. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  81793. /**
  81794. * Fills the matrix from direct values
  81795. * @param m00 defines value for (0, 0)
  81796. * @param m01 defines value for (0, 1)
  81797. * @param m10 defines value for (1, 0)
  81798. * @param m11 defines value for (1, 1)
  81799. * @param m20 defines value for (2, 0)
  81800. * @param m21 defines value for (2, 1)
  81801. * @returns the current modified matrix
  81802. */
  81803. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  81804. /**
  81805. * Gets matrix determinant
  81806. * @returns the determinant
  81807. */
  81808. determinant(): number;
  81809. /**
  81810. * Inverses the matrix and stores it in a target matrix
  81811. * @param result defines the target matrix
  81812. * @returns the current matrix
  81813. */
  81814. invertToRef(result: Matrix2D): Matrix2D;
  81815. /**
  81816. * Multiplies the current matrix with another one
  81817. * @param other defines the second operand
  81818. * @param result defines the target matrix
  81819. * @returns the current matrix
  81820. */
  81821. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  81822. /**
  81823. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  81824. * @param x defines the x coordinate to transform
  81825. * @param y defines the x coordinate to transform
  81826. * @param result defines the target vector2
  81827. * @returns the current matrix
  81828. */
  81829. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  81830. /**
  81831. * Creates an identity matrix
  81832. * @returns a new matrix
  81833. */
  81834. static Identity(): Matrix2D;
  81835. /**
  81836. * Creates a translation matrix and stores it in a target matrix
  81837. * @param x defines the x coordinate of the translation
  81838. * @param y defines the y coordinate of the translation
  81839. * @param result defines the target matrix
  81840. */
  81841. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  81842. /**
  81843. * Creates a scaling matrix and stores it in a target matrix
  81844. * @param x defines the x coordinate of the scaling
  81845. * @param y defines the y coordinate of the scaling
  81846. * @param result defines the target matrix
  81847. */
  81848. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  81849. /**
  81850. * Creates a rotation matrix and stores it in a target matrix
  81851. * @param angle defines the rotation angle
  81852. * @param result defines the target matrix
  81853. */
  81854. static RotationToRef(angle: number, result: Matrix2D): void;
  81855. private static _TempPreTranslationMatrix;
  81856. private static _TempPostTranslationMatrix;
  81857. private static _TempRotationMatrix;
  81858. private static _TempScalingMatrix;
  81859. private static _TempCompose0;
  81860. private static _TempCompose1;
  81861. private static _TempCompose2;
  81862. /**
  81863. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  81864. * @param tx defines the x coordinate of the translation
  81865. * @param ty defines the y coordinate of the translation
  81866. * @param angle defines the rotation angle
  81867. * @param scaleX defines the x coordinate of the scaling
  81868. * @param scaleY defines the y coordinate of the scaling
  81869. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  81870. * @param result defines the target matrix
  81871. */
  81872. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  81873. }
  81874. }
  81875. declare module BABYLON.GUI {
  81876. /**
  81877. * Class used to store 2D control sizes
  81878. */
  81879. export class Measure {
  81880. /** defines left coordinate */
  81881. left: number;
  81882. /** defines top coordinate */
  81883. top: number;
  81884. /** defines width dimension */
  81885. width: number;
  81886. /** defines height dimension */
  81887. height: number;
  81888. /**
  81889. * Creates a new measure
  81890. * @param left defines left coordinate
  81891. * @param top defines top coordinate
  81892. * @param width defines width dimension
  81893. * @param height defines height dimension
  81894. */
  81895. constructor(
  81896. /** defines left coordinate */
  81897. left: number,
  81898. /** defines top coordinate */
  81899. top: number,
  81900. /** defines width dimension */
  81901. width: number,
  81902. /** defines height dimension */
  81903. height: number);
  81904. /**
  81905. * Copy from another measure
  81906. * @param other defines the other measure to copy from
  81907. */
  81908. copyFrom(other: Measure): void;
  81909. /**
  81910. * Copy from a group of 4 floats
  81911. * @param left defines left coordinate
  81912. * @param top defines top coordinate
  81913. * @param width defines width dimension
  81914. * @param height defines height dimension
  81915. */
  81916. copyFromFloats(left: number, top: number, width: number, height: number): void;
  81917. /**
  81918. * Computes the axis aligned bounding box measure for two given measures
  81919. * @param a Input measure
  81920. * @param b Input measure
  81921. * @param result the resulting bounding measure
  81922. */
  81923. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  81924. /**
  81925. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  81926. * @param transform the matrix to transform the measure before computing the AABB
  81927. * @param addX number to add to left
  81928. * @param addY number to add to top
  81929. * @param addWidth number to add to width
  81930. * @param addHeight number to add to height
  81931. * @param result the resulting AABB
  81932. */
  81933. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  81934. /**
  81935. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  81936. * @param transform the matrix to transform the measure before computing the AABB
  81937. * @param result the resulting AABB
  81938. */
  81939. transformToRef(transform: Matrix2D, result: Measure): void;
  81940. /**
  81941. * Check equality between this measure and another one
  81942. * @param other defines the other measures
  81943. * @returns true if both measures are equals
  81944. */
  81945. isEqualsTo(other: Measure): boolean;
  81946. /**
  81947. * Creates an empty measure
  81948. * @returns a new measure
  81949. */
  81950. static Empty(): Measure;
  81951. }
  81952. }
  81953. declare module BABYLON.GUI {
  81954. /**
  81955. * Class used to create texture to support 2D GUI elements
  81956. * @see https://doc.babylonjs.com/how_to/gui
  81957. */
  81958. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  81959. private _isDirty;
  81960. private _renderObserver;
  81961. private _resizeObserver;
  81962. private _preKeyboardObserver;
  81963. private _pointerMoveObserver;
  81964. private _pointerObserver;
  81965. private _canvasPointerOutObserver;
  81966. private _canvasBlurObserver;
  81967. private _background;
  81968. /** @hidden */
  81969. _rootContainer: Container;
  81970. /** @hidden */
  81971. _lastPickedControl: Control;
  81972. /** @hidden */
  81973. _lastControlOver: {
  81974. [pointerId: number]: Control;
  81975. };
  81976. /** @hidden */
  81977. _lastControlDown: {
  81978. [pointerId: number]: Control;
  81979. };
  81980. /** @hidden */
  81981. _capturingControl: {
  81982. [pointerId: number]: Control;
  81983. };
  81984. /** @hidden */
  81985. _shouldBlockPointer: boolean;
  81986. /** @hidden */
  81987. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  81988. /** @hidden */
  81989. _linkedControls: Control[];
  81990. private _isFullscreen;
  81991. private _fullscreenViewport;
  81992. private _idealWidth;
  81993. private _idealHeight;
  81994. private _useSmallestIdeal;
  81995. private _renderAtIdealSize;
  81996. private _focusedControl;
  81997. private _blockNextFocusCheck;
  81998. private _renderScale;
  81999. private _rootElement;
  82000. private _cursorChanged;
  82001. private _defaultMousePointerId;
  82002. /** @hidden */
  82003. _numLayoutCalls: number;
  82004. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82005. get numLayoutCalls(): number;
  82006. /** @hidden */
  82007. _numRenderCalls: number;
  82008. /** Gets the number of render calls made the last time the ADT has been rendered */
  82009. get numRenderCalls(): number;
  82010. /**
  82011. * Define type to string to ensure compatibility across browsers
  82012. * Safari doesn't support DataTransfer constructor
  82013. */
  82014. private _clipboardData;
  82015. /**
  82016. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82017. */
  82018. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82019. /**
  82020. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82021. */
  82022. onControlPickedObservable: BABYLON.Observable<Control>;
  82023. /**
  82024. * BABYLON.Observable event triggered before layout is evaluated
  82025. */
  82026. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82027. /**
  82028. * BABYLON.Observable event triggered after the layout was evaluated
  82029. */
  82030. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82031. /**
  82032. * BABYLON.Observable event triggered before the texture is rendered
  82033. */
  82034. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82035. /**
  82036. * BABYLON.Observable event triggered after the texture was rendered
  82037. */
  82038. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82039. /**
  82040. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82041. */
  82042. premulAlpha: boolean;
  82043. /**
  82044. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82045. */
  82046. applyYInversionOnUpdate: boolean;
  82047. /**
  82048. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82049. * Useful when you want more antialiasing
  82050. */
  82051. get renderScale(): number;
  82052. set renderScale(value: number);
  82053. /** Gets or sets the background color */
  82054. get background(): string;
  82055. set background(value: string);
  82056. /**
  82057. * Gets or sets the ideal width used to design controls.
  82058. * The GUI will then rescale everything accordingly
  82059. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82060. */
  82061. get idealWidth(): number;
  82062. set idealWidth(value: number);
  82063. /**
  82064. * Gets or sets the ideal height used to design controls.
  82065. * The GUI will then rescale everything accordingly
  82066. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82067. */
  82068. get idealHeight(): number;
  82069. set idealHeight(value: number);
  82070. /**
  82071. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82072. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82073. */
  82074. get useSmallestIdeal(): boolean;
  82075. set useSmallestIdeal(value: boolean);
  82076. /**
  82077. * Gets or sets a boolean indicating if adaptive scaling must be used
  82078. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82079. */
  82080. get renderAtIdealSize(): boolean;
  82081. set renderAtIdealSize(value: boolean);
  82082. /**
  82083. * Gets the ratio used when in "ideal mode"
  82084. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82085. * */
  82086. get idealRatio(): number;
  82087. /**
  82088. * Gets the underlying layer used to render the texture when in fullscreen mode
  82089. */
  82090. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  82091. /**
  82092. * Gets the root container control
  82093. */
  82094. get rootContainer(): Container;
  82095. /**
  82096. * Returns an array containing the root container.
  82097. * This is mostly used to let the Inspector introspects the ADT
  82098. * @returns an array containing the rootContainer
  82099. */
  82100. getChildren(): Array<Container>;
  82101. /**
  82102. * Will return all controls that are inside this texture
  82103. * @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
  82104. * @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
  82105. * @return all child controls
  82106. */
  82107. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  82108. /**
  82109. * Gets or sets the current focused control
  82110. */
  82111. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  82112. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  82113. /**
  82114. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  82115. */
  82116. get isForeground(): boolean;
  82117. set isForeground(value: boolean);
  82118. /**
  82119. * Gets or set information about clipboardData
  82120. */
  82121. get clipboardData(): string;
  82122. set clipboardData(value: string);
  82123. /**
  82124. * Creates a new AdvancedDynamicTexture
  82125. * @param name defines the name of the texture
  82126. * @param width defines the width of the texture
  82127. * @param height defines the height of the texture
  82128. * @param scene defines the hosting scene
  82129. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  82130. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82131. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82132. */
  82133. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  82134. /**
  82135. * Get the current class name of the texture useful for serialization or dynamic coding.
  82136. * @returns "AdvancedDynamicTexture"
  82137. */
  82138. getClassName(): string;
  82139. /**
  82140. * Function used to execute a function on all controls
  82141. * @param func defines the function to execute
  82142. * @param container defines the container where controls belong. If null the root container will be used
  82143. */
  82144. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  82145. private _useInvalidateRectOptimization;
  82146. /**
  82147. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  82148. */
  82149. get useInvalidateRectOptimization(): boolean;
  82150. set useInvalidateRectOptimization(value: boolean);
  82151. private _invalidatedRectangle;
  82152. /**
  82153. * Invalidates a rectangle area on the gui texture
  82154. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  82155. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  82156. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  82157. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  82158. */
  82159. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  82160. /**
  82161. * Marks the texture as dirty forcing a complete update
  82162. */
  82163. markAsDirty(): void;
  82164. /**
  82165. * Helper function used to create a new style
  82166. * @returns a new style
  82167. * @see https://doc.babylonjs.com/how_to/gui#styles
  82168. */
  82169. createStyle(): Style;
  82170. /**
  82171. * Adds a new control to the root container
  82172. * @param control defines the control to add
  82173. * @returns the current texture
  82174. */
  82175. addControl(control: Control): AdvancedDynamicTexture;
  82176. /**
  82177. * Removes a control from the root container
  82178. * @param control defines the control to remove
  82179. * @returns the current texture
  82180. */
  82181. removeControl(control: Control): AdvancedDynamicTexture;
  82182. /**
  82183. * Release all resources
  82184. */
  82185. dispose(): void;
  82186. private _onResize;
  82187. /** @hidden */
  82188. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  82189. /**
  82190. * Get screen coordinates for a vector3
  82191. * @param position defines the position to project
  82192. * @param worldMatrix defines the world matrix to use
  82193. * @returns the projected position
  82194. */
  82195. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  82196. /**
  82197. * Get screen coordinates for a vector3
  82198. * @param position defines the position to project
  82199. * @param worldMatrix defines the world matrix to use
  82200. * @returns the projected position with Z
  82201. */
  82202. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  82203. private _checkUpdate;
  82204. private _clearMeasure;
  82205. private _render;
  82206. /** @hidden */
  82207. _changeCursor(cursor: string): void;
  82208. /** @hidden */
  82209. _registerLastControlDown(control: Control, pointerId: number): void;
  82210. private _doPicking;
  82211. /** @hidden */
  82212. _cleanControlAfterRemovalFromList(list: {
  82213. [pointerId: number]: Control;
  82214. }, control: Control): void;
  82215. /** @hidden */
  82216. _cleanControlAfterRemoval(control: Control): void;
  82217. /** Attach to all scene events required to support pointer events */
  82218. attach(): void;
  82219. /** @hidden */
  82220. private onClipboardCopy;
  82221. /** @hidden */
  82222. private onClipboardCut;
  82223. /** @hidden */
  82224. private onClipboardPaste;
  82225. /**
  82226. * Register the clipboard Events onto the canvas
  82227. */
  82228. registerClipboardEvents(): void;
  82229. /**
  82230. * Unregister the clipboard Events from the canvas
  82231. */
  82232. unRegisterClipboardEvents(): void;
  82233. /**
  82234. * Connect the texture to a hosting mesh to enable interactions
  82235. * @param mesh defines the mesh to attach to
  82236. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  82237. */
  82238. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  82239. /**
  82240. * Move the focus to a specific control
  82241. * @param control defines the control which will receive the focus
  82242. */
  82243. moveFocusToControl(control: IFocusableControl): void;
  82244. private _manageFocus;
  82245. private _attachToOnPointerOut;
  82246. private _attachToOnBlur;
  82247. /**
  82248. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  82249. * @param mesh defines the mesh which will receive the texture
  82250. * @param width defines the texture width (1024 by default)
  82251. * @param height defines the texture height (1024 by default)
  82252. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82253. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  82254. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82255. * @returns a new AdvancedDynamicTexture
  82256. */
  82257. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82258. /**
  82259. * 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
  82260. * @param mesh defines the mesh which will receive the texture
  82261. * @param width defines the texture width (1024 by default)
  82262. * @param height defines the texture height (1024 by default)
  82263. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82264. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82265. * @returns a new AdvancedDynamicTexture
  82266. */
  82267. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82268. /**
  82269. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  82270. * In this mode the texture will rely on a layer for its rendering.
  82271. * This allows it to be treated like any other layer.
  82272. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  82273. * LayerMask is set through advancedTexture.layer.layerMask
  82274. * @param name defines name for the texture
  82275. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  82276. * @param scene defines the hsoting scene
  82277. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  82278. * @returns a new AdvancedDynamicTexture
  82279. */
  82280. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  82281. }
  82282. }
  82283. declare module BABYLON.GUI {
  82284. /**
  82285. * Root class used for all 2D controls
  82286. * @see https://doc.babylonjs.com/how_to/gui#controls
  82287. */
  82288. export class Control {
  82289. /** defines the name of the control */
  82290. name?: string | undefined;
  82291. /**
  82292. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  82293. */
  82294. static AllowAlphaInheritance: boolean;
  82295. private _alpha;
  82296. private _alphaSet;
  82297. private _zIndex;
  82298. /** @hidden */
  82299. _host: AdvancedDynamicTexture;
  82300. /** Gets or sets the control parent */
  82301. parent: BABYLON.Nullable<Container>;
  82302. /** @hidden */
  82303. _currentMeasure: Measure;
  82304. private _fontFamily;
  82305. private _fontStyle;
  82306. private _fontWeight;
  82307. private _fontSize;
  82308. private _font;
  82309. /** @hidden */
  82310. _width: ValueAndUnit;
  82311. /** @hidden */
  82312. _height: ValueAndUnit;
  82313. /** @hidden */
  82314. protected _fontOffset: {
  82315. ascent: number;
  82316. height: number;
  82317. descent: number;
  82318. };
  82319. private _color;
  82320. private _style;
  82321. private _styleObserver;
  82322. /** @hidden */
  82323. protected _horizontalAlignment: number;
  82324. /** @hidden */
  82325. protected _verticalAlignment: number;
  82326. /** @hidden */
  82327. protected _isDirty: boolean;
  82328. /** @hidden */
  82329. protected _wasDirty: boolean;
  82330. /** @hidden */
  82331. _tempParentMeasure: Measure;
  82332. /** @hidden */
  82333. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  82334. /** @hidden */
  82335. protected _cachedParentMeasure: Measure;
  82336. private _paddingLeft;
  82337. private _paddingRight;
  82338. private _paddingTop;
  82339. private _paddingBottom;
  82340. /** @hidden */
  82341. _left: ValueAndUnit;
  82342. /** @hidden */
  82343. _top: ValueAndUnit;
  82344. private _scaleX;
  82345. private _scaleY;
  82346. private _rotation;
  82347. private _transformCenterX;
  82348. private _transformCenterY;
  82349. /** @hidden */
  82350. _transformMatrix: Matrix2D;
  82351. /** @hidden */
  82352. protected _invertTransformMatrix: Matrix2D;
  82353. /** @hidden */
  82354. protected _transformedPosition: BABYLON.Vector2;
  82355. private _isMatrixDirty;
  82356. private _cachedOffsetX;
  82357. private _cachedOffsetY;
  82358. private _isVisible;
  82359. private _isHighlighted;
  82360. /** @hidden */
  82361. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  82362. private _fontSet;
  82363. private _dummyVector2;
  82364. private _downCount;
  82365. private _enterCount;
  82366. private _doNotRender;
  82367. private _downPointerIds;
  82368. protected _isEnabled: boolean;
  82369. protected _disabledColor: string;
  82370. protected _disabledColorItem: string;
  82371. /** @hidden */
  82372. protected _rebuildLayout: boolean;
  82373. /** @hidden */
  82374. _customData: any;
  82375. /** @hidden */
  82376. _isClipped: boolean;
  82377. /** @hidden */
  82378. _automaticSize: boolean;
  82379. /** @hidden */
  82380. _tag: any;
  82381. /**
  82382. * 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
  82383. */
  82384. uniqueId: number;
  82385. /**
  82386. * Gets or sets an object used to store user defined information for the node
  82387. */
  82388. metadata: any;
  82389. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  82390. isHitTestVisible: boolean;
  82391. /** Gets or sets a boolean indicating if the control can block pointer events */
  82392. isPointerBlocker: boolean;
  82393. /** Gets or sets a boolean indicating if the control can be focusable */
  82394. isFocusInvisible: boolean;
  82395. /**
  82396. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  82397. * 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
  82398. */
  82399. clipChildren: boolean;
  82400. /**
  82401. * Gets or sets a boolean indicating that control content must be clipped
  82402. * 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
  82403. */
  82404. clipContent: boolean;
  82405. /**
  82406. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  82407. */
  82408. useBitmapCache: boolean;
  82409. private _cacheData;
  82410. private _shadowOffsetX;
  82411. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  82412. get shadowOffsetX(): number;
  82413. set shadowOffsetX(value: number);
  82414. private _shadowOffsetY;
  82415. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  82416. get shadowOffsetY(): number;
  82417. set shadowOffsetY(value: number);
  82418. private _shadowBlur;
  82419. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  82420. get shadowBlur(): number;
  82421. set shadowBlur(value: number);
  82422. private _shadowColor;
  82423. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  82424. get shadowColor(): string;
  82425. set shadowColor(value: string);
  82426. /** Gets or sets the cursor to use when the control is hovered */
  82427. hoverCursor: string;
  82428. /** @hidden */
  82429. protected _linkOffsetX: ValueAndUnit;
  82430. /** @hidden */
  82431. protected _linkOffsetY: ValueAndUnit;
  82432. /** Gets the control type name */
  82433. get typeName(): string;
  82434. /**
  82435. * Get the current class name of the control.
  82436. * @returns current class name
  82437. */
  82438. getClassName(): string;
  82439. /**
  82440. * An event triggered when pointer wheel is scrolled
  82441. */
  82442. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  82443. /**
  82444. * An event triggered when the pointer move over the control.
  82445. */
  82446. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  82447. /**
  82448. * An event triggered when the pointer move out of the control.
  82449. */
  82450. onPointerOutObservable: BABYLON.Observable<Control>;
  82451. /**
  82452. * An event triggered when the pointer taps the control
  82453. */
  82454. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  82455. /**
  82456. * An event triggered when pointer up
  82457. */
  82458. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  82459. /**
  82460. * An event triggered when a control is clicked on
  82461. */
  82462. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  82463. /**
  82464. * An event triggered when pointer enters the control
  82465. */
  82466. onPointerEnterObservable: BABYLON.Observable<Control>;
  82467. /**
  82468. * An event triggered when the control is marked as dirty
  82469. */
  82470. onDirtyObservable: BABYLON.Observable<Control>;
  82471. /**
  82472. * An event triggered before drawing the control
  82473. */
  82474. onBeforeDrawObservable: BABYLON.Observable<Control>;
  82475. /**
  82476. * An event triggered after the control was drawn
  82477. */
  82478. onAfterDrawObservable: BABYLON.Observable<Control>;
  82479. /**
  82480. * An event triggered when the control has been disposed
  82481. */
  82482. onDisposeObservable: BABYLON.Observable<Control>;
  82483. /**
  82484. * Get the hosting AdvancedDynamicTexture
  82485. */
  82486. get host(): AdvancedDynamicTexture;
  82487. /** Gets or set information about font offsets (used to render and align text) */
  82488. get fontOffset(): {
  82489. ascent: number;
  82490. height: number;
  82491. descent: number;
  82492. };
  82493. set fontOffset(offset: {
  82494. ascent: number;
  82495. height: number;
  82496. descent: number;
  82497. });
  82498. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  82499. get alpha(): number;
  82500. set alpha(value: number);
  82501. /**
  82502. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  82503. */
  82504. get isHighlighted(): boolean;
  82505. set isHighlighted(value: boolean);
  82506. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  82507. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82508. */
  82509. get scaleX(): number;
  82510. set scaleX(value: number);
  82511. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  82512. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82513. */
  82514. get scaleY(): number;
  82515. set scaleY(value: number);
  82516. /** Gets or sets the rotation angle (0 by default)
  82517. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82518. */
  82519. get rotation(): number;
  82520. set rotation(value: number);
  82521. /** Gets or sets the transformation center on Y axis (0 by default)
  82522. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82523. */
  82524. get transformCenterY(): number;
  82525. set transformCenterY(value: number);
  82526. /** Gets or sets the transformation center on X axis (0 by default)
  82527. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82528. */
  82529. get transformCenterX(): number;
  82530. set transformCenterX(value: number);
  82531. /**
  82532. * Gets or sets the horizontal alignment
  82533. * @see https://doc.babylonjs.com/how_to/gui#alignments
  82534. */
  82535. get horizontalAlignment(): number;
  82536. set horizontalAlignment(value: number);
  82537. /**
  82538. * Gets or sets the vertical alignment
  82539. * @see https://doc.babylonjs.com/how_to/gui#alignments
  82540. */
  82541. get verticalAlignment(): number;
  82542. set verticalAlignment(value: number);
  82543. /**
  82544. * Gets or sets a fixed ratio for this control.
  82545. * When different from 0, the ratio is used to compute the "second" dimension.
  82546. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  82547. * second dimension is computed as first dimension * fixedRatio
  82548. */
  82549. fixedRatio: number;
  82550. private _fixedRatioMasterIsWidth;
  82551. /**
  82552. * Gets or sets control width
  82553. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82554. */
  82555. get width(): string | number;
  82556. set width(value: string | number);
  82557. /**
  82558. * Gets or sets the control width in pixel
  82559. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82560. */
  82561. get widthInPixels(): number;
  82562. set widthInPixels(value: number);
  82563. /**
  82564. * Gets or sets control height
  82565. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82566. */
  82567. get height(): string | number;
  82568. set height(value: string | number);
  82569. /**
  82570. * Gets or sets control height in pixel
  82571. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82572. */
  82573. get heightInPixels(): number;
  82574. set heightInPixels(value: number);
  82575. /** Gets or set font family */
  82576. get fontFamily(): string;
  82577. set fontFamily(value: string);
  82578. /** Gets or sets font style */
  82579. get fontStyle(): string;
  82580. set fontStyle(value: string);
  82581. /** Gets or sets font weight */
  82582. get fontWeight(): string;
  82583. set fontWeight(value: string);
  82584. /**
  82585. * Gets or sets style
  82586. * @see https://doc.babylonjs.com/how_to/gui#styles
  82587. */
  82588. get style(): BABYLON.Nullable<Style>;
  82589. set style(value: BABYLON.Nullable<Style>);
  82590. /** @hidden */
  82591. get _isFontSizeInPercentage(): boolean;
  82592. /** Gets or sets font size in pixels */
  82593. get fontSizeInPixels(): number;
  82594. set fontSizeInPixels(value: number);
  82595. /** Gets or sets font size */
  82596. get fontSize(): string | number;
  82597. set fontSize(value: string | number);
  82598. /** Gets or sets foreground color */
  82599. get color(): string;
  82600. set color(value: string);
  82601. /** Gets or sets z index which is used to reorder controls on the z axis */
  82602. get zIndex(): number;
  82603. set zIndex(value: number);
  82604. /** Gets or sets a boolean indicating if the control can be rendered */
  82605. get notRenderable(): boolean;
  82606. set notRenderable(value: boolean);
  82607. /** Gets or sets a boolean indicating if the control is visible */
  82608. get isVisible(): boolean;
  82609. set isVisible(value: boolean);
  82610. /** Gets a boolean indicating that the control needs to update its rendering */
  82611. get isDirty(): boolean;
  82612. /**
  82613. * Gets the current linked mesh (or null if none)
  82614. */
  82615. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  82616. /**
  82617. * Gets or sets a value indicating the padding to use on the left of the control
  82618. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82619. */
  82620. get paddingLeft(): string | number;
  82621. set paddingLeft(value: string | number);
  82622. /**
  82623. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  82624. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82625. */
  82626. get paddingLeftInPixels(): number;
  82627. set paddingLeftInPixels(value: number);
  82628. /**
  82629. * Gets or sets a value indicating the padding to use on the right of the control
  82630. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82631. */
  82632. get paddingRight(): string | number;
  82633. set paddingRight(value: string | number);
  82634. /**
  82635. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  82636. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82637. */
  82638. get paddingRightInPixels(): number;
  82639. set paddingRightInPixels(value: number);
  82640. /**
  82641. * Gets or sets a value indicating the padding to use on the top of the control
  82642. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82643. */
  82644. get paddingTop(): string | number;
  82645. set paddingTop(value: string | number);
  82646. /**
  82647. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  82648. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82649. */
  82650. get paddingTopInPixels(): number;
  82651. set paddingTopInPixels(value: number);
  82652. /**
  82653. * Gets or sets a value indicating the padding to use on the bottom of the control
  82654. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82655. */
  82656. get paddingBottom(): string | number;
  82657. set paddingBottom(value: string | number);
  82658. /**
  82659. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  82660. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82661. */
  82662. get paddingBottomInPixels(): number;
  82663. set paddingBottomInPixels(value: number);
  82664. /**
  82665. * Gets or sets a value indicating the left coordinate of the control
  82666. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82667. */
  82668. get left(): string | number;
  82669. set left(value: string | number);
  82670. /**
  82671. * Gets or sets a value indicating the left coordinate in pixels of the control
  82672. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82673. */
  82674. get leftInPixels(): number;
  82675. set leftInPixels(value: number);
  82676. /**
  82677. * Gets or sets a value indicating the top coordinate of the control
  82678. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82679. */
  82680. get top(): string | number;
  82681. set top(value: string | number);
  82682. /**
  82683. * Gets or sets a value indicating the top coordinate in pixels of the control
  82684. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82685. */
  82686. get topInPixels(): number;
  82687. set topInPixels(value: number);
  82688. /**
  82689. * Gets or sets a value indicating the offset on X axis to the linked mesh
  82690. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82691. */
  82692. get linkOffsetX(): string | number;
  82693. set linkOffsetX(value: string | number);
  82694. /**
  82695. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  82696. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82697. */
  82698. get linkOffsetXInPixels(): number;
  82699. set linkOffsetXInPixels(value: number);
  82700. /**
  82701. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  82702. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82703. */
  82704. get linkOffsetY(): string | number;
  82705. set linkOffsetY(value: string | number);
  82706. /**
  82707. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  82708. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82709. */
  82710. get linkOffsetYInPixels(): number;
  82711. set linkOffsetYInPixels(value: number);
  82712. /** Gets the center coordinate on X axis */
  82713. get centerX(): number;
  82714. /** Gets the center coordinate on Y axis */
  82715. get centerY(): number;
  82716. /** Gets or sets if control is Enabled*/
  82717. get isEnabled(): boolean;
  82718. set isEnabled(value: boolean);
  82719. /** Gets or sets background color of control if it's disabled*/
  82720. get disabledColor(): string;
  82721. set disabledColor(value: string);
  82722. /** Gets or sets front color of control if it's disabled*/
  82723. get disabledColorItem(): string;
  82724. set disabledColorItem(value: string);
  82725. /**
  82726. * Creates a new control
  82727. * @param name defines the name of the control
  82728. */
  82729. constructor(
  82730. /** defines the name of the control */
  82731. name?: string | undefined);
  82732. /** @hidden */
  82733. protected _getTypeName(): string;
  82734. /**
  82735. * Gets the first ascendant in the hierarchy of the given type
  82736. * @param className defines the required type
  82737. * @returns the ascendant or null if not found
  82738. */
  82739. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  82740. /** @hidden */
  82741. _resetFontCache(): void;
  82742. /**
  82743. * Determines if a container is an ascendant of the current control
  82744. * @param container defines the container to look for
  82745. * @returns true if the container is one of the ascendant of the control
  82746. */
  82747. isAscendant(container: Control): boolean;
  82748. /**
  82749. * Gets coordinates in local control space
  82750. * @param globalCoordinates defines the coordinates to transform
  82751. * @returns the new coordinates in local space
  82752. */
  82753. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  82754. /**
  82755. * Gets coordinates in local control space
  82756. * @param globalCoordinates defines the coordinates to transform
  82757. * @param result defines the target vector2 where to store the result
  82758. * @returns the current control
  82759. */
  82760. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  82761. /**
  82762. * Gets coordinates in parent local control space
  82763. * @param globalCoordinates defines the coordinates to transform
  82764. * @returns the new coordinates in parent local space
  82765. */
  82766. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  82767. /**
  82768. * Move the current control to a vector3 position projected onto the screen.
  82769. * @param position defines the target position
  82770. * @param scene defines the hosting scene
  82771. */
  82772. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  82773. /**
  82774. * Will store all controls that have this control as ascendant in a given array
  82775. * @param results defines the array where to store the descendants
  82776. * @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
  82777. * @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
  82778. */
  82779. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  82780. /**
  82781. * Will return all controls that have this control as ascendant
  82782. * @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
  82783. * @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
  82784. * @return all child controls
  82785. */
  82786. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  82787. /**
  82788. * Link current control with a target mesh
  82789. * @param mesh defines the mesh to link with
  82790. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82791. */
  82792. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  82793. /** @hidden */
  82794. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  82795. /** @hidden */
  82796. _offsetLeft(offset: number): void;
  82797. /** @hidden */
  82798. _offsetTop(offset: number): void;
  82799. /** @hidden */
  82800. _markMatrixAsDirty(): void;
  82801. /** @hidden */
  82802. _flagDescendantsAsMatrixDirty(): void;
  82803. /** @hidden */
  82804. _intersectsRect(rect: Measure): boolean;
  82805. /** @hidden */
  82806. protected invalidateRect(): void;
  82807. /** @hidden */
  82808. _markAsDirty(force?: boolean): void;
  82809. /** @hidden */
  82810. _markAllAsDirty(): void;
  82811. /** @hidden */
  82812. _link(host: AdvancedDynamicTexture): void;
  82813. /** @hidden */
  82814. protected _transform(context?: CanvasRenderingContext2D): void;
  82815. /** @hidden */
  82816. _renderHighlight(context: CanvasRenderingContext2D): void;
  82817. /** @hidden */
  82818. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  82819. /** @hidden */
  82820. protected _applyStates(context: CanvasRenderingContext2D): void;
  82821. /** @hidden */
  82822. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  82823. /** @hidden */
  82824. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  82825. protected _evaluateClippingState(parentMeasure: Measure): void;
  82826. /** @hidden */
  82827. _measure(): void;
  82828. /** @hidden */
  82829. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  82830. /** @hidden */
  82831. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  82832. /** @hidden */
  82833. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  82834. /** @hidden */
  82835. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  82836. private static _ClipMeasure;
  82837. private _tmpMeasureA;
  82838. private _clip;
  82839. /** @hidden */
  82840. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  82841. /** @hidden */
  82842. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  82843. /**
  82844. * Tests if a given coordinates belong to the current control
  82845. * @param x defines x coordinate to test
  82846. * @param y defines y coordinate to test
  82847. * @returns true if the coordinates are inside the control
  82848. */
  82849. contains(x: number, y: number): boolean;
  82850. /** @hidden */
  82851. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  82852. /** @hidden */
  82853. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  82854. /** @hidden */
  82855. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  82856. /** @hidden */
  82857. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  82858. /** @hidden */
  82859. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  82860. /** @hidden */
  82861. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  82862. /** @hidden */
  82863. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  82864. /** @hidden */
  82865. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  82866. /** @hidden */
  82867. _onCanvasBlur(): void;
  82868. /** @hidden */
  82869. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  82870. private _prepareFont;
  82871. /** Releases associated resources */
  82872. dispose(): void;
  82873. private static _HORIZONTAL_ALIGNMENT_LEFT;
  82874. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  82875. private static _HORIZONTAL_ALIGNMENT_CENTER;
  82876. private static _VERTICAL_ALIGNMENT_TOP;
  82877. private static _VERTICAL_ALIGNMENT_BOTTOM;
  82878. private static _VERTICAL_ALIGNMENT_CENTER;
  82879. /** HORIZONTAL_ALIGNMENT_LEFT */
  82880. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  82881. /** HORIZONTAL_ALIGNMENT_RIGHT */
  82882. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  82883. /** HORIZONTAL_ALIGNMENT_CENTER */
  82884. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  82885. /** VERTICAL_ALIGNMENT_TOP */
  82886. static get VERTICAL_ALIGNMENT_TOP(): number;
  82887. /** VERTICAL_ALIGNMENT_BOTTOM */
  82888. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  82889. /** VERTICAL_ALIGNMENT_CENTER */
  82890. static get VERTICAL_ALIGNMENT_CENTER(): number;
  82891. private static _FontHeightSizes;
  82892. /** @hidden */
  82893. static _GetFontOffset(font: string): {
  82894. ascent: number;
  82895. height: number;
  82896. descent: number;
  82897. };
  82898. /**
  82899. * Creates a stack panel that can be used to render headers
  82900. * @param control defines the control to associate with the header
  82901. * @param text defines the text of the header
  82902. * @param size defines the size of the header
  82903. * @param options defines options used to configure the header
  82904. * @returns a new StackPanel
  82905. * @ignore
  82906. * @hidden
  82907. */
  82908. static AddHeader: (control: Control, text: string, size: string | number, options: {
  82909. isHorizontal: boolean;
  82910. controlFirst: boolean;
  82911. }) => any;
  82912. /** @hidden */
  82913. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  82914. }
  82915. }
  82916. declare module BABYLON.GUI {
  82917. /**
  82918. * Root class for 2D containers
  82919. * @see https://doc.babylonjs.com/how_to/gui#containers
  82920. */
  82921. export class Container extends Control {
  82922. name?: string | undefined;
  82923. /** @hidden */
  82924. _children: Control[];
  82925. /** @hidden */
  82926. protected _measureForChildren: Measure;
  82927. /** @hidden */
  82928. protected _background: string;
  82929. /** @hidden */
  82930. protected _adaptWidthToChildren: boolean;
  82931. /** @hidden */
  82932. protected _adaptHeightToChildren: boolean;
  82933. /**
  82934. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  82935. */
  82936. logLayoutCycleErrors: boolean;
  82937. /**
  82938. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  82939. */
  82940. maxLayoutCycle: number;
  82941. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  82942. get adaptHeightToChildren(): boolean;
  82943. set adaptHeightToChildren(value: boolean);
  82944. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  82945. get adaptWidthToChildren(): boolean;
  82946. set adaptWidthToChildren(value: boolean);
  82947. /** Gets or sets background color */
  82948. get background(): string;
  82949. set background(value: string);
  82950. /** Gets the list of children */
  82951. get children(): Control[];
  82952. /**
  82953. * Creates a new Container
  82954. * @param name defines the name of the container
  82955. */
  82956. constructor(name?: string | undefined);
  82957. protected _getTypeName(): string;
  82958. _flagDescendantsAsMatrixDirty(): void;
  82959. /**
  82960. * Gets a child using its name
  82961. * @param name defines the child name to look for
  82962. * @returns the child control if found
  82963. */
  82964. getChildByName(name: string): BABYLON.Nullable<Control>;
  82965. /**
  82966. * Gets a child using its type and its name
  82967. * @param name defines the child name to look for
  82968. * @param type defines the child type to look for
  82969. * @returns the child control if found
  82970. */
  82971. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  82972. /**
  82973. * Search for a specific control in children
  82974. * @param control defines the control to look for
  82975. * @returns true if the control is in child list
  82976. */
  82977. containsControl(control: Control): boolean;
  82978. /**
  82979. * Adds a new control to the current container
  82980. * @param control defines the control to add
  82981. * @returns the current container
  82982. */
  82983. addControl(control: BABYLON.Nullable<Control>): Container;
  82984. /**
  82985. * Removes all controls from the current container
  82986. * @returns the current container
  82987. */
  82988. clearControls(): Container;
  82989. /**
  82990. * Removes a control from the current container
  82991. * @param control defines the control to remove
  82992. * @returns the current container
  82993. */
  82994. removeControl(control: Control): Container;
  82995. /** @hidden */
  82996. _reOrderControl(control: Control): void;
  82997. /** @hidden */
  82998. _offsetLeft(offset: number): void;
  82999. /** @hidden */
  83000. _offsetTop(offset: number): void;
  83001. /** @hidden */
  83002. _markAllAsDirty(): void;
  83003. /** @hidden */
  83004. protected _localDraw(context: CanvasRenderingContext2D): void;
  83005. /** @hidden */
  83006. _link(host: AdvancedDynamicTexture): void;
  83007. /** @hidden */
  83008. protected _beforeLayout(): void;
  83009. /** @hidden */
  83010. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83011. /** @hidden */
  83012. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83013. protected _postMeasure(): void;
  83014. /** @hidden */
  83015. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83016. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83017. /** @hidden */
  83018. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83019. /** @hidden */
  83020. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83021. /** Releases associated resources */
  83022. dispose(): void;
  83023. }
  83024. }
  83025. declare module BABYLON.GUI {
  83026. /** Class used to create rectangle container */
  83027. export class Rectangle extends Container {
  83028. name?: string | undefined;
  83029. private _thickness;
  83030. private _cornerRadius;
  83031. /** Gets or sets border thickness */
  83032. get thickness(): number;
  83033. set thickness(value: number);
  83034. /** Gets or sets the corner radius angle */
  83035. get cornerRadius(): number;
  83036. set cornerRadius(value: number);
  83037. /**
  83038. * Creates a new Rectangle
  83039. * @param name defines the control name
  83040. */
  83041. constructor(name?: string | undefined);
  83042. protected _getTypeName(): string;
  83043. protected _localDraw(context: CanvasRenderingContext2D): void;
  83044. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83045. private _drawRoundedRect;
  83046. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83047. }
  83048. }
  83049. declare module BABYLON.GUI {
  83050. /**
  83051. * Enum that determines the text-wrapping mode to use.
  83052. */
  83053. export enum TextWrapping {
  83054. /**
  83055. * Clip the text when it's larger than Control.width; this is the default mode.
  83056. */
  83057. Clip = 0,
  83058. /**
  83059. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  83060. */
  83061. WordWrap = 1,
  83062. /**
  83063. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  83064. */
  83065. Ellipsis = 2
  83066. }
  83067. /**
  83068. * Class used to create text block control
  83069. */
  83070. export class TextBlock extends Control {
  83071. /**
  83072. * Defines the name of the control
  83073. */
  83074. name?: string | undefined;
  83075. private _text;
  83076. private _textWrapping;
  83077. private _textHorizontalAlignment;
  83078. private _textVerticalAlignment;
  83079. private _lines;
  83080. private _resizeToFit;
  83081. private _lineSpacing;
  83082. private _outlineWidth;
  83083. private _outlineColor;
  83084. private _underline;
  83085. private _lineThrough;
  83086. /**
  83087. * An event triggered after the text is changed
  83088. */
  83089. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  83090. /**
  83091. * An event triggered after the text was broken up into lines
  83092. */
  83093. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  83094. /**
  83095. * Function used to split a string into words. By default, a string is split at each space character found
  83096. */
  83097. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  83098. /**
  83099. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  83100. */
  83101. get lines(): any[];
  83102. /**
  83103. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83104. */
  83105. get resizeToFit(): boolean;
  83106. /**
  83107. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83108. */
  83109. set resizeToFit(value: boolean);
  83110. /**
  83111. * Gets or sets a boolean indicating if text must be wrapped
  83112. */
  83113. get textWrapping(): TextWrapping | boolean;
  83114. /**
  83115. * Gets or sets a boolean indicating if text must be wrapped
  83116. */
  83117. set textWrapping(value: TextWrapping | boolean);
  83118. /**
  83119. * Gets or sets text to display
  83120. */
  83121. get text(): string;
  83122. /**
  83123. * Gets or sets text to display
  83124. */
  83125. set text(value: string);
  83126. /**
  83127. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83128. */
  83129. get textHorizontalAlignment(): number;
  83130. /**
  83131. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83132. */
  83133. set textHorizontalAlignment(value: number);
  83134. /**
  83135. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83136. */
  83137. get textVerticalAlignment(): number;
  83138. /**
  83139. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83140. */
  83141. set textVerticalAlignment(value: number);
  83142. /**
  83143. * Gets or sets line spacing value
  83144. */
  83145. set lineSpacing(value: string | number);
  83146. /**
  83147. * Gets or sets line spacing value
  83148. */
  83149. get lineSpacing(): string | number;
  83150. /**
  83151. * Gets or sets outlineWidth of the text to display
  83152. */
  83153. get outlineWidth(): number;
  83154. /**
  83155. * Gets or sets outlineWidth of the text to display
  83156. */
  83157. set outlineWidth(value: number);
  83158. /**
  83159. * Gets or sets a boolean indicating that text must have underline
  83160. */
  83161. get underline(): boolean;
  83162. /**
  83163. * Gets or sets a boolean indicating that text must have underline
  83164. */
  83165. set underline(value: boolean);
  83166. /**
  83167. * Gets or sets an boolean indicating that text must be crossed out
  83168. */
  83169. get lineThrough(): boolean;
  83170. /**
  83171. * Gets or sets an boolean indicating that text must be crossed out
  83172. */
  83173. set lineThrough(value: boolean);
  83174. /**
  83175. * Gets or sets outlineColor of the text to display
  83176. */
  83177. get outlineColor(): string;
  83178. /**
  83179. * Gets or sets outlineColor of the text to display
  83180. */
  83181. set outlineColor(value: string);
  83182. /**
  83183. * Creates a new TextBlock object
  83184. * @param name defines the name of the control
  83185. * @param text defines the text to display (emptry string by default)
  83186. */
  83187. constructor(
  83188. /**
  83189. * Defines the name of the control
  83190. */
  83191. name?: string | undefined, text?: string);
  83192. protected _getTypeName(): string;
  83193. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83194. private _drawText;
  83195. /** @hidden */
  83196. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83197. protected _applyStates(context: CanvasRenderingContext2D): void;
  83198. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  83199. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  83200. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  83201. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  83202. protected _renderLines(context: CanvasRenderingContext2D): void;
  83203. /**
  83204. * Given a width constraint applied on the text block, find the expected height
  83205. * @returns expected height
  83206. */
  83207. computeExpectedHeight(): number;
  83208. dispose(): void;
  83209. }
  83210. }
  83211. declare module BABYLON.GUI {
  83212. /**
  83213. * Class used to create 2D images
  83214. */
  83215. export class Image extends Control {
  83216. name?: string | undefined;
  83217. private _workingCanvas;
  83218. private _domImage;
  83219. private _imageWidth;
  83220. private _imageHeight;
  83221. private _loaded;
  83222. private _stretch;
  83223. private _source;
  83224. private _autoScale;
  83225. private _sourceLeft;
  83226. private _sourceTop;
  83227. private _sourceWidth;
  83228. private _sourceHeight;
  83229. private _svgAttributesComputationCompleted;
  83230. private _isSVG;
  83231. private _cellWidth;
  83232. private _cellHeight;
  83233. private _cellId;
  83234. private _populateNinePatchSlicesFromImage;
  83235. private _sliceLeft;
  83236. private _sliceRight;
  83237. private _sliceTop;
  83238. private _sliceBottom;
  83239. private _detectPointerOnOpaqueOnly;
  83240. private _imageDataCache;
  83241. /**
  83242. * BABYLON.Observable notified when the content is loaded
  83243. */
  83244. onImageLoadedObservable: BABYLON.Observable<Image>;
  83245. /**
  83246. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  83247. */
  83248. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  83249. /**
  83250. * Gets a boolean indicating that the content is loaded
  83251. */
  83252. get isLoaded(): boolean;
  83253. /**
  83254. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  83255. */
  83256. get populateNinePatchSlicesFromImage(): boolean;
  83257. set populateNinePatchSlicesFromImage(value: boolean);
  83258. /**
  83259. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  83260. * Beware using this as this will comsume more memory as the image has to be stored twice
  83261. */
  83262. get detectPointerOnOpaqueOnly(): boolean;
  83263. set detectPointerOnOpaqueOnly(value: boolean);
  83264. /**
  83265. * Gets or sets the left value for slicing (9-patch)
  83266. */
  83267. get sliceLeft(): number;
  83268. set sliceLeft(value: number);
  83269. /**
  83270. * Gets or sets the right value for slicing (9-patch)
  83271. */
  83272. get sliceRight(): number;
  83273. set sliceRight(value: number);
  83274. /**
  83275. * Gets or sets the top value for slicing (9-patch)
  83276. */
  83277. get sliceTop(): number;
  83278. set sliceTop(value: number);
  83279. /**
  83280. * Gets or sets the bottom value for slicing (9-patch)
  83281. */
  83282. get sliceBottom(): number;
  83283. set sliceBottom(value: number);
  83284. /**
  83285. * Gets or sets the left coordinate in the source image
  83286. */
  83287. get sourceLeft(): number;
  83288. set sourceLeft(value: number);
  83289. /**
  83290. * Gets or sets the top coordinate in the source image
  83291. */
  83292. get sourceTop(): number;
  83293. set sourceTop(value: number);
  83294. /**
  83295. * Gets or sets the width to capture in the source image
  83296. */
  83297. get sourceWidth(): number;
  83298. set sourceWidth(value: number);
  83299. /**
  83300. * Gets or sets the height to capture in the source image
  83301. */
  83302. get sourceHeight(): number;
  83303. set sourceHeight(value: number);
  83304. /** Indicates if the format of the image is SVG */
  83305. get isSVG(): boolean;
  83306. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  83307. get svgAttributesComputationCompleted(): boolean;
  83308. /**
  83309. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  83310. * @see https://doc.babylonjs.com/how_to/gui#image
  83311. */
  83312. get autoScale(): boolean;
  83313. set autoScale(value: boolean);
  83314. /** Gets or sets the streching mode used by the image */
  83315. get stretch(): number;
  83316. set stretch(value: number);
  83317. /** @hidden */
  83318. _rotate90(n: number, preserveProperties?: boolean): Image;
  83319. private _handleRotationForSVGImage;
  83320. private _rotate90SourceProperties;
  83321. /**
  83322. * Gets or sets the internal DOM image used to render the control
  83323. */
  83324. set domImage(value: HTMLImageElement);
  83325. get domImage(): HTMLImageElement;
  83326. private _onImageLoaded;
  83327. private _extractNinePatchSliceDataFromImage;
  83328. /**
  83329. * Gets or sets image source url
  83330. */
  83331. set source(value: BABYLON.Nullable<string>);
  83332. /**
  83333. * Checks for svg document with icon id present
  83334. */
  83335. private _svgCheck;
  83336. /**
  83337. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  83338. * given external svg file and icon id
  83339. */
  83340. private _getSVGAttribs;
  83341. /**
  83342. * Gets or sets the cell width to use when animation sheet is enabled
  83343. * @see https://doc.babylonjs.com/how_to/gui#image
  83344. */
  83345. get cellWidth(): number;
  83346. set cellWidth(value: number);
  83347. /**
  83348. * Gets or sets the cell height to use when animation sheet is enabled
  83349. * @see https://doc.babylonjs.com/how_to/gui#image
  83350. */
  83351. get cellHeight(): number;
  83352. set cellHeight(value: number);
  83353. /**
  83354. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  83355. * @see https://doc.babylonjs.com/how_to/gui#image
  83356. */
  83357. get cellId(): number;
  83358. set cellId(value: number);
  83359. /**
  83360. * Creates a new Image
  83361. * @param name defines the control name
  83362. * @param url defines the image url
  83363. */
  83364. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  83365. /**
  83366. * Tests if a given coordinates belong to the current control
  83367. * @param x defines x coordinate to test
  83368. * @param y defines y coordinate to test
  83369. * @returns true if the coordinates are inside the control
  83370. */
  83371. contains(x: number, y: number): boolean;
  83372. protected _getTypeName(): string;
  83373. /** Force the control to synchronize with its content */
  83374. synchronizeSizeWithContent(): void;
  83375. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83376. private _prepareWorkingCanvasForOpaqueDetection;
  83377. private _drawImage;
  83378. _draw(context: CanvasRenderingContext2D): void;
  83379. private _renderCornerPatch;
  83380. private _renderNinePatch;
  83381. dispose(): void;
  83382. /** STRETCH_NONE */
  83383. static readonly STRETCH_NONE: number;
  83384. /** STRETCH_FILL */
  83385. static readonly STRETCH_FILL: number;
  83386. /** STRETCH_UNIFORM */
  83387. static readonly STRETCH_UNIFORM: number;
  83388. /** STRETCH_EXTEND */
  83389. static readonly STRETCH_EXTEND: number;
  83390. /** NINE_PATCH */
  83391. static readonly STRETCH_NINE_PATCH: number;
  83392. }
  83393. }
  83394. declare module BABYLON.GUI {
  83395. /**
  83396. * Class used to create 2D buttons
  83397. */
  83398. export class Button extends Rectangle {
  83399. name?: string | undefined;
  83400. /**
  83401. * Function called to generate a pointer enter animation
  83402. */
  83403. pointerEnterAnimation: () => void;
  83404. /**
  83405. * Function called to generate a pointer out animation
  83406. */
  83407. pointerOutAnimation: () => void;
  83408. /**
  83409. * Function called to generate a pointer down animation
  83410. */
  83411. pointerDownAnimation: () => void;
  83412. /**
  83413. * Function called to generate a pointer up animation
  83414. */
  83415. pointerUpAnimation: () => void;
  83416. /**
  83417. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  83418. */
  83419. delegatePickingToChildren: boolean;
  83420. private _image;
  83421. /**
  83422. * Returns the image part of the button (if any)
  83423. */
  83424. get image(): BABYLON.Nullable<Image>;
  83425. private _textBlock;
  83426. /**
  83427. * Returns the image part of the button (if any)
  83428. */
  83429. get textBlock(): BABYLON.Nullable<TextBlock>;
  83430. /**
  83431. * Creates a new Button
  83432. * @param name defines the name of the button
  83433. */
  83434. constructor(name?: string | undefined);
  83435. protected _getTypeName(): string;
  83436. /** @hidden */
  83437. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83438. /** @hidden */
  83439. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83440. /** @hidden */
  83441. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  83442. /** @hidden */
  83443. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83444. /** @hidden */
  83445. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  83446. /**
  83447. * Creates a new button made with an image and a text
  83448. * @param name defines the name of the button
  83449. * @param text defines the text of the button
  83450. * @param imageUrl defines the url of the image
  83451. * @returns a new Button
  83452. */
  83453. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  83454. /**
  83455. * Creates a new button made with an image
  83456. * @param name defines the name of the button
  83457. * @param imageUrl defines the url of the image
  83458. * @returns a new Button
  83459. */
  83460. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  83461. /**
  83462. * Creates a new button made with a text
  83463. * @param name defines the name of the button
  83464. * @param text defines the text of the button
  83465. * @returns a new Button
  83466. */
  83467. static CreateSimpleButton(name: string, text: string): Button;
  83468. /**
  83469. * Creates a new button made with an image and a centered text
  83470. * @param name defines the name of the button
  83471. * @param text defines the text of the button
  83472. * @param imageUrl defines the url of the image
  83473. * @returns a new Button
  83474. */
  83475. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  83476. }
  83477. }
  83478. declare module BABYLON.GUI {
  83479. /**
  83480. * Class used to create a 2D stack panel container
  83481. */
  83482. export class StackPanel extends Container {
  83483. name?: string | undefined;
  83484. private _isVertical;
  83485. private _manualWidth;
  83486. private _manualHeight;
  83487. private _doNotTrackManualChanges;
  83488. /**
  83489. * Gets or sets a boolean indicating that layou warnings should be ignored
  83490. */
  83491. ignoreLayoutWarnings: boolean;
  83492. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  83493. get isVertical(): boolean;
  83494. set isVertical(value: boolean);
  83495. /**
  83496. * Gets or sets panel width.
  83497. * This value should not be set when in horizontal mode as it will be computed automatically
  83498. */
  83499. set width(value: string | number);
  83500. get width(): string | number;
  83501. /**
  83502. * Gets or sets panel height.
  83503. * This value should not be set when in vertical mode as it will be computed automatically
  83504. */
  83505. set height(value: string | number);
  83506. get height(): string | number;
  83507. /**
  83508. * Creates a new StackPanel
  83509. * @param name defines control name
  83510. */
  83511. constructor(name?: string | undefined);
  83512. protected _getTypeName(): string;
  83513. /** @hidden */
  83514. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83515. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83516. protected _postMeasure(): void;
  83517. }
  83518. }
  83519. declare module BABYLON.GUI {
  83520. /**
  83521. * Class used to represent a 2D checkbox
  83522. */
  83523. export class Checkbox extends Control {
  83524. name?: string | undefined;
  83525. private _isChecked;
  83526. private _background;
  83527. private _checkSizeRatio;
  83528. private _thickness;
  83529. /** Gets or sets border thickness */
  83530. get thickness(): number;
  83531. set thickness(value: number);
  83532. /**
  83533. * BABYLON.Observable raised when isChecked property changes
  83534. */
  83535. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  83536. /** Gets or sets a value indicating the ratio between overall size and check size */
  83537. get checkSizeRatio(): number;
  83538. set checkSizeRatio(value: number);
  83539. /** Gets or sets background color */
  83540. get background(): string;
  83541. set background(value: string);
  83542. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  83543. get isChecked(): boolean;
  83544. set isChecked(value: boolean);
  83545. /**
  83546. * Creates a new CheckBox
  83547. * @param name defines the control name
  83548. */
  83549. constructor(name?: string | undefined);
  83550. protected _getTypeName(): string;
  83551. /** @hidden */
  83552. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83553. /** @hidden */
  83554. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83555. /**
  83556. * Utility function to easily create a checkbox with a header
  83557. * @param title defines the label to use for the header
  83558. * @param onValueChanged defines the callback to call when value changes
  83559. * @returns a StackPanel containing the checkbox and a textBlock
  83560. */
  83561. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  83562. }
  83563. }
  83564. declare module BABYLON.GUI {
  83565. /**
  83566. * Class used to store key control properties
  83567. */
  83568. export class KeyPropertySet {
  83569. /** Width */
  83570. width?: string;
  83571. /** Height */
  83572. height?: string;
  83573. /** Left padding */
  83574. paddingLeft?: string;
  83575. /** Right padding */
  83576. paddingRight?: string;
  83577. /** Top padding */
  83578. paddingTop?: string;
  83579. /** Bottom padding */
  83580. paddingBottom?: string;
  83581. /** Foreground color */
  83582. color?: string;
  83583. /** Background color */
  83584. background?: string;
  83585. }
  83586. /**
  83587. * Class used to create virtual keyboard
  83588. */
  83589. export class VirtualKeyboard extends StackPanel {
  83590. /** BABYLON.Observable raised when a key is pressed */
  83591. onKeyPressObservable: BABYLON.Observable<string>;
  83592. /** Gets or sets default key button width */
  83593. defaultButtonWidth: string;
  83594. /** Gets or sets default key button height */
  83595. defaultButtonHeight: string;
  83596. /** Gets or sets default key button left padding */
  83597. defaultButtonPaddingLeft: string;
  83598. /** Gets or sets default key button right padding */
  83599. defaultButtonPaddingRight: string;
  83600. /** Gets or sets default key button top padding */
  83601. defaultButtonPaddingTop: string;
  83602. /** Gets or sets default key button bottom padding */
  83603. defaultButtonPaddingBottom: string;
  83604. /** Gets or sets default key button foreground color */
  83605. defaultButtonColor: string;
  83606. /** Gets or sets default key button background color */
  83607. defaultButtonBackground: string;
  83608. /** Gets or sets shift button foreground color */
  83609. shiftButtonColor: string;
  83610. /** Gets or sets shift button thickness*/
  83611. selectedShiftThickness: number;
  83612. /** Gets shift key state */
  83613. shiftState: number;
  83614. protected _getTypeName(): string;
  83615. private _createKey;
  83616. /**
  83617. * Adds a new row of keys
  83618. * @param keys defines the list of keys to add
  83619. * @param propertySets defines the associated property sets
  83620. */
  83621. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  83622. /**
  83623. * Set the shift key to a specific state
  83624. * @param shiftState defines the new shift state
  83625. */
  83626. applyShiftState(shiftState: number): void;
  83627. private _currentlyConnectedInputText;
  83628. private _connectedInputTexts;
  83629. private _onKeyPressObserver;
  83630. /** Gets the input text control currently attached to the keyboard */
  83631. get connectedInputText(): BABYLON.Nullable<InputText>;
  83632. /**
  83633. * Connects the keyboard with an input text control
  83634. *
  83635. * @param input defines the target control
  83636. */
  83637. connect(input: InputText): void;
  83638. /**
  83639. * Disconnects the keyboard from connected InputText controls
  83640. *
  83641. * @param input optionally defines a target control, otherwise all are disconnected
  83642. */
  83643. disconnect(input?: InputText): void;
  83644. private _removeConnectedInputObservables;
  83645. /**
  83646. * Release all resources
  83647. */
  83648. dispose(): void;
  83649. /**
  83650. * Creates a new keyboard using a default layout
  83651. *
  83652. * @param name defines control name
  83653. * @returns a new VirtualKeyboard
  83654. */
  83655. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  83656. }
  83657. }
  83658. declare module BABYLON.GUI {
  83659. /** @hidden */
  83660. export class TextWrapper {
  83661. private _text;
  83662. private _characters;
  83663. get text(): string;
  83664. set text(txt: string);
  83665. get length(): number;
  83666. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  83667. charAt(idx: number): string;
  83668. substr(from: number, length?: number): string;
  83669. substring(from: number, to?: number): string;
  83670. isWord(index: number): boolean;
  83671. }
  83672. }
  83673. declare module BABYLON.GUI {
  83674. /**
  83675. * Class used to create input text control
  83676. */
  83677. export class InputText extends Control implements IFocusableControl {
  83678. name?: string | undefined;
  83679. private _textWrapper;
  83680. private _placeholderText;
  83681. private _background;
  83682. private _focusedBackground;
  83683. private _focusedColor;
  83684. private _placeholderColor;
  83685. private _thickness;
  83686. private _margin;
  83687. private _autoStretchWidth;
  83688. private _maxWidth;
  83689. private _isFocused;
  83690. private _blinkTimeout;
  83691. private _blinkIsEven;
  83692. private _cursorOffset;
  83693. private _scrollLeft;
  83694. private _textWidth;
  83695. private _clickedCoordinate;
  83696. private _deadKey;
  83697. private _addKey;
  83698. private _currentKey;
  83699. private _isTextHighlightOn;
  83700. private _textHighlightColor;
  83701. private _highligherOpacity;
  83702. private _highlightedText;
  83703. private _startHighlightIndex;
  83704. private _endHighlightIndex;
  83705. private _cursorIndex;
  83706. private _onFocusSelectAll;
  83707. private _isPointerDown;
  83708. private _onClipboardObserver;
  83709. private _onPointerDblTapObserver;
  83710. /** @hidden */
  83711. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  83712. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  83713. promptMessage: string;
  83714. /** Force disable prompt on mobile device */
  83715. disableMobilePrompt: boolean;
  83716. /** BABYLON.Observable raised when the text changes */
  83717. onTextChangedObservable: BABYLON.Observable<InputText>;
  83718. /** BABYLON.Observable raised just before an entered character is to be added */
  83719. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  83720. /** BABYLON.Observable raised when the control gets the focus */
  83721. onFocusObservable: BABYLON.Observable<InputText>;
  83722. /** BABYLON.Observable raised when the control loses the focus */
  83723. onBlurObservable: BABYLON.Observable<InputText>;
  83724. /**Observable raised when the text is highlighted */
  83725. onTextHighlightObservable: BABYLON.Observable<InputText>;
  83726. /**Observable raised when copy event is triggered */
  83727. onTextCopyObservable: BABYLON.Observable<InputText>;
  83728. /** BABYLON.Observable raised when cut event is triggered */
  83729. onTextCutObservable: BABYLON.Observable<InputText>;
  83730. /** BABYLON.Observable raised when paste event is triggered */
  83731. onTextPasteObservable: BABYLON.Observable<InputText>;
  83732. /** BABYLON.Observable raised when a key event was processed */
  83733. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  83734. /** Gets or sets the maximum width allowed by the control */
  83735. get maxWidth(): string | number;
  83736. /** Gets the maximum width allowed by the control in pixels */
  83737. get maxWidthInPixels(): number;
  83738. set maxWidth(value: string | number);
  83739. /** Gets or sets the text highlighter transparency; default: 0.4 */
  83740. get highligherOpacity(): number;
  83741. set highligherOpacity(value: number);
  83742. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  83743. get onFocusSelectAll(): boolean;
  83744. set onFocusSelectAll(value: boolean);
  83745. /** Gets or sets the text hightlight color */
  83746. get textHighlightColor(): string;
  83747. set textHighlightColor(value: string);
  83748. /** Gets or sets control margin */
  83749. get margin(): string;
  83750. /** Gets control margin in pixels */
  83751. get marginInPixels(): number;
  83752. set margin(value: string);
  83753. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  83754. get autoStretchWidth(): boolean;
  83755. set autoStretchWidth(value: boolean);
  83756. /** Gets or sets border thickness */
  83757. get thickness(): number;
  83758. set thickness(value: number);
  83759. /** Gets or sets the background color when focused */
  83760. get focusedBackground(): string;
  83761. set focusedBackground(value: string);
  83762. /** Gets or sets the background color when focused */
  83763. get focusedColor(): string;
  83764. set focusedColor(value: string);
  83765. /** Gets or sets the background color */
  83766. get background(): string;
  83767. set background(value: string);
  83768. /** Gets or sets the placeholder color */
  83769. get placeholderColor(): string;
  83770. set placeholderColor(value: string);
  83771. /** Gets or sets the text displayed when the control is empty */
  83772. get placeholderText(): string;
  83773. set placeholderText(value: string);
  83774. /** Gets or sets the dead key flag */
  83775. get deadKey(): boolean;
  83776. set deadKey(flag: boolean);
  83777. /** Gets or sets the highlight text */
  83778. get highlightedText(): string;
  83779. set highlightedText(text: string);
  83780. /** Gets or sets if the current key should be added */
  83781. get addKey(): boolean;
  83782. set addKey(flag: boolean);
  83783. /** Gets or sets the value of the current key being entered */
  83784. get currentKey(): string;
  83785. set currentKey(key: string);
  83786. /** Gets or sets the text displayed in the control */
  83787. get text(): string;
  83788. set text(value: string);
  83789. private _textHasChanged;
  83790. /** Gets or sets control width */
  83791. get width(): string | number;
  83792. set width(value: string | number);
  83793. /**
  83794. * Creates a new InputText
  83795. * @param name defines the control name
  83796. * @param text defines the text of the control
  83797. */
  83798. constructor(name?: string | undefined, text?: string);
  83799. /** @hidden */
  83800. onBlur(): void;
  83801. /** @hidden */
  83802. onFocus(): void;
  83803. /**
  83804. * Function to focus an inputText programmatically
  83805. */
  83806. focus(): void;
  83807. /**
  83808. * Function to unfocus an inputText programmatically
  83809. */
  83810. blur(): void;
  83811. protected _getTypeName(): string;
  83812. /**
  83813. * Function called to get the list of controls that should not steal the focus from this control
  83814. * @returns an array of controls
  83815. */
  83816. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  83817. /** @hidden */
  83818. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  83819. /** @hidden */
  83820. private _updateValueFromCursorIndex;
  83821. /** @hidden */
  83822. private _processDblClick;
  83823. /** @hidden */
  83824. private _selectAllText;
  83825. /**
  83826. * Handles the keyboard event
  83827. * @param evt Defines the KeyboardEvent
  83828. */
  83829. processKeyboard(evt: KeyboardEvent): void;
  83830. /** @hidden */
  83831. private _onCopyText;
  83832. /** @hidden */
  83833. private _onCutText;
  83834. /** @hidden */
  83835. private _onPasteText;
  83836. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83837. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83838. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83839. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  83840. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  83841. dispose(): void;
  83842. }
  83843. }
  83844. declare module BABYLON.GUI {
  83845. /**
  83846. * Class used to create a 2D grid container
  83847. */
  83848. export class Grid extends Container {
  83849. name?: string | undefined;
  83850. private _rowDefinitions;
  83851. private _columnDefinitions;
  83852. private _cells;
  83853. private _childControls;
  83854. /**
  83855. * Gets the number of columns
  83856. */
  83857. get columnCount(): number;
  83858. /**
  83859. * Gets the number of rows
  83860. */
  83861. get rowCount(): number;
  83862. /** Gets the list of children */
  83863. get children(): Control[];
  83864. /** Gets the list of cells (e.g. the containers) */
  83865. get cells(): {
  83866. [key: string]: Container;
  83867. };
  83868. /**
  83869. * Gets the definition of a specific row
  83870. * @param index defines the index of the row
  83871. * @returns the row definition
  83872. */
  83873. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  83874. /**
  83875. * Gets the definition of a specific column
  83876. * @param index defines the index of the column
  83877. * @returns the column definition
  83878. */
  83879. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  83880. /**
  83881. * Adds a new row to the grid
  83882. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  83883. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  83884. * @returns the current grid
  83885. */
  83886. addRowDefinition(height: number, isPixel?: boolean): Grid;
  83887. /**
  83888. * Adds a new column to the grid
  83889. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  83890. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  83891. * @returns the current grid
  83892. */
  83893. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  83894. /**
  83895. * Update a row definition
  83896. * @param index defines the index of the row to update
  83897. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  83898. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  83899. * @returns the current grid
  83900. */
  83901. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  83902. /**
  83903. * Update a column definition
  83904. * @param index defines the index of the column to update
  83905. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  83906. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  83907. * @returns the current grid
  83908. */
  83909. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  83910. /**
  83911. * Gets the list of children stored in a specific cell
  83912. * @param row defines the row to check
  83913. * @param column defines the column to check
  83914. * @returns the list of controls
  83915. */
  83916. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  83917. /**
  83918. * Gets a string representing the child cell info (row x column)
  83919. * @param child defines the control to get info from
  83920. * @returns a string containing the child cell info (row x column)
  83921. */
  83922. getChildCellInfo(child: Control): string;
  83923. private _removeCell;
  83924. private _offsetCell;
  83925. /**
  83926. * Remove a column definition at specified index
  83927. * @param index defines the index of the column to remove
  83928. * @returns the current grid
  83929. */
  83930. removeColumnDefinition(index: number): Grid;
  83931. /**
  83932. * Remove a row definition at specified index
  83933. * @param index defines the index of the row to remove
  83934. * @returns the current grid
  83935. */
  83936. removeRowDefinition(index: number): Grid;
  83937. /**
  83938. * Adds a new control to the current grid
  83939. * @param control defines the control to add
  83940. * @param row defines the row where to add the control (0 by default)
  83941. * @param column defines the column where to add the control (0 by default)
  83942. * @returns the current grid
  83943. */
  83944. addControl(control: Control, row?: number, column?: number): Grid;
  83945. /**
  83946. * Removes a control from the current container
  83947. * @param control defines the control to remove
  83948. * @returns the current container
  83949. */
  83950. removeControl(control: Control): Container;
  83951. /**
  83952. * Creates a new Grid
  83953. * @param name defines control name
  83954. */
  83955. constructor(name?: string | undefined);
  83956. protected _getTypeName(): string;
  83957. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  83958. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83959. _flagDescendantsAsMatrixDirty(): void;
  83960. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83961. /** Releases associated resources */
  83962. dispose(): void;
  83963. }
  83964. }
  83965. declare module BABYLON.GUI {
  83966. /** Class used to create color pickers */
  83967. export class ColorPicker extends Control {
  83968. name?: string | undefined;
  83969. private static _Epsilon;
  83970. private _colorWheelCanvas;
  83971. private _value;
  83972. private _tmpColor;
  83973. private _pointerStartedOnSquare;
  83974. private _pointerStartedOnWheel;
  83975. private _squareLeft;
  83976. private _squareTop;
  83977. private _squareSize;
  83978. private _h;
  83979. private _s;
  83980. private _v;
  83981. private _lastPointerDownID;
  83982. /**
  83983. * BABYLON.Observable raised when the value changes
  83984. */
  83985. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  83986. /** Gets or sets the color of the color picker */
  83987. get value(): BABYLON.Color3;
  83988. set value(value: BABYLON.Color3);
  83989. /**
  83990. * Gets or sets control width
  83991. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83992. */
  83993. get width(): string | number;
  83994. set width(value: string | number);
  83995. /**
  83996. * Gets or sets control height
  83997. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83998. */
  83999. get height(): string | number;
  84000. /** Gets or sets control height */
  84001. set height(value: string | number);
  84002. /** Gets or sets control size */
  84003. get size(): string | number;
  84004. set size(value: string | number);
  84005. /**
  84006. * Creates a new ColorPicker
  84007. * @param name defines the control name
  84008. */
  84009. constructor(name?: string | undefined);
  84010. protected _getTypeName(): string;
  84011. /** @hidden */
  84012. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84013. private _updateSquareProps;
  84014. private _drawGradientSquare;
  84015. private _drawCircle;
  84016. private _createColorWheelCanvas;
  84017. /** @hidden */
  84018. _draw(context: CanvasRenderingContext2D): void;
  84019. private _pointerIsDown;
  84020. private _updateValueFromPointer;
  84021. private _isPointOnSquare;
  84022. private _isPointOnWheel;
  84023. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84024. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84025. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84026. _onCanvasBlur(): void;
  84027. /**
  84028. * This function expands the color picker by creating a color picker dialog with manual
  84029. * color value input and the ability to save colors into an array to be used later in
  84030. * subsequent launches of the dialogue.
  84031. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  84032. * @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.
  84033. * @returns picked color as a hex string and the saved colors array as hex strings.
  84034. */
  84035. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  84036. pickerWidth?: string;
  84037. pickerHeight?: string;
  84038. headerHeight?: string;
  84039. lastColor?: string;
  84040. swatchLimit?: number;
  84041. numSwatchesPerLine?: number;
  84042. savedColors?: Array<string>;
  84043. }): Promise<{
  84044. savedColors?: string[];
  84045. pickedColor: string;
  84046. }>;
  84047. }
  84048. }
  84049. declare module BABYLON.GUI {
  84050. /** Class used to create 2D ellipse containers */
  84051. export class Ellipse extends Container {
  84052. name?: string | undefined;
  84053. private _thickness;
  84054. /** Gets or sets border thickness */
  84055. get thickness(): number;
  84056. set thickness(value: number);
  84057. /**
  84058. * Creates a new Ellipse
  84059. * @param name defines the control name
  84060. */
  84061. constructor(name?: string | undefined);
  84062. protected _getTypeName(): string;
  84063. protected _localDraw(context: CanvasRenderingContext2D): void;
  84064. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84065. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84066. }
  84067. }
  84068. declare module BABYLON.GUI {
  84069. /**
  84070. * Class used to create a focusable button that can easily handle keyboard events
  84071. */
  84072. export class FocusableButton extends Button implements IFocusableControl {
  84073. name?: string | undefined;
  84074. /** Highlight color when button is focused */
  84075. focusedColor: BABYLON.Nullable<string>;
  84076. private _isFocused;
  84077. private _unfocusedColor;
  84078. /** BABYLON.Observable raised when the control gets the focus */
  84079. onFocusObservable: BABYLON.Observable<Button>;
  84080. /** BABYLON.Observable raised when the control loses the focus */
  84081. onBlurObservable: BABYLON.Observable<Button>;
  84082. /** BABYLON.Observable raised when a key event was processed */
  84083. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84084. constructor(name?: string | undefined);
  84085. /** @hidden */
  84086. onBlur(): void;
  84087. /** @hidden */
  84088. onFocus(): void;
  84089. /**
  84090. * Function called to get the list of controls that should not steal the focus from this control
  84091. * @returns an array of controls
  84092. */
  84093. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84094. /**
  84095. * Function to focus a button programmatically
  84096. */
  84097. focus(): void;
  84098. /**
  84099. * Function to unfocus a button programmatically
  84100. */
  84101. blur(): void;
  84102. /**
  84103. * Handles the keyboard event
  84104. * @param evt Defines the KeyboardEvent
  84105. */
  84106. processKeyboard(evt: KeyboardEvent): void;
  84107. /** @hidden */
  84108. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84109. /** @hidden */
  84110. displose(): void;
  84111. }
  84112. }
  84113. declare module BABYLON.GUI {
  84114. /**
  84115. * Class used to create a password control
  84116. */
  84117. export class InputPassword extends InputText {
  84118. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84119. }
  84120. }
  84121. declare module BABYLON.GUI {
  84122. /** Class used to render 2D lines */
  84123. export class Line extends Control {
  84124. name?: string | undefined;
  84125. private _lineWidth;
  84126. private _x1;
  84127. private _y1;
  84128. private _x2;
  84129. private _y2;
  84130. private _dash;
  84131. private _connectedControl;
  84132. private _connectedControlDirtyObserver;
  84133. /** Gets or sets the dash pattern */
  84134. get dash(): Array<number>;
  84135. set dash(value: Array<number>);
  84136. /** Gets or sets the control connected with the line end */
  84137. get connectedControl(): Control;
  84138. set connectedControl(value: Control);
  84139. /** Gets or sets start coordinates on X axis */
  84140. get x1(): string | number;
  84141. set x1(value: string | number);
  84142. /** Gets or sets start coordinates on Y axis */
  84143. get y1(): string | number;
  84144. set y1(value: string | number);
  84145. /** Gets or sets end coordinates on X axis */
  84146. get x2(): string | number;
  84147. set x2(value: string | number);
  84148. /** Gets or sets end coordinates on Y axis */
  84149. get y2(): string | number;
  84150. set y2(value: string | number);
  84151. /** Gets or sets line width */
  84152. get lineWidth(): number;
  84153. set lineWidth(value: number);
  84154. /** Gets or sets horizontal alignment */
  84155. set horizontalAlignment(value: number);
  84156. /** Gets or sets vertical alignment */
  84157. set verticalAlignment(value: number);
  84158. private get _effectiveX2();
  84159. private get _effectiveY2();
  84160. /**
  84161. * Creates a new Line
  84162. * @param name defines the control name
  84163. */
  84164. constructor(name?: string | undefined);
  84165. protected _getTypeName(): string;
  84166. _draw(context: CanvasRenderingContext2D): void;
  84167. _measure(): void;
  84168. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84169. /**
  84170. * Move one end of the line given 3D cartesian coordinates.
  84171. * @param position Targeted world position
  84172. * @param scene BABYLON.Scene
  84173. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84174. */
  84175. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  84176. /**
  84177. * Move one end of the line to a position in screen absolute space.
  84178. * @param projectedPosition Position in screen absolute space (X, Y)
  84179. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84180. */
  84181. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  84182. }
  84183. }
  84184. declare module BABYLON.GUI {
  84185. /**
  84186. * Class used to store a point for a MultiLine object.
  84187. * The point can be pure 2D coordinates, a mesh or a control
  84188. */
  84189. export class MultiLinePoint {
  84190. private _multiLine;
  84191. private _x;
  84192. private _y;
  84193. private _control;
  84194. private _mesh;
  84195. private _controlObserver;
  84196. private _meshObserver;
  84197. /** @hidden */
  84198. _point: BABYLON.Vector3;
  84199. /**
  84200. * Creates a new MultiLinePoint
  84201. * @param multiLine defines the source MultiLine object
  84202. */
  84203. constructor(multiLine: MultiLine);
  84204. /** Gets or sets x coordinate */
  84205. get x(): string | number;
  84206. set x(value: string | number);
  84207. /** Gets or sets y coordinate */
  84208. get y(): string | number;
  84209. set y(value: string | number);
  84210. /** Gets or sets the control associated with this point */
  84211. get control(): BABYLON.Nullable<Control>;
  84212. set control(value: BABYLON.Nullable<Control>);
  84213. /** Gets or sets the mesh associated with this point */
  84214. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  84215. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  84216. /** Resets links */
  84217. resetLinks(): void;
  84218. /**
  84219. * Gets a translation vector with Z component
  84220. * @returns the translation vector
  84221. */
  84222. translate(): BABYLON.Vector3;
  84223. private _translatePoint;
  84224. /** Release associated resources */
  84225. dispose(): void;
  84226. }
  84227. }
  84228. declare module BABYLON.GUI {
  84229. /**
  84230. * Class used to create multi line control
  84231. */
  84232. export class MultiLine extends Control {
  84233. name?: string | undefined;
  84234. private _lineWidth;
  84235. private _dash;
  84236. private _points;
  84237. private _minX;
  84238. private _minY;
  84239. private _maxX;
  84240. private _maxY;
  84241. /**
  84242. * Creates a new MultiLine
  84243. * @param name defines the control name
  84244. */
  84245. constructor(name?: string | undefined);
  84246. /** Gets or sets dash pattern */
  84247. get dash(): Array<number>;
  84248. set dash(value: Array<number>);
  84249. /**
  84250. * Gets point stored at specified index
  84251. * @param index defines the index to look for
  84252. * @returns the requested point if found
  84253. */
  84254. getAt(index: number): MultiLinePoint;
  84255. /** Function called when a point is updated */
  84256. onPointUpdate: () => void;
  84257. /**
  84258. * Adds new points to the point collection
  84259. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  84260. * @returns the list of created MultiLinePoint
  84261. */
  84262. add(...items: (AbstractMesh | Control | {
  84263. x: string | number;
  84264. y: string | number;
  84265. })[]): MultiLinePoint[];
  84266. /**
  84267. * Adds a new point to the point collection
  84268. * @param item defines the item (mesh, control or 2d coordiantes) to add
  84269. * @returns the created MultiLinePoint
  84270. */
  84271. push(item?: (AbstractMesh | Control | {
  84272. x: string | number;
  84273. y: string | number;
  84274. })): MultiLinePoint;
  84275. /**
  84276. * Remove a specific value or point from the active point collection
  84277. * @param value defines the value or point to remove
  84278. */
  84279. remove(value: number | MultiLinePoint): void;
  84280. /**
  84281. * Resets this object to initial state (no point)
  84282. */
  84283. reset(): void;
  84284. /**
  84285. * Resets all links
  84286. */
  84287. resetLinks(): void;
  84288. /** Gets or sets line width */
  84289. get lineWidth(): number;
  84290. set lineWidth(value: number);
  84291. set horizontalAlignment(value: number);
  84292. set verticalAlignment(value: number);
  84293. protected _getTypeName(): string;
  84294. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84295. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84296. _measure(): void;
  84297. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84298. dispose(): void;
  84299. }
  84300. }
  84301. declare module BABYLON.GUI {
  84302. /**
  84303. * Class used to create radio button controls
  84304. */
  84305. export class RadioButton extends Control {
  84306. name?: string | undefined;
  84307. private _isChecked;
  84308. private _background;
  84309. private _checkSizeRatio;
  84310. private _thickness;
  84311. /** Gets or sets border thickness */
  84312. get thickness(): number;
  84313. set thickness(value: number);
  84314. /** Gets or sets group name */
  84315. group: string;
  84316. /** BABYLON.Observable raised when isChecked is changed */
  84317. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84318. /** Gets or sets a value indicating the ratio between overall size and check size */
  84319. get checkSizeRatio(): number;
  84320. set checkSizeRatio(value: number);
  84321. /** Gets or sets background color */
  84322. get background(): string;
  84323. set background(value: string);
  84324. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84325. get isChecked(): boolean;
  84326. set isChecked(value: boolean);
  84327. /**
  84328. * Creates a new RadioButton
  84329. * @param name defines the control name
  84330. */
  84331. constructor(name?: string | undefined);
  84332. protected _getTypeName(): string;
  84333. _draw(context: CanvasRenderingContext2D): void;
  84334. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84335. /**
  84336. * Utility function to easily create a radio button with a header
  84337. * @param title defines the label to use for the header
  84338. * @param group defines the group to use for the radio button
  84339. * @param isChecked defines the initial state of the radio button
  84340. * @param onValueChanged defines the callback to call when value changes
  84341. * @returns a StackPanel containing the radio button and a textBlock
  84342. */
  84343. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  84344. }
  84345. }
  84346. declare module BABYLON.GUI {
  84347. /**
  84348. * Class used to create slider controls
  84349. */
  84350. export class BaseSlider extends Control {
  84351. name?: string | undefined;
  84352. protected _thumbWidth: ValueAndUnit;
  84353. private _minimum;
  84354. private _maximum;
  84355. private _value;
  84356. private _isVertical;
  84357. protected _barOffset: ValueAndUnit;
  84358. private _isThumbClamped;
  84359. protected _displayThumb: boolean;
  84360. private _step;
  84361. private _lastPointerDownID;
  84362. protected _effectiveBarOffset: number;
  84363. protected _renderLeft: number;
  84364. protected _renderTop: number;
  84365. protected _renderWidth: number;
  84366. protected _renderHeight: number;
  84367. protected _backgroundBoxLength: number;
  84368. protected _backgroundBoxThickness: number;
  84369. protected _effectiveThumbThickness: number;
  84370. /** BABYLON.Observable raised when the sldier value changes */
  84371. onValueChangedObservable: BABYLON.Observable<number>;
  84372. /** Gets or sets a boolean indicating if the thumb must be rendered */
  84373. get displayThumb(): boolean;
  84374. set displayThumb(value: boolean);
  84375. /** Gets or sets a step to apply to values (0 by default) */
  84376. get step(): number;
  84377. set step(value: number);
  84378. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  84379. get barOffset(): string | number;
  84380. /** Gets main bar offset in pixels*/
  84381. get barOffsetInPixels(): number;
  84382. set barOffset(value: string | number);
  84383. /** Gets or sets thumb width */
  84384. get thumbWidth(): string | number;
  84385. /** Gets thumb width in pixels */
  84386. get thumbWidthInPixels(): number;
  84387. set thumbWidth(value: string | number);
  84388. /** Gets or sets minimum value */
  84389. get minimum(): number;
  84390. set minimum(value: number);
  84391. /** Gets or sets maximum value */
  84392. get maximum(): number;
  84393. set maximum(value: number);
  84394. /** Gets or sets current value */
  84395. get value(): number;
  84396. set value(value: number);
  84397. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  84398. get isVertical(): boolean;
  84399. set isVertical(value: boolean);
  84400. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  84401. get isThumbClamped(): boolean;
  84402. set isThumbClamped(value: boolean);
  84403. /**
  84404. * Creates a new BaseSlider
  84405. * @param name defines the control name
  84406. */
  84407. constructor(name?: string | undefined);
  84408. protected _getTypeName(): string;
  84409. protected _getThumbPosition(): number;
  84410. protected _getThumbThickness(type: string): number;
  84411. protected _prepareRenderingData(type: string): void;
  84412. private _pointerIsDown;
  84413. /** @hidden */
  84414. protected _updateValueFromPointer(x: number, y: number): void;
  84415. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84416. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84417. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84418. _onCanvasBlur(): void;
  84419. }
  84420. }
  84421. declare module BABYLON.GUI {
  84422. /**
  84423. * Class used to create slider controls
  84424. */
  84425. export class Slider extends BaseSlider {
  84426. name?: string | undefined;
  84427. private _background;
  84428. private _borderColor;
  84429. private _thumbColor;
  84430. private _isThumbCircle;
  84431. protected _displayValueBar: boolean;
  84432. /** Gets or sets a boolean indicating if the value bar must be rendered */
  84433. get displayValueBar(): boolean;
  84434. set displayValueBar(value: boolean);
  84435. /** Gets or sets border color */
  84436. get borderColor(): string;
  84437. set borderColor(value: string);
  84438. /** Gets or sets background color */
  84439. get background(): string;
  84440. set background(value: string);
  84441. /** Gets or sets thumb's color */
  84442. get thumbColor(): string;
  84443. set thumbColor(value: string);
  84444. /** Gets or sets a boolean indicating if the thumb should be round or square */
  84445. get isThumbCircle(): boolean;
  84446. set isThumbCircle(value: boolean);
  84447. /**
  84448. * Creates a new Slider
  84449. * @param name defines the control name
  84450. */
  84451. constructor(name?: string | undefined);
  84452. protected _getTypeName(): string;
  84453. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84454. }
  84455. }
  84456. declare module BABYLON.GUI {
  84457. /** Class used to create a RadioGroup
  84458. * which contains groups of radio buttons
  84459. */
  84460. export class SelectorGroup {
  84461. /** name of SelectorGroup */
  84462. name: string;
  84463. private _groupPanel;
  84464. private _selectors;
  84465. private _groupHeader;
  84466. /**
  84467. * Creates a new SelectorGroup
  84468. * @param name of group, used as a group heading
  84469. */
  84470. constructor(
  84471. /** name of SelectorGroup */
  84472. name: string);
  84473. /** Gets the groupPanel of the SelectorGroup */
  84474. get groupPanel(): StackPanel;
  84475. /** Gets the selectors array */
  84476. get selectors(): StackPanel[];
  84477. /** Gets and sets the group header */
  84478. get header(): string;
  84479. set header(label: string);
  84480. /** @hidden */
  84481. private _addGroupHeader;
  84482. /** @hidden*/
  84483. _getSelector(selectorNb: number): StackPanel | undefined;
  84484. /** Removes the selector at the given position
  84485. * @param selectorNb the position of the selector within the group
  84486. */
  84487. removeSelector(selectorNb: number): void;
  84488. }
  84489. /** Class used to create a CheckboxGroup
  84490. * which contains groups of checkbox buttons
  84491. */
  84492. export class CheckboxGroup extends SelectorGroup {
  84493. /** Adds a checkbox as a control
  84494. * @param text is the label for the selector
  84495. * @param func is the function called when the Selector is checked
  84496. * @param checked is true when Selector is checked
  84497. */
  84498. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  84499. /** @hidden */
  84500. _setSelectorLabel(selectorNb: number, label: string): void;
  84501. /** @hidden */
  84502. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84503. /** @hidden */
  84504. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84505. /** @hidden */
  84506. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84507. }
  84508. /** Class used to create a RadioGroup
  84509. * which contains groups of radio buttons
  84510. */
  84511. export class RadioGroup extends SelectorGroup {
  84512. private _selectNb;
  84513. /** Adds a radio button as a control
  84514. * @param label is the label for the selector
  84515. * @param func is the function called when the Selector is checked
  84516. * @param checked is true when Selector is checked
  84517. */
  84518. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  84519. /** @hidden */
  84520. _setSelectorLabel(selectorNb: number, label: string): void;
  84521. /** @hidden */
  84522. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84523. /** @hidden */
  84524. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84525. /** @hidden */
  84526. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84527. }
  84528. /** Class used to create a SliderGroup
  84529. * which contains groups of slider buttons
  84530. */
  84531. export class SliderGroup extends SelectorGroup {
  84532. /**
  84533. * Adds a slider to the SelectorGroup
  84534. * @param label is the label for the SliderBar
  84535. * @param func is the function called when the Slider moves
  84536. * @param unit is a string describing the units used, eg degrees or metres
  84537. * @param min is the minimum value for the Slider
  84538. * @param max is the maximum value for the Slider
  84539. * @param value is the start value for the Slider between min and max
  84540. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  84541. */
  84542. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  84543. /** @hidden */
  84544. _setSelectorLabel(selectorNb: number, label: string): void;
  84545. /** @hidden */
  84546. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84547. /** @hidden */
  84548. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84549. /** @hidden */
  84550. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84551. }
  84552. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  84553. * @see https://doc.babylonjs.com/how_to/selector
  84554. */
  84555. export class SelectionPanel extends Rectangle {
  84556. /** name of SelectionPanel */
  84557. name: string;
  84558. /** an array of SelectionGroups */
  84559. groups: SelectorGroup[];
  84560. private _panel;
  84561. private _buttonColor;
  84562. private _buttonBackground;
  84563. private _headerColor;
  84564. private _barColor;
  84565. private _barHeight;
  84566. private _spacerHeight;
  84567. private _labelColor;
  84568. private _groups;
  84569. private _bars;
  84570. /**
  84571. * Creates a new SelectionPanel
  84572. * @param name of SelectionPanel
  84573. * @param groups is an array of SelectionGroups
  84574. */
  84575. constructor(
  84576. /** name of SelectionPanel */
  84577. name: string,
  84578. /** an array of SelectionGroups */
  84579. groups?: SelectorGroup[]);
  84580. protected _getTypeName(): string;
  84581. /** Gets the (stack) panel of the SelectionPanel */
  84582. get panel(): StackPanel;
  84583. /** Gets or sets the headerColor */
  84584. get headerColor(): string;
  84585. set headerColor(color: string);
  84586. private _setHeaderColor;
  84587. /** Gets or sets the button color */
  84588. get buttonColor(): string;
  84589. set buttonColor(color: string);
  84590. private _setbuttonColor;
  84591. /** Gets or sets the label color */
  84592. get labelColor(): string;
  84593. set labelColor(color: string);
  84594. private _setLabelColor;
  84595. /** Gets or sets the button background */
  84596. get buttonBackground(): string;
  84597. set buttonBackground(color: string);
  84598. private _setButtonBackground;
  84599. /** Gets or sets the color of separator bar */
  84600. get barColor(): string;
  84601. set barColor(color: string);
  84602. private _setBarColor;
  84603. /** Gets or sets the height of separator bar */
  84604. get barHeight(): string;
  84605. set barHeight(value: string);
  84606. private _setBarHeight;
  84607. /** Gets or sets the height of spacers*/
  84608. get spacerHeight(): string;
  84609. set spacerHeight(value: string);
  84610. private _setSpacerHeight;
  84611. /** Adds a bar between groups */
  84612. private _addSpacer;
  84613. /** Add a group to the selection panel
  84614. * @param group is the selector group to add
  84615. */
  84616. addGroup(group: SelectorGroup): void;
  84617. /** Remove the group from the given position
  84618. * @param groupNb is the position of the group in the list
  84619. */
  84620. removeGroup(groupNb: number): void;
  84621. /** Change a group header label
  84622. * @param label is the new group header label
  84623. * @param groupNb is the number of the group to relabel
  84624. * */
  84625. setHeaderName(label: string, groupNb: number): void;
  84626. /** Change selector label to the one given
  84627. * @param label is the new selector label
  84628. * @param groupNb is the number of the groupcontaining the selector
  84629. * @param selectorNb is the number of the selector within a group to relabel
  84630. * */
  84631. relabel(label: string, groupNb: number, selectorNb: number): void;
  84632. /** For a given group position remove the selector at the given position
  84633. * @param groupNb is the number of the group to remove the selector from
  84634. * @param selectorNb is the number of the selector within the group
  84635. */
  84636. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  84637. /** For a given group position of correct type add a checkbox button
  84638. * @param groupNb is the number of the group to remove the selector from
  84639. * @param label is the label for the selector
  84640. * @param func is the function called when the Selector is checked
  84641. * @param checked is true when Selector is checked
  84642. */
  84643. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  84644. /** For a given group position of correct type add a radio button
  84645. * @param groupNb is the number of the group to remove the selector from
  84646. * @param label is the label for the selector
  84647. * @param func is the function called when the Selector is checked
  84648. * @param checked is true when Selector is checked
  84649. */
  84650. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  84651. /**
  84652. * For a given slider group add a slider
  84653. * @param groupNb is the number of the group to add the slider to
  84654. * @param label is the label for the Slider
  84655. * @param func is the function called when the Slider moves
  84656. * @param unit is a string describing the units used, eg degrees or metres
  84657. * @param min is the minimum value for the Slider
  84658. * @param max is the maximum value for the Slider
  84659. * @param value is the start value for the Slider between min and max
  84660. * @param onVal is the function used to format the value displayed, eg radians to degrees
  84661. */
  84662. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  84663. }
  84664. }
  84665. declare module BABYLON.GUI {
  84666. /**
  84667. * Class used to hold a the container for ScrollViewer
  84668. * @hidden
  84669. */
  84670. export class _ScrollViewerWindow extends Container {
  84671. parentClientWidth: number;
  84672. parentClientHeight: number;
  84673. private _freezeControls;
  84674. private _parentMeasure;
  84675. private _oldLeft;
  84676. private _oldTop;
  84677. get freezeControls(): boolean;
  84678. set freezeControls(value: boolean);
  84679. private _bucketWidth;
  84680. private _bucketHeight;
  84681. private _buckets;
  84682. private _bucketLen;
  84683. get bucketWidth(): number;
  84684. get bucketHeight(): number;
  84685. setBucketSizes(width: number, height: number): void;
  84686. private _useBuckets;
  84687. private _makeBuckets;
  84688. private _dispatchInBuckets;
  84689. private _updateMeasures;
  84690. private _updateChildrenMeasures;
  84691. private _restoreMeasures;
  84692. /**
  84693. * Creates a new ScrollViewerWindow
  84694. * @param name of ScrollViewerWindow
  84695. */
  84696. constructor(name?: string);
  84697. protected _getTypeName(): string;
  84698. /** @hidden */
  84699. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84700. /** @hidden */
  84701. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  84702. private _scrollChildren;
  84703. private _scrollChildrenWithBuckets;
  84704. /** @hidden */
  84705. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  84706. protected _postMeasure(): void;
  84707. }
  84708. }
  84709. declare module BABYLON.GUI {
  84710. /**
  84711. * Class used to create slider controls
  84712. */
  84713. export class ScrollBar extends BaseSlider {
  84714. name?: string | undefined;
  84715. private _background;
  84716. private _borderColor;
  84717. private _tempMeasure;
  84718. /** Gets or sets border color */
  84719. get borderColor(): string;
  84720. set borderColor(value: string);
  84721. /** Gets or sets background color */
  84722. get background(): string;
  84723. set background(value: string);
  84724. /**
  84725. * Creates a new Slider
  84726. * @param name defines the control name
  84727. */
  84728. constructor(name?: string | undefined);
  84729. protected _getTypeName(): string;
  84730. protected _getThumbThickness(): number;
  84731. _draw(context: CanvasRenderingContext2D): void;
  84732. private _first;
  84733. private _originX;
  84734. private _originY;
  84735. /** @hidden */
  84736. protected _updateValueFromPointer(x: number, y: number): void;
  84737. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84738. }
  84739. }
  84740. declare module BABYLON.GUI {
  84741. /**
  84742. * Class used to create slider controls
  84743. */
  84744. export class ImageScrollBar extends BaseSlider {
  84745. name?: string | undefined;
  84746. private _backgroundBaseImage;
  84747. private _backgroundImage;
  84748. private _thumbImage;
  84749. private _thumbBaseImage;
  84750. private _thumbLength;
  84751. private _thumbHeight;
  84752. private _barImageHeight;
  84753. private _tempMeasure;
  84754. /** Number of 90° rotation to apply on the images when in vertical mode */
  84755. num90RotationInVerticalMode: number;
  84756. /**
  84757. * Gets or sets the image used to render the background for horizontal bar
  84758. */
  84759. get backgroundImage(): Image;
  84760. set backgroundImage(value: Image);
  84761. /**
  84762. * Gets or sets the image used to render the thumb
  84763. */
  84764. get thumbImage(): Image;
  84765. set thumbImage(value: Image);
  84766. /**
  84767. * Gets or sets the length of the thumb
  84768. */
  84769. get thumbLength(): number;
  84770. set thumbLength(value: number);
  84771. /**
  84772. * Gets or sets the height of the thumb
  84773. */
  84774. get thumbHeight(): number;
  84775. set thumbHeight(value: number);
  84776. /**
  84777. * Gets or sets the height of the bar image
  84778. */
  84779. get barImageHeight(): number;
  84780. set barImageHeight(value: number);
  84781. /**
  84782. * Creates a new ImageScrollBar
  84783. * @param name defines the control name
  84784. */
  84785. constructor(name?: string | undefined);
  84786. protected _getTypeName(): string;
  84787. protected _getThumbThickness(): number;
  84788. _draw(context: CanvasRenderingContext2D): void;
  84789. private _first;
  84790. private _originX;
  84791. private _originY;
  84792. /** @hidden */
  84793. protected _updateValueFromPointer(x: number, y: number): void;
  84794. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84795. }
  84796. }
  84797. declare module BABYLON.GUI {
  84798. /**
  84799. * Class used to hold a viewer window and sliders in a grid
  84800. */
  84801. export class ScrollViewer extends Rectangle {
  84802. private _grid;
  84803. private _horizontalBarSpace;
  84804. private _verticalBarSpace;
  84805. private _dragSpace;
  84806. private _horizontalBar;
  84807. private _verticalBar;
  84808. private _barColor;
  84809. private _barBackground;
  84810. private _barImage;
  84811. private _horizontalBarImage;
  84812. private _verticalBarImage;
  84813. private _barBackgroundImage;
  84814. private _horizontalBarBackgroundImage;
  84815. private _verticalBarBackgroundImage;
  84816. private _barSize;
  84817. private _window;
  84818. private _pointerIsOver;
  84819. private _wheelPrecision;
  84820. private _onWheelObserver;
  84821. private _clientWidth;
  84822. private _clientHeight;
  84823. private _useImageBar;
  84824. private _thumbLength;
  84825. private _thumbHeight;
  84826. private _barImageHeight;
  84827. private _horizontalBarImageHeight;
  84828. private _verticalBarImageHeight;
  84829. private _oldWindowContentsWidth;
  84830. private _oldWindowContentsHeight;
  84831. /**
  84832. * Gets the horizontal scrollbar
  84833. */
  84834. get horizontalBar(): ScrollBar | ImageScrollBar;
  84835. /**
  84836. * Gets the vertical scrollbar
  84837. */
  84838. get verticalBar(): ScrollBar | ImageScrollBar;
  84839. /**
  84840. * Adds a new control to the current container
  84841. * @param control defines the control to add
  84842. * @returns the current container
  84843. */
  84844. addControl(control: BABYLON.Nullable<Control>): Container;
  84845. /**
  84846. * Removes a control from the current container
  84847. * @param control defines the control to remove
  84848. * @returns the current container
  84849. */
  84850. removeControl(control: Control): Container;
  84851. /** Gets the list of children */
  84852. get children(): Control[];
  84853. _flagDescendantsAsMatrixDirty(): void;
  84854. /**
  84855. * Freezes or unfreezes the controls in the window.
  84856. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  84857. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  84858. */
  84859. get freezeControls(): boolean;
  84860. set freezeControls(value: boolean);
  84861. /** Gets the bucket width */
  84862. get bucketWidth(): number;
  84863. /** Gets the bucket height */
  84864. get bucketHeight(): number;
  84865. /**
  84866. * Sets the bucket sizes.
  84867. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  84868. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  84869. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  84870. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  84871. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  84872. * used), that's why it is not enabled by default.
  84873. * @param width width of the bucket
  84874. * @param height height of the bucket
  84875. */
  84876. setBucketSizes(width: number, height: number): void;
  84877. private _forceHorizontalBar;
  84878. private _forceVerticalBar;
  84879. /**
  84880. * Forces the horizontal scroll bar to be displayed
  84881. */
  84882. get forceHorizontalBar(): boolean;
  84883. set forceHorizontalBar(value: boolean);
  84884. /**
  84885. * Forces the vertical scroll bar to be displayed
  84886. */
  84887. get forceVerticalBar(): boolean;
  84888. set forceVerticalBar(value: boolean);
  84889. /**
  84890. * Creates a new ScrollViewer
  84891. * @param name of ScrollViewer
  84892. */
  84893. constructor(name?: string, isImageBased?: boolean);
  84894. /** Reset the scroll viewer window to initial size */
  84895. resetWindow(): void;
  84896. protected _getTypeName(): string;
  84897. private _buildClientSizes;
  84898. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84899. protected _postMeasure(): void;
  84900. /**
  84901. * Gets or sets the mouse wheel precision
  84902. * from 0 to 1 with a default value of 0.05
  84903. * */
  84904. get wheelPrecision(): number;
  84905. set wheelPrecision(value: number);
  84906. /** Gets or sets the scroll bar container background color */
  84907. get scrollBackground(): string;
  84908. set scrollBackground(color: string);
  84909. /** Gets or sets the bar color */
  84910. get barColor(): string;
  84911. set barColor(color: string);
  84912. /** Gets or sets the bar image */
  84913. get thumbImage(): Image;
  84914. set thumbImage(value: Image);
  84915. /** Gets or sets the horizontal bar image */
  84916. get horizontalThumbImage(): Image;
  84917. set horizontalThumbImage(value: Image);
  84918. /** Gets or sets the vertical bar image */
  84919. get verticalThumbImage(): Image;
  84920. set verticalThumbImage(value: Image);
  84921. /** Gets or sets the size of the bar */
  84922. get barSize(): number;
  84923. set barSize(value: number);
  84924. /** Gets or sets the length of the thumb */
  84925. get thumbLength(): number;
  84926. set thumbLength(value: number);
  84927. /** Gets or sets the height of the thumb */
  84928. get thumbHeight(): number;
  84929. set thumbHeight(value: number);
  84930. /** Gets or sets the height of the bar image */
  84931. get barImageHeight(): number;
  84932. set barImageHeight(value: number);
  84933. /** Gets or sets the height of the horizontal bar image */
  84934. get horizontalBarImageHeight(): number;
  84935. set horizontalBarImageHeight(value: number);
  84936. /** Gets or sets the height of the vertical bar image */
  84937. get verticalBarImageHeight(): number;
  84938. set verticalBarImageHeight(value: number);
  84939. /** Gets or sets the bar background */
  84940. get barBackground(): string;
  84941. set barBackground(color: string);
  84942. /** Gets or sets the bar background image */
  84943. get barImage(): Image;
  84944. set barImage(value: Image);
  84945. /** Gets or sets the horizontal bar background image */
  84946. get horizontalBarImage(): Image;
  84947. set horizontalBarImage(value: Image);
  84948. /** Gets or sets the vertical bar background image */
  84949. get verticalBarImage(): Image;
  84950. set verticalBarImage(value: Image);
  84951. private _setWindowPosition;
  84952. /** @hidden */
  84953. private _updateScroller;
  84954. _link(host: AdvancedDynamicTexture): void;
  84955. /** @hidden */
  84956. private _addBar;
  84957. /** @hidden */
  84958. private _attachWheel;
  84959. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84960. /** Releases associated resources */
  84961. dispose(): void;
  84962. }
  84963. }
  84964. declare module BABYLON.GUI {
  84965. /** Class used to render a grid */
  84966. export class DisplayGrid extends Control {
  84967. name?: string | undefined;
  84968. private _cellWidth;
  84969. private _cellHeight;
  84970. private _minorLineTickness;
  84971. private _minorLineColor;
  84972. private _majorLineTickness;
  84973. private _majorLineColor;
  84974. private _majorLineFrequency;
  84975. private _background;
  84976. private _displayMajorLines;
  84977. private _displayMinorLines;
  84978. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  84979. get displayMinorLines(): boolean;
  84980. set displayMinorLines(value: boolean);
  84981. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  84982. get displayMajorLines(): boolean;
  84983. set displayMajorLines(value: boolean);
  84984. /** Gets or sets background color (Black by default) */
  84985. get background(): string;
  84986. set background(value: string);
  84987. /** Gets or sets the width of each cell (20 by default) */
  84988. get cellWidth(): number;
  84989. set cellWidth(value: number);
  84990. /** Gets or sets the height of each cell (20 by default) */
  84991. get cellHeight(): number;
  84992. set cellHeight(value: number);
  84993. /** Gets or sets the tickness of minor lines (1 by default) */
  84994. get minorLineTickness(): number;
  84995. set minorLineTickness(value: number);
  84996. /** Gets or sets the color of minor lines (DarkGray by default) */
  84997. get minorLineColor(): string;
  84998. set minorLineColor(value: string);
  84999. /** Gets or sets the tickness of major lines (2 by default) */
  85000. get majorLineTickness(): number;
  85001. set majorLineTickness(value: number);
  85002. /** Gets or sets the color of major lines (White by default) */
  85003. get majorLineColor(): string;
  85004. set majorLineColor(value: string);
  85005. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  85006. get majorLineFrequency(): number;
  85007. set majorLineFrequency(value: number);
  85008. /**
  85009. * Creates a new GridDisplayRectangle
  85010. * @param name defines the control name
  85011. */
  85012. constructor(name?: string | undefined);
  85013. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85014. protected _getTypeName(): string;
  85015. }
  85016. }
  85017. declare module BABYLON.GUI {
  85018. /**
  85019. * Class used to create slider controls based on images
  85020. */
  85021. export class ImageBasedSlider extends BaseSlider {
  85022. name?: string | undefined;
  85023. private _backgroundImage;
  85024. private _thumbImage;
  85025. private _valueBarImage;
  85026. private _tempMeasure;
  85027. get displayThumb(): boolean;
  85028. set displayThumb(value: boolean);
  85029. /**
  85030. * Gets or sets the image used to render the background
  85031. */
  85032. get backgroundImage(): Image;
  85033. set backgroundImage(value: Image);
  85034. /**
  85035. * Gets or sets the image used to render the value bar
  85036. */
  85037. get valueBarImage(): Image;
  85038. set valueBarImage(value: Image);
  85039. /**
  85040. * Gets or sets the image used to render the thumb
  85041. */
  85042. get thumbImage(): Image;
  85043. set thumbImage(value: Image);
  85044. /**
  85045. * Creates a new ImageBasedSlider
  85046. * @param name defines the control name
  85047. */
  85048. constructor(name?: string | undefined);
  85049. protected _getTypeName(): string;
  85050. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85051. }
  85052. }
  85053. declare module BABYLON.GUI {
  85054. /**
  85055. * Forcing an export so that this code will execute
  85056. * @hidden
  85057. */
  85058. const name = "Statics";
  85059. }
  85060. declare module BABYLON.GUI {
  85061. /**
  85062. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  85063. */
  85064. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  85065. /**
  85066. * Define the instrumented AdvancedDynamicTexture.
  85067. */
  85068. texture: AdvancedDynamicTexture;
  85069. private _captureRenderTime;
  85070. private _renderTime;
  85071. private _captureLayoutTime;
  85072. private _layoutTime;
  85073. private _onBeginRenderObserver;
  85074. private _onEndRenderObserver;
  85075. private _onBeginLayoutObserver;
  85076. private _onEndLayoutObserver;
  85077. /**
  85078. * Gets the perf counter used to capture render time
  85079. */
  85080. get renderTimeCounter(): BABYLON.PerfCounter;
  85081. /**
  85082. * Gets the perf counter used to capture layout time
  85083. */
  85084. get layoutTimeCounter(): BABYLON.PerfCounter;
  85085. /**
  85086. * Enable or disable the render time capture
  85087. */
  85088. get captureRenderTime(): boolean;
  85089. set captureRenderTime(value: boolean);
  85090. /**
  85091. * Enable or disable the layout time capture
  85092. */
  85093. get captureLayoutTime(): boolean;
  85094. set captureLayoutTime(value: boolean);
  85095. /**
  85096. * Instantiates a new advanced dynamic texture instrumentation.
  85097. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  85098. * @param texture Defines the AdvancedDynamicTexture to instrument
  85099. */
  85100. constructor(
  85101. /**
  85102. * Define the instrumented AdvancedDynamicTexture.
  85103. */
  85104. texture: AdvancedDynamicTexture);
  85105. /**
  85106. * Dispose and release associated resources.
  85107. */
  85108. dispose(): void;
  85109. }
  85110. }
  85111. declare module BABYLON.GUI {
  85112. /**
  85113. * Class used to load GUI via XML.
  85114. */
  85115. export class XmlLoader {
  85116. private _nodes;
  85117. private _nodeTypes;
  85118. private _isLoaded;
  85119. private _objectAttributes;
  85120. private _parentClass;
  85121. /**
  85122. * Create a new xml loader
  85123. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  85124. */
  85125. constructor(parentClass?: null);
  85126. private _getChainElement;
  85127. private _getClassAttribute;
  85128. private _createGuiElement;
  85129. private _parseGrid;
  85130. private _parseElement;
  85131. private _prepareSourceElement;
  85132. private _parseElementsFromSource;
  85133. private _parseXml;
  85134. /**
  85135. * Gets if the loading has finished.
  85136. * @returns whether the loading has finished or not
  85137. */
  85138. isLoaded(): boolean;
  85139. /**
  85140. * Gets a loaded node / control by id.
  85141. * @param id the Controls id set in the xml
  85142. * @returns element of type Control
  85143. */
  85144. getNodeById(id: string): any;
  85145. /**
  85146. * Gets all loaded nodes / controls
  85147. * @returns Array of controls
  85148. */
  85149. getNodes(): any;
  85150. /**
  85151. * Initiates the xml layout loading
  85152. * @param xmlFile defines the xml layout to load
  85153. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  85154. * @param callback defines the callback called on layout load.
  85155. */
  85156. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  85157. }
  85158. }
  85159. declare module BABYLON.GUI {
  85160. /**
  85161. * Class used to create containers for controls
  85162. */
  85163. export class Container3D extends Control3D {
  85164. private _blockLayout;
  85165. /**
  85166. * Gets the list of child controls
  85167. */
  85168. protected _children: Control3D[];
  85169. /**
  85170. * Gets the list of child controls
  85171. */
  85172. get children(): Array<Control3D>;
  85173. /**
  85174. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  85175. * This is helpful to optimize layout operation when adding multiple children in a row
  85176. */
  85177. get blockLayout(): boolean;
  85178. set blockLayout(value: boolean);
  85179. /**
  85180. * Creates a new container
  85181. * @param name defines the container name
  85182. */
  85183. constructor(name?: string);
  85184. /**
  85185. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  85186. * @returns the current container
  85187. */
  85188. updateLayout(): Container3D;
  85189. /**
  85190. * Gets a boolean indicating if the given control is in the children of this control
  85191. * @param control defines the control to check
  85192. * @returns true if the control is in the child list
  85193. */
  85194. containsControl(control: Control3D): boolean;
  85195. /**
  85196. * Adds a control to the children of this control
  85197. * @param control defines the control to add
  85198. * @returns the current container
  85199. */
  85200. addControl(control: Control3D): Container3D;
  85201. /**
  85202. * This function will be called everytime a new control is added
  85203. */
  85204. protected _arrangeChildren(): void;
  85205. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  85206. /**
  85207. * Removes a control from the children of this control
  85208. * @param control defines the control to remove
  85209. * @returns the current container
  85210. */
  85211. removeControl(control: Control3D): Container3D;
  85212. protected _getTypeName(): string;
  85213. /**
  85214. * Releases all associated resources
  85215. */
  85216. dispose(): void;
  85217. /** Control rotation will remain unchanged */
  85218. static readonly UNSET_ORIENTATION: number;
  85219. /** Control will rotate to make it look at sphere central axis */
  85220. static readonly FACEORIGIN_ORIENTATION: number;
  85221. /** Control will rotate to make it look back at sphere central axis */
  85222. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  85223. /** Control will rotate to look at z axis (0, 0, 1) */
  85224. static readonly FACEFORWARD_ORIENTATION: number;
  85225. /** Control will rotate to look at negative z axis (0, 0, -1) */
  85226. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  85227. }
  85228. }
  85229. declare module BABYLON.GUI {
  85230. /**
  85231. * Class used to manage 3D user interface
  85232. * @see https://doc.babylonjs.com/how_to/gui3d
  85233. */
  85234. export class GUI3DManager implements BABYLON.IDisposable {
  85235. private _scene;
  85236. private _sceneDisposeObserver;
  85237. private _utilityLayer;
  85238. private _rootContainer;
  85239. private _pointerObserver;
  85240. private _pointerOutObserver;
  85241. /** @hidden */
  85242. _lastPickedControl: Control3D;
  85243. /** @hidden */
  85244. _lastControlOver: {
  85245. [pointerId: number]: Control3D;
  85246. };
  85247. /** @hidden */
  85248. _lastControlDown: {
  85249. [pointerId: number]: Control3D;
  85250. };
  85251. /**
  85252. * BABYLON.Observable raised when the point picked by the pointer events changed
  85253. */
  85254. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  85255. /** @hidden */
  85256. _sharedMaterials: {
  85257. [key: string]: BABYLON.Material;
  85258. };
  85259. /** Gets the hosting scene */
  85260. get scene(): BABYLON.Scene;
  85261. /** Gets associated utility layer */
  85262. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  85263. /**
  85264. * Creates a new GUI3DManager
  85265. * @param scene
  85266. */
  85267. constructor(scene?: BABYLON.Scene);
  85268. private _handlePointerOut;
  85269. private _doPicking;
  85270. /**
  85271. * Gets the root container
  85272. */
  85273. get rootContainer(): Container3D;
  85274. /**
  85275. * Gets a boolean indicating if the given control is in the root child list
  85276. * @param control defines the control to check
  85277. * @returns true if the control is in the root child list
  85278. */
  85279. containsControl(control: Control3D): boolean;
  85280. /**
  85281. * Adds a control to the root child list
  85282. * @param control defines the control to add
  85283. * @returns the current manager
  85284. */
  85285. addControl(control: Control3D): GUI3DManager;
  85286. /**
  85287. * Removes a control from the root child list
  85288. * @param control defines the control to remove
  85289. * @returns the current container
  85290. */
  85291. removeControl(control: Control3D): GUI3DManager;
  85292. /**
  85293. * Releases all associated resources
  85294. */
  85295. dispose(): void;
  85296. }
  85297. }
  85298. declare module BABYLON.GUI {
  85299. /**
  85300. * Class used to transport BABYLON.Vector3 information for pointer events
  85301. */
  85302. export class Vector3WithInfo extends BABYLON.Vector3 {
  85303. /** defines the current mouse button index */
  85304. buttonIndex: number;
  85305. /**
  85306. * Creates a new Vector3WithInfo
  85307. * @param source defines the vector3 data to transport
  85308. * @param buttonIndex defines the current mouse button index
  85309. */
  85310. constructor(source: BABYLON.Vector3,
  85311. /** defines the current mouse button index */
  85312. buttonIndex?: number);
  85313. }
  85314. }
  85315. declare module BABYLON.GUI {
  85316. /**
  85317. * Class used as base class for controls
  85318. */
  85319. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  85320. /** Defines the control name */
  85321. name?: string | undefined;
  85322. /** @hidden */
  85323. _host: GUI3DManager;
  85324. private _node;
  85325. private _downCount;
  85326. private _enterCount;
  85327. private _downPointerIds;
  85328. private _isVisible;
  85329. /** Gets or sets the control position in world space */
  85330. get position(): BABYLON.Vector3;
  85331. set position(value: BABYLON.Vector3);
  85332. /** Gets or sets the control scaling in world space */
  85333. get scaling(): BABYLON.Vector3;
  85334. set scaling(value: BABYLON.Vector3);
  85335. /** Callback used to start pointer enter animation */
  85336. pointerEnterAnimation: () => void;
  85337. /** Callback used to start pointer out animation */
  85338. pointerOutAnimation: () => void;
  85339. /** Callback used to start pointer down animation */
  85340. pointerDownAnimation: () => void;
  85341. /** Callback used to start pointer up animation */
  85342. pointerUpAnimation: () => void;
  85343. /**
  85344. * An event triggered when the pointer move over the control
  85345. */
  85346. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  85347. /**
  85348. * An event triggered when the pointer move out of the control
  85349. */
  85350. onPointerOutObservable: BABYLON.Observable<Control3D>;
  85351. /**
  85352. * An event triggered when the pointer taps the control
  85353. */
  85354. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  85355. /**
  85356. * An event triggered when pointer is up
  85357. */
  85358. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  85359. /**
  85360. * An event triggered when a control is clicked on (with a mouse)
  85361. */
  85362. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  85363. /**
  85364. * An event triggered when pointer enters the control
  85365. */
  85366. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  85367. /**
  85368. * Gets or sets the parent container
  85369. */
  85370. parent: BABYLON.Nullable<Container3D>;
  85371. private _behaviors;
  85372. /**
  85373. * Gets the list of attached behaviors
  85374. * @see https://doc.babylonjs.com/features/behaviour
  85375. */
  85376. get behaviors(): BABYLON.Behavior<Control3D>[];
  85377. /**
  85378. * Attach a behavior to the control
  85379. * @see https://doc.babylonjs.com/features/behaviour
  85380. * @param behavior defines the behavior to attach
  85381. * @returns the current control
  85382. */
  85383. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  85384. /**
  85385. * Remove an attached behavior
  85386. * @see https://doc.babylonjs.com/features/behaviour
  85387. * @param behavior defines the behavior to attach
  85388. * @returns the current control
  85389. */
  85390. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  85391. /**
  85392. * Gets an attached behavior by name
  85393. * @param name defines the name of the behavior to look for
  85394. * @see https://doc.babylonjs.com/features/behaviour
  85395. * @returns null if behavior was not found else the requested behavior
  85396. */
  85397. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  85398. /** Gets or sets a boolean indicating if the control is visible */
  85399. get isVisible(): boolean;
  85400. set isVisible(value: boolean);
  85401. /**
  85402. * Creates a new control
  85403. * @param name defines the control name
  85404. */
  85405. constructor(
  85406. /** Defines the control name */
  85407. name?: string | undefined);
  85408. /**
  85409. * Gets a string representing the class name
  85410. */
  85411. get typeName(): string;
  85412. /**
  85413. * Get the current class name of the control.
  85414. * @returns current class name
  85415. */
  85416. getClassName(): string;
  85417. protected _getTypeName(): string;
  85418. /**
  85419. * Gets the transform node used by this control
  85420. */
  85421. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  85422. /**
  85423. * Gets the mesh used to render this control
  85424. */
  85425. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85426. /**
  85427. * Link the control as child of the given node
  85428. * @param node defines the node to link to. Use null to unlink the control
  85429. * @returns the current control
  85430. */
  85431. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  85432. /** @hidden **/
  85433. _prepareNode(scene: BABYLON.Scene): void;
  85434. /**
  85435. * Node creation.
  85436. * Can be overriden by children
  85437. * @param scene defines the scene where the node must be attached
  85438. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  85439. */
  85440. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  85441. /**
  85442. * Affect a material to the given mesh
  85443. * @param mesh defines the mesh which will represent the control
  85444. */
  85445. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  85446. /** @hidden */
  85447. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  85448. /** @hidden */
  85449. _onPointerEnter(target: Control3D): boolean;
  85450. /** @hidden */
  85451. _onPointerOut(target: Control3D): void;
  85452. /** @hidden */
  85453. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  85454. /** @hidden */
  85455. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85456. /** @hidden */
  85457. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  85458. /** @hidden */
  85459. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  85460. /** @hidden */
  85461. _disposeNode(): void;
  85462. /**
  85463. * Releases all associated resources
  85464. */
  85465. dispose(): void;
  85466. }
  85467. }
  85468. declare module BABYLON.GUI {
  85469. /**
  85470. * Class used as a root to all buttons
  85471. */
  85472. export class AbstractButton3D extends Control3D {
  85473. /**
  85474. * Creates a new button
  85475. * @param name defines the control name
  85476. */
  85477. constructor(name?: string);
  85478. protected _getTypeName(): string;
  85479. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  85480. }
  85481. }
  85482. declare module BABYLON.GUI {
  85483. /**
  85484. * Class used to create a button in 3D
  85485. */
  85486. export class Button3D extends AbstractButton3D {
  85487. /** @hidden */
  85488. protected _currentMaterial: BABYLON.Material;
  85489. private _facadeTexture;
  85490. private _content;
  85491. private _contentResolution;
  85492. private _contentScaleRatio;
  85493. /**
  85494. * Gets or sets the texture resolution used to render content (512 by default)
  85495. */
  85496. get contentResolution(): BABYLON.int;
  85497. set contentResolution(value: BABYLON.int);
  85498. /**
  85499. * Gets or sets the texture scale ratio used to render content (2 by default)
  85500. */
  85501. get contentScaleRatio(): number;
  85502. set contentScaleRatio(value: number);
  85503. protected _disposeFacadeTexture(): void;
  85504. protected _resetContent(): void;
  85505. /**
  85506. * Creates a new button
  85507. * @param name defines the control name
  85508. */
  85509. constructor(name?: string);
  85510. /**
  85511. * Gets or sets the GUI 2D content used to display the button's facade
  85512. */
  85513. get content(): Control;
  85514. set content(value: Control);
  85515. /**
  85516. * Apply the facade texture (created from the content property).
  85517. * This function can be overloaded by child classes
  85518. * @param facadeTexture defines the AdvancedDynamicTexture to use
  85519. */
  85520. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  85521. protected _getTypeName(): string;
  85522. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  85523. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  85524. /**
  85525. * Releases all associated resources
  85526. */
  85527. dispose(): void;
  85528. }
  85529. }
  85530. declare module BABYLON.GUI {
  85531. /**
  85532. * Abstract class used to create a container panel deployed on the surface of a volume
  85533. */
  85534. export abstract class VolumeBasedPanel extends Container3D {
  85535. private _columns;
  85536. private _rows;
  85537. private _rowThenColum;
  85538. private _orientation;
  85539. protected _cellWidth: number;
  85540. protected _cellHeight: number;
  85541. /**
  85542. * Gets or sets the distance between elements
  85543. */
  85544. margin: number;
  85545. /**
  85546. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  85547. * | Value | Type | Description |
  85548. * | ----- | ----------------------------------- | ----------- |
  85549. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  85550. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  85551. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  85552. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  85553. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  85554. */
  85555. get orientation(): number;
  85556. set orientation(value: number);
  85557. /**
  85558. * Gets or sets the number of columns requested (10 by default).
  85559. * The panel will automatically compute the number of rows based on number of child controls.
  85560. */
  85561. get columns(): BABYLON.int;
  85562. set columns(value: BABYLON.int);
  85563. /**
  85564. * Gets or sets a the number of rows requested.
  85565. * The panel will automatically compute the number of columns based on number of child controls.
  85566. */
  85567. get rows(): BABYLON.int;
  85568. set rows(value: BABYLON.int);
  85569. /**
  85570. * Creates new VolumeBasedPanel
  85571. */
  85572. constructor();
  85573. protected _arrangeChildren(): void;
  85574. /** Child classes must implement this function to provide correct control positioning */
  85575. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85576. /** Child classes can implement this function to provide additional processing */
  85577. protected _finalProcessing(): void;
  85578. }
  85579. }
  85580. declare module BABYLON.GUI {
  85581. /**
  85582. * Class used to create a container panel deployed on the surface of a cylinder
  85583. */
  85584. export class CylinderPanel extends VolumeBasedPanel {
  85585. private _radius;
  85586. /**
  85587. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  85588. */
  85589. get radius(): BABYLON.float;
  85590. set radius(value: BABYLON.float);
  85591. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85592. private _cylindricalMapping;
  85593. }
  85594. }
  85595. declare module BABYLON.GUI {
  85596. /** @hidden */
  85597. export var fluentVertexShader: {
  85598. name: string;
  85599. shader: string;
  85600. };
  85601. }
  85602. declare module BABYLON.GUI {
  85603. /** @hidden */
  85604. export var fluentPixelShader: {
  85605. name: string;
  85606. shader: string;
  85607. };
  85608. }
  85609. declare module BABYLON.GUI {
  85610. /** @hidden */
  85611. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  85612. INNERGLOW: boolean;
  85613. BORDER: boolean;
  85614. HOVERLIGHT: boolean;
  85615. TEXTURE: boolean;
  85616. constructor();
  85617. }
  85618. /**
  85619. * Class used to render controls with fluent desgin
  85620. */
  85621. export class FluentMaterial extends BABYLON.PushMaterial {
  85622. /**
  85623. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  85624. */
  85625. innerGlowColorIntensity: number;
  85626. /**
  85627. * Gets or sets the inner glow color (white by default)
  85628. */
  85629. innerGlowColor: BABYLON.Color3;
  85630. /**
  85631. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  85632. */
  85633. albedoColor: BABYLON.Color3;
  85634. /**
  85635. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  85636. */
  85637. renderBorders: boolean;
  85638. /**
  85639. * Gets or sets border width (default is 0.5)
  85640. */
  85641. borderWidth: number;
  85642. /**
  85643. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  85644. */
  85645. edgeSmoothingValue: number;
  85646. /**
  85647. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  85648. */
  85649. borderMinValue: number;
  85650. /**
  85651. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  85652. */
  85653. renderHoverLight: boolean;
  85654. /**
  85655. * Gets or sets the radius used to render the hover light (default is 1.0)
  85656. */
  85657. hoverRadius: number;
  85658. /**
  85659. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  85660. */
  85661. hoverColor: BABYLON.Color4;
  85662. /**
  85663. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  85664. */
  85665. hoverPosition: BABYLON.Vector3;
  85666. private _albedoTexture;
  85667. /** Gets or sets the texture to use for albedo color */
  85668. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  85669. /**
  85670. * Creates a new Fluent material
  85671. * @param name defines the name of the material
  85672. * @param scene defines the hosting scene
  85673. */
  85674. constructor(name: string, scene: BABYLON.Scene);
  85675. needAlphaBlending(): boolean;
  85676. needAlphaTesting(): boolean;
  85677. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85678. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85679. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85680. getActiveTextures(): BABYLON.BaseTexture[];
  85681. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85682. dispose(forceDisposeEffect?: boolean): void;
  85683. clone(name: string): FluentMaterial;
  85684. serialize(): any;
  85685. getClassName(): string;
  85686. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  85687. }
  85688. }
  85689. declare module BABYLON.GUI {
  85690. /**
  85691. * Class used to create a holographic button in 3D
  85692. */
  85693. export class HolographicButton extends Button3D {
  85694. private _backPlate;
  85695. private _textPlate;
  85696. private _frontPlate;
  85697. private _text;
  85698. private _imageUrl;
  85699. private _shareMaterials;
  85700. private _frontMaterial;
  85701. private _backMaterial;
  85702. private _plateMaterial;
  85703. private _pickedPointObserver;
  85704. private _tooltipFade;
  85705. private _tooltipTextBlock;
  85706. private _tooltipTexture;
  85707. private _tooltipMesh;
  85708. private _tooltipHoverObserver;
  85709. private _tooltipOutObserver;
  85710. private _disposeTooltip;
  85711. /**
  85712. * Rendering ground id of all the mesh in the button
  85713. */
  85714. set renderingGroupId(id: number);
  85715. get renderingGroupId(): number;
  85716. /**
  85717. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  85718. */
  85719. set tooltipText(text: BABYLON.Nullable<string>);
  85720. get tooltipText(): BABYLON.Nullable<string>;
  85721. /**
  85722. * Gets or sets text for the button
  85723. */
  85724. get text(): string;
  85725. set text(value: string);
  85726. /**
  85727. * Gets or sets the image url for the button
  85728. */
  85729. get imageUrl(): string;
  85730. set imageUrl(value: string);
  85731. /**
  85732. * Gets the back material used by this button
  85733. */
  85734. get backMaterial(): FluentMaterial;
  85735. /**
  85736. * Gets the front material used by this button
  85737. */
  85738. get frontMaterial(): FluentMaterial;
  85739. /**
  85740. * Gets the plate material used by this button
  85741. */
  85742. get plateMaterial(): BABYLON.StandardMaterial;
  85743. /**
  85744. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  85745. */
  85746. get shareMaterials(): boolean;
  85747. /**
  85748. * Creates a new button
  85749. * @param name defines the control name
  85750. */
  85751. constructor(name?: string, shareMaterials?: boolean);
  85752. protected _getTypeName(): string;
  85753. private _rebuildContent;
  85754. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  85755. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  85756. private _createBackMaterial;
  85757. private _createFrontMaterial;
  85758. private _createPlateMaterial;
  85759. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  85760. /**
  85761. * Releases all associated resources
  85762. */
  85763. dispose(): void;
  85764. }
  85765. }
  85766. declare module BABYLON.GUI {
  85767. /**
  85768. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  85769. */
  85770. export class MeshButton3D extends Button3D {
  85771. /** @hidden */
  85772. protected _currentMesh: BABYLON.Mesh;
  85773. /**
  85774. * Creates a new 3D button based on a mesh
  85775. * @param mesh mesh to become a 3D button
  85776. * @param name defines the control name
  85777. */
  85778. constructor(mesh: BABYLON.Mesh, name?: string);
  85779. protected _getTypeName(): string;
  85780. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  85781. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  85782. }
  85783. }
  85784. declare module BABYLON.GUI {
  85785. /**
  85786. * Class used to create a container panel deployed on the surface of a plane
  85787. */
  85788. export class PlanePanel extends VolumeBasedPanel {
  85789. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85790. }
  85791. }
  85792. declare module BABYLON.GUI {
  85793. /**
  85794. * Class used to create a container panel where items get randomized planar mapping
  85795. */
  85796. export class ScatterPanel extends VolumeBasedPanel {
  85797. private _iteration;
  85798. /**
  85799. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  85800. */
  85801. get iteration(): BABYLON.float;
  85802. set iteration(value: BABYLON.float);
  85803. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85804. private _scatterMapping;
  85805. protected _finalProcessing(): void;
  85806. }
  85807. }
  85808. declare module BABYLON.GUI {
  85809. /**
  85810. * Class used to create a container panel deployed on the surface of a sphere
  85811. */
  85812. export class SpherePanel extends VolumeBasedPanel {
  85813. private _radius;
  85814. /**
  85815. * Gets or sets the radius of the sphere where to project controls (5 by default)
  85816. */
  85817. get radius(): BABYLON.float;
  85818. set radius(value: BABYLON.float);
  85819. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85820. private _sphericalMapping;
  85821. }
  85822. }
  85823. declare module BABYLON.GUI {
  85824. /**
  85825. * Class used to create a stack panel in 3D on XY plane
  85826. */
  85827. export class StackPanel3D extends Container3D {
  85828. private _isVertical;
  85829. /**
  85830. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  85831. */
  85832. get isVertical(): boolean;
  85833. set isVertical(value: boolean);
  85834. /**
  85835. * Gets or sets the distance between elements
  85836. */
  85837. margin: number;
  85838. /**
  85839. * Creates new StackPanel
  85840. * @param isVertical
  85841. */
  85842. constructor(isVertical?: boolean);
  85843. protected _arrangeChildren(): void;
  85844. }
  85845. }
  85846. declare module BABYLON {
  85847. /**
  85848. * Configuration for glTF validation
  85849. */
  85850. export interface IGLTFValidationConfiguration {
  85851. /**
  85852. * The url of the glTF validator.
  85853. */
  85854. url: string;
  85855. }
  85856. /**
  85857. * glTF validation
  85858. */
  85859. export class GLTFValidation {
  85860. /**
  85861. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  85862. */
  85863. static Configuration: IGLTFValidationConfiguration;
  85864. private static _LoadScriptPromise;
  85865. /**
  85866. * Validate a glTF asset using the glTF-Validator.
  85867. * @param data The JSON of a glTF or the array buffer of a binary glTF
  85868. * @param rootUrl The root url for the glTF
  85869. * @param fileName The file name for the glTF
  85870. * @param getExternalResource The callback to get external resources for the glTF validator
  85871. * @returns A promise that resolves with the glTF validation results once complete
  85872. */
  85873. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  85874. }
  85875. }
  85876. declare module BABYLON {
  85877. /**
  85878. * Mode that determines the coordinate system to use.
  85879. */
  85880. export enum GLTFLoaderCoordinateSystemMode {
  85881. /**
  85882. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  85883. */
  85884. AUTO = 0,
  85885. /**
  85886. * Sets the useRightHandedSystem flag on the scene.
  85887. */
  85888. FORCE_RIGHT_HANDED = 1
  85889. }
  85890. /**
  85891. * Mode that determines what animations will start.
  85892. */
  85893. export enum GLTFLoaderAnimationStartMode {
  85894. /**
  85895. * No animation will start.
  85896. */
  85897. NONE = 0,
  85898. /**
  85899. * The first animation will start.
  85900. */
  85901. FIRST = 1,
  85902. /**
  85903. * All animations will start.
  85904. */
  85905. ALL = 2
  85906. }
  85907. /**
  85908. * Interface that contains the data for the glTF asset.
  85909. */
  85910. export interface IGLTFLoaderData {
  85911. /**
  85912. * The object that represents the glTF JSON.
  85913. */
  85914. json: Object;
  85915. /**
  85916. * The BIN chunk of a binary glTF.
  85917. */
  85918. bin: Nullable<IDataBuffer>;
  85919. }
  85920. /**
  85921. * Interface for extending the loader.
  85922. */
  85923. export interface IGLTFLoaderExtension {
  85924. /**
  85925. * The name of this extension.
  85926. */
  85927. readonly name: string;
  85928. /**
  85929. * Defines whether this extension is enabled.
  85930. */
  85931. enabled: boolean;
  85932. /**
  85933. * Defines the order of this extension.
  85934. * The loader sorts the extensions using these values when loading.
  85935. */
  85936. order?: number;
  85937. }
  85938. /**
  85939. * Loader state.
  85940. */
  85941. export enum GLTFLoaderState {
  85942. /**
  85943. * The asset is loading.
  85944. */
  85945. LOADING = 0,
  85946. /**
  85947. * The asset is ready for rendering.
  85948. */
  85949. READY = 1,
  85950. /**
  85951. * The asset is completely loaded.
  85952. */
  85953. COMPLETE = 2
  85954. }
  85955. /** @hidden */
  85956. export interface IGLTFLoader extends IDisposable {
  85957. readonly state: Nullable<GLTFLoaderState>;
  85958. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  85959. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  85960. }
  85961. /**
  85962. * File loader for loading glTF files into a scene.
  85963. */
  85964. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  85965. /** @hidden */
  85966. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  85967. /** @hidden */
  85968. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  85969. /**
  85970. * Raised when the asset has been parsed
  85971. */
  85972. onParsedObservable: Observable<IGLTFLoaderData>;
  85973. private _onParsedObserver;
  85974. /**
  85975. * Raised when the asset has been parsed
  85976. */
  85977. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  85978. /**
  85979. * 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.
  85980. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  85981. * Defaults to true.
  85982. * @hidden
  85983. */
  85984. static IncrementalLoading: boolean;
  85985. /**
  85986. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  85987. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  85988. * @hidden
  85989. */
  85990. static HomogeneousCoordinates: boolean;
  85991. /**
  85992. * The coordinate system mode. Defaults to AUTO.
  85993. */
  85994. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  85995. /**
  85996. * The animation start mode. Defaults to FIRST.
  85997. */
  85998. animationStartMode: GLTFLoaderAnimationStartMode;
  85999. /**
  86000. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  86001. */
  86002. compileMaterials: boolean;
  86003. /**
  86004. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  86005. */
  86006. useClipPlane: boolean;
  86007. /**
  86008. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  86009. */
  86010. compileShadowGenerators: boolean;
  86011. /**
  86012. * Defines if the Alpha blended materials are only applied as coverage.
  86013. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  86014. * If true, no extra effects are applied to transparent pixels.
  86015. */
  86016. transparencyAsCoverage: boolean;
  86017. /**
  86018. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  86019. * Enabling will disable offline support and glTF validator.
  86020. * Defaults to false.
  86021. */
  86022. useRangeRequests: boolean;
  86023. /**
  86024. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  86025. */
  86026. createInstances: boolean;
  86027. /**
  86028. * 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.
  86029. */
  86030. alwaysComputeBoundingBox: boolean;
  86031. /**
  86032. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  86033. */
  86034. loadAllMaterials: boolean;
  86035. /**
  86036. * Function called before loading a url referenced by the asset.
  86037. */
  86038. preprocessUrlAsync: (url: string) => Promise<string>;
  86039. /**
  86040. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86041. * 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, ...)
  86042. */
  86043. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  86044. private _onMeshLoadedObserver;
  86045. /**
  86046. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86047. * 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, ...)
  86048. */
  86049. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  86050. /**
  86051. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  86052. */
  86053. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  86054. private _onTextureLoadedObserver;
  86055. /**
  86056. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  86057. */
  86058. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  86059. /**
  86060. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  86061. */
  86062. readonly onMaterialLoadedObservable: Observable<Material>;
  86063. private _onMaterialLoadedObserver;
  86064. /**
  86065. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  86066. */
  86067. set onMaterialLoaded(callback: (material: Material) => void);
  86068. /**
  86069. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  86070. */
  86071. readonly onCameraLoadedObservable: Observable<Camera>;
  86072. private _onCameraLoadedObserver;
  86073. /**
  86074. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  86075. */
  86076. set onCameraLoaded(callback: (camera: Camera) => void);
  86077. /**
  86078. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  86079. * For assets with LODs, raised when all of the LODs are complete.
  86080. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86081. */
  86082. readonly onCompleteObservable: Observable<void>;
  86083. private _onCompleteObserver;
  86084. /**
  86085. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  86086. * For assets with LODs, raised when all of the LODs are complete.
  86087. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86088. */
  86089. set onComplete(callback: () => void);
  86090. /**
  86091. * Observable raised when an error occurs.
  86092. */
  86093. readonly onErrorObservable: Observable<any>;
  86094. private _onErrorObserver;
  86095. /**
  86096. * Callback raised when an error occurs.
  86097. */
  86098. set onError(callback: (reason: any) => void);
  86099. /**
  86100. * Observable raised after the loader is disposed.
  86101. */
  86102. readonly onDisposeObservable: Observable<void>;
  86103. private _onDisposeObserver;
  86104. /**
  86105. * Callback raised after the loader is disposed.
  86106. */
  86107. set onDispose(callback: () => void);
  86108. /**
  86109. * Observable raised after a loader extension is created.
  86110. * Set additional options for a loader extension in this event.
  86111. */
  86112. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  86113. private _onExtensionLoadedObserver;
  86114. /**
  86115. * Callback raised after a loader extension is created.
  86116. */
  86117. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  86118. /**
  86119. * Defines if the loader logging is enabled.
  86120. */
  86121. get loggingEnabled(): boolean;
  86122. set loggingEnabled(value: boolean);
  86123. /**
  86124. * Defines if the loader should capture performance counters.
  86125. */
  86126. get capturePerformanceCounters(): boolean;
  86127. set capturePerformanceCounters(value: boolean);
  86128. /**
  86129. * Defines if the loader should validate the asset.
  86130. */
  86131. validate: boolean;
  86132. /**
  86133. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  86134. */
  86135. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  86136. private _onValidatedObserver;
  86137. /**
  86138. * Callback raised after a loader extension is created.
  86139. */
  86140. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  86141. private _loader;
  86142. private _progressCallback?;
  86143. private _requests;
  86144. private static magicBase64Encoded;
  86145. /**
  86146. * Name of the loader ("gltf")
  86147. */
  86148. name: string;
  86149. /** @hidden */
  86150. extensions: ISceneLoaderPluginExtensions;
  86151. /**
  86152. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  86153. */
  86154. dispose(): void;
  86155. /** @hidden */
  86156. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86157. /** @hidden */
  86158. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86159. /** @hidden */
  86160. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  86161. /** @hidden */
  86162. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  86163. /** @hidden */
  86164. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  86165. /** @hidden */
  86166. canDirectLoad(data: string): boolean;
  86167. /** @hidden */
  86168. directLoad(scene: Scene, data: string): Promise<any>;
  86169. /**
  86170. * The callback that allows custom handling of the root url based on the response url.
  86171. * @param rootUrl the original root url
  86172. * @param responseURL the response url if available
  86173. * @returns the new root url
  86174. */
  86175. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  86176. /** @hidden */
  86177. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  86178. /**
  86179. * The loader state or null if the loader is not active.
  86180. */
  86181. get loaderState(): Nullable<GLTFLoaderState>;
  86182. /**
  86183. * Returns a promise that resolves when the asset is completely loaded.
  86184. * @returns a promise that resolves when the asset is completely loaded.
  86185. */
  86186. whenCompleteAsync(): Promise<void>;
  86187. /** @hidden */
  86188. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  86189. /** @hidden */
  86190. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  86191. private _onProgress;
  86192. private _validate;
  86193. private _getLoader;
  86194. private _parseJson;
  86195. private _unpackBinaryAsync;
  86196. private _unpackBinaryV1Async;
  86197. private _unpackBinaryV2Async;
  86198. private static _parseVersion;
  86199. private static _compareVersion;
  86200. private static readonly _logSpaces;
  86201. private _logIndentLevel;
  86202. private _loggingEnabled;
  86203. /** @hidden */
  86204. _log: (message: string) => void;
  86205. /** @hidden */
  86206. _logOpen(message: string): void;
  86207. /** @hidden */
  86208. _logClose(): void;
  86209. private _logEnabled;
  86210. private _logDisabled;
  86211. private _capturePerformanceCounters;
  86212. /** @hidden */
  86213. _startPerformanceCounter: (counterName: string) => void;
  86214. /** @hidden */
  86215. _endPerformanceCounter: (counterName: string) => void;
  86216. private _startPerformanceCounterEnabled;
  86217. private _startPerformanceCounterDisabled;
  86218. private _endPerformanceCounterEnabled;
  86219. private _endPerformanceCounterDisabled;
  86220. }
  86221. }
  86222. declare module BABYLON.GLTF1 {
  86223. /**
  86224. * Enums
  86225. * @hidden
  86226. */
  86227. export enum EComponentType {
  86228. BYTE = 5120,
  86229. UNSIGNED_BYTE = 5121,
  86230. SHORT = 5122,
  86231. UNSIGNED_SHORT = 5123,
  86232. FLOAT = 5126
  86233. }
  86234. /** @hidden */
  86235. export enum EShaderType {
  86236. FRAGMENT = 35632,
  86237. VERTEX = 35633
  86238. }
  86239. /** @hidden */
  86240. export enum EParameterType {
  86241. BYTE = 5120,
  86242. UNSIGNED_BYTE = 5121,
  86243. SHORT = 5122,
  86244. UNSIGNED_SHORT = 5123,
  86245. INT = 5124,
  86246. UNSIGNED_INT = 5125,
  86247. FLOAT = 5126,
  86248. FLOAT_VEC2 = 35664,
  86249. FLOAT_VEC3 = 35665,
  86250. FLOAT_VEC4 = 35666,
  86251. INT_VEC2 = 35667,
  86252. INT_VEC3 = 35668,
  86253. INT_VEC4 = 35669,
  86254. BOOL = 35670,
  86255. BOOL_VEC2 = 35671,
  86256. BOOL_VEC3 = 35672,
  86257. BOOL_VEC4 = 35673,
  86258. FLOAT_MAT2 = 35674,
  86259. FLOAT_MAT3 = 35675,
  86260. FLOAT_MAT4 = 35676,
  86261. SAMPLER_2D = 35678
  86262. }
  86263. /** @hidden */
  86264. export enum ETextureWrapMode {
  86265. CLAMP_TO_EDGE = 33071,
  86266. MIRRORED_REPEAT = 33648,
  86267. REPEAT = 10497
  86268. }
  86269. /** @hidden */
  86270. export enum ETextureFilterType {
  86271. NEAREST = 9728,
  86272. LINEAR = 9728,
  86273. NEAREST_MIPMAP_NEAREST = 9984,
  86274. LINEAR_MIPMAP_NEAREST = 9985,
  86275. NEAREST_MIPMAP_LINEAR = 9986,
  86276. LINEAR_MIPMAP_LINEAR = 9987
  86277. }
  86278. /** @hidden */
  86279. export enum ETextureFormat {
  86280. ALPHA = 6406,
  86281. RGB = 6407,
  86282. RGBA = 6408,
  86283. LUMINANCE = 6409,
  86284. LUMINANCE_ALPHA = 6410
  86285. }
  86286. /** @hidden */
  86287. export enum ECullingType {
  86288. FRONT = 1028,
  86289. BACK = 1029,
  86290. FRONT_AND_BACK = 1032
  86291. }
  86292. /** @hidden */
  86293. export enum EBlendingFunction {
  86294. ZERO = 0,
  86295. ONE = 1,
  86296. SRC_COLOR = 768,
  86297. ONE_MINUS_SRC_COLOR = 769,
  86298. DST_COLOR = 774,
  86299. ONE_MINUS_DST_COLOR = 775,
  86300. SRC_ALPHA = 770,
  86301. ONE_MINUS_SRC_ALPHA = 771,
  86302. DST_ALPHA = 772,
  86303. ONE_MINUS_DST_ALPHA = 773,
  86304. CONSTANT_COLOR = 32769,
  86305. ONE_MINUS_CONSTANT_COLOR = 32770,
  86306. CONSTANT_ALPHA = 32771,
  86307. ONE_MINUS_CONSTANT_ALPHA = 32772,
  86308. SRC_ALPHA_SATURATE = 776
  86309. }
  86310. /** @hidden */
  86311. export interface IGLTFProperty {
  86312. extensions?: {
  86313. [key: string]: any;
  86314. };
  86315. extras?: Object;
  86316. }
  86317. /** @hidden */
  86318. export interface IGLTFChildRootProperty extends IGLTFProperty {
  86319. name?: string;
  86320. }
  86321. /** @hidden */
  86322. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  86323. bufferView: string;
  86324. byteOffset: number;
  86325. byteStride: number;
  86326. count: number;
  86327. type: string;
  86328. componentType: EComponentType;
  86329. max?: number[];
  86330. min?: number[];
  86331. name?: string;
  86332. }
  86333. /** @hidden */
  86334. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  86335. buffer: string;
  86336. byteOffset: number;
  86337. byteLength: number;
  86338. byteStride: number;
  86339. target?: number;
  86340. }
  86341. /** @hidden */
  86342. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  86343. uri: string;
  86344. byteLength?: number;
  86345. type?: string;
  86346. }
  86347. /** @hidden */
  86348. export interface IGLTFShader extends IGLTFChildRootProperty {
  86349. uri: string;
  86350. type: EShaderType;
  86351. }
  86352. /** @hidden */
  86353. export interface IGLTFProgram extends IGLTFChildRootProperty {
  86354. attributes: string[];
  86355. fragmentShader: string;
  86356. vertexShader: string;
  86357. }
  86358. /** @hidden */
  86359. export interface IGLTFTechniqueParameter {
  86360. type: number;
  86361. count?: number;
  86362. semantic?: string;
  86363. node?: string;
  86364. value?: number | boolean | string | Array<any>;
  86365. source?: string;
  86366. babylonValue?: any;
  86367. }
  86368. /** @hidden */
  86369. export interface IGLTFTechniqueCommonProfile {
  86370. lightingModel: string;
  86371. texcoordBindings: Object;
  86372. parameters?: Array<any>;
  86373. }
  86374. /** @hidden */
  86375. export interface IGLTFTechniqueStatesFunctions {
  86376. blendColor?: number[];
  86377. blendEquationSeparate?: number[];
  86378. blendFuncSeparate?: number[];
  86379. colorMask: boolean[];
  86380. cullFace: number[];
  86381. }
  86382. /** @hidden */
  86383. export interface IGLTFTechniqueStates {
  86384. enable: number[];
  86385. functions: IGLTFTechniqueStatesFunctions;
  86386. }
  86387. /** @hidden */
  86388. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  86389. parameters: {
  86390. [key: string]: IGLTFTechniqueParameter;
  86391. };
  86392. program: string;
  86393. attributes: {
  86394. [key: string]: string;
  86395. };
  86396. uniforms: {
  86397. [key: string]: string;
  86398. };
  86399. states: IGLTFTechniqueStates;
  86400. }
  86401. /** @hidden */
  86402. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  86403. technique?: string;
  86404. values: string[];
  86405. }
  86406. /** @hidden */
  86407. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  86408. attributes: {
  86409. [key: string]: string;
  86410. };
  86411. indices: string;
  86412. material: string;
  86413. mode?: number;
  86414. }
  86415. /** @hidden */
  86416. export interface IGLTFMesh extends IGLTFChildRootProperty {
  86417. primitives: IGLTFMeshPrimitive[];
  86418. }
  86419. /** @hidden */
  86420. export interface IGLTFImage extends IGLTFChildRootProperty {
  86421. uri: string;
  86422. }
  86423. /** @hidden */
  86424. export interface IGLTFSampler extends IGLTFChildRootProperty {
  86425. magFilter?: number;
  86426. minFilter?: number;
  86427. wrapS?: number;
  86428. wrapT?: number;
  86429. }
  86430. /** @hidden */
  86431. export interface IGLTFTexture extends IGLTFChildRootProperty {
  86432. sampler: string;
  86433. source: string;
  86434. format?: ETextureFormat;
  86435. internalFormat?: ETextureFormat;
  86436. target?: number;
  86437. type?: number;
  86438. babylonTexture?: Texture;
  86439. }
  86440. /** @hidden */
  86441. export interface IGLTFAmbienLight {
  86442. color?: number[];
  86443. }
  86444. /** @hidden */
  86445. export interface IGLTFDirectionalLight {
  86446. color?: number[];
  86447. }
  86448. /** @hidden */
  86449. export interface IGLTFPointLight {
  86450. color?: number[];
  86451. constantAttenuation?: number;
  86452. linearAttenuation?: number;
  86453. quadraticAttenuation?: number;
  86454. }
  86455. /** @hidden */
  86456. export interface IGLTFSpotLight {
  86457. color?: number[];
  86458. constantAttenuation?: number;
  86459. fallOfAngle?: number;
  86460. fallOffExponent?: number;
  86461. linearAttenuation?: number;
  86462. quadraticAttenuation?: number;
  86463. }
  86464. /** @hidden */
  86465. export interface IGLTFLight extends IGLTFChildRootProperty {
  86466. type: string;
  86467. }
  86468. /** @hidden */
  86469. export interface IGLTFCameraOrthographic {
  86470. xmag: number;
  86471. ymag: number;
  86472. zfar: number;
  86473. znear: number;
  86474. }
  86475. /** @hidden */
  86476. export interface IGLTFCameraPerspective {
  86477. aspectRatio: number;
  86478. yfov: number;
  86479. zfar: number;
  86480. znear: number;
  86481. }
  86482. /** @hidden */
  86483. export interface IGLTFCamera extends IGLTFChildRootProperty {
  86484. type: string;
  86485. }
  86486. /** @hidden */
  86487. export interface IGLTFAnimationChannelTarget {
  86488. id: string;
  86489. path: string;
  86490. }
  86491. /** @hidden */
  86492. export interface IGLTFAnimationChannel {
  86493. sampler: string;
  86494. target: IGLTFAnimationChannelTarget;
  86495. }
  86496. /** @hidden */
  86497. export interface IGLTFAnimationSampler {
  86498. input: string;
  86499. output: string;
  86500. interpolation?: string;
  86501. }
  86502. /** @hidden */
  86503. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  86504. channels?: IGLTFAnimationChannel[];
  86505. parameters?: {
  86506. [key: string]: string;
  86507. };
  86508. samplers?: {
  86509. [key: string]: IGLTFAnimationSampler;
  86510. };
  86511. }
  86512. /** @hidden */
  86513. export interface IGLTFNodeInstanceSkin {
  86514. skeletons: string[];
  86515. skin: string;
  86516. meshes: string[];
  86517. }
  86518. /** @hidden */
  86519. export interface IGLTFSkins extends IGLTFChildRootProperty {
  86520. bindShapeMatrix: number[];
  86521. inverseBindMatrices: string;
  86522. jointNames: string[];
  86523. babylonSkeleton?: Skeleton;
  86524. }
  86525. /** @hidden */
  86526. export interface IGLTFNode extends IGLTFChildRootProperty {
  86527. camera?: string;
  86528. children: string[];
  86529. skin?: string;
  86530. jointName?: string;
  86531. light?: string;
  86532. matrix: number[];
  86533. mesh?: string;
  86534. meshes?: string[];
  86535. rotation?: number[];
  86536. scale?: number[];
  86537. translation?: number[];
  86538. babylonNode?: Node;
  86539. }
  86540. /** @hidden */
  86541. export interface IGLTFScene extends IGLTFChildRootProperty {
  86542. nodes: string[];
  86543. }
  86544. /** @hidden */
  86545. export interface IGLTFRuntime {
  86546. extensions: {
  86547. [key: string]: any;
  86548. };
  86549. accessors: {
  86550. [key: string]: IGLTFAccessor;
  86551. };
  86552. buffers: {
  86553. [key: string]: IGLTFBuffer;
  86554. };
  86555. bufferViews: {
  86556. [key: string]: IGLTFBufferView;
  86557. };
  86558. meshes: {
  86559. [key: string]: IGLTFMesh;
  86560. };
  86561. lights: {
  86562. [key: string]: IGLTFLight;
  86563. };
  86564. cameras: {
  86565. [key: string]: IGLTFCamera;
  86566. };
  86567. nodes: {
  86568. [key: string]: IGLTFNode;
  86569. };
  86570. images: {
  86571. [key: string]: IGLTFImage;
  86572. };
  86573. textures: {
  86574. [key: string]: IGLTFTexture;
  86575. };
  86576. shaders: {
  86577. [key: string]: IGLTFShader;
  86578. };
  86579. programs: {
  86580. [key: string]: IGLTFProgram;
  86581. };
  86582. samplers: {
  86583. [key: string]: IGLTFSampler;
  86584. };
  86585. techniques: {
  86586. [key: string]: IGLTFTechnique;
  86587. };
  86588. materials: {
  86589. [key: string]: IGLTFMaterial;
  86590. };
  86591. animations: {
  86592. [key: string]: IGLTFAnimation;
  86593. };
  86594. skins: {
  86595. [key: string]: IGLTFSkins;
  86596. };
  86597. currentScene?: Object;
  86598. scenes: {
  86599. [key: string]: IGLTFScene;
  86600. };
  86601. extensionsUsed: string[];
  86602. extensionsRequired?: string[];
  86603. buffersCount: number;
  86604. shaderscount: number;
  86605. scene: Scene;
  86606. rootUrl: string;
  86607. loadedBufferCount: number;
  86608. loadedBufferViews: {
  86609. [name: string]: ArrayBufferView;
  86610. };
  86611. loadedShaderCount: number;
  86612. importOnlyMeshes: boolean;
  86613. importMeshesNames?: string[];
  86614. dummyNodes: Node[];
  86615. forAssetContainer: boolean;
  86616. }
  86617. /** @hidden */
  86618. export interface INodeToRoot {
  86619. bone: Bone;
  86620. node: IGLTFNode;
  86621. id: string;
  86622. }
  86623. /** @hidden */
  86624. export interface IJointNode {
  86625. node: IGLTFNode;
  86626. id: string;
  86627. }
  86628. }
  86629. declare module BABYLON.GLTF1 {
  86630. /**
  86631. * Utils functions for GLTF
  86632. * @hidden
  86633. */
  86634. export class GLTFUtils {
  86635. /**
  86636. * Sets the given "parameter" matrix
  86637. * @param scene: the Scene object
  86638. * @param source: the source node where to pick the matrix
  86639. * @param parameter: the GLTF technique parameter
  86640. * @param uniformName: the name of the shader's uniform
  86641. * @param shaderMaterial: the shader material
  86642. */
  86643. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  86644. /**
  86645. * Sets the given "parameter" matrix
  86646. * @param shaderMaterial: the shader material
  86647. * @param uniform: the name of the shader's uniform
  86648. * @param value: the value of the uniform
  86649. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  86650. */
  86651. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  86652. /**
  86653. * Returns the wrap mode of the texture
  86654. * @param mode: the mode value
  86655. */
  86656. static GetWrapMode(mode: number): number;
  86657. /**
  86658. * Returns the byte stride giving an accessor
  86659. * @param accessor: the GLTF accessor objet
  86660. */
  86661. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  86662. /**
  86663. * Returns the texture filter mode giving a mode value
  86664. * @param mode: the filter mode value
  86665. */
  86666. static GetTextureFilterMode(mode: number): ETextureFilterType;
  86667. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  86668. /**
  86669. * Returns a buffer from its accessor
  86670. * @param gltfRuntime: the GLTF runtime
  86671. * @param accessor: the GLTF accessor
  86672. */
  86673. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  86674. /**
  86675. * Decodes a buffer view into a string
  86676. * @param view: the buffer view
  86677. */
  86678. static DecodeBufferToText(view: ArrayBufferView): string;
  86679. /**
  86680. * Returns the default material of gltf. Related to
  86681. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  86682. * @param scene: the Babylon.js scene
  86683. */
  86684. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  86685. private static _DefaultMaterial;
  86686. }
  86687. }
  86688. declare module BABYLON.GLTF1 {
  86689. /**
  86690. * Implementation of the base glTF spec
  86691. * @hidden
  86692. */
  86693. export class GLTFLoaderBase {
  86694. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  86695. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  86696. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  86697. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  86698. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  86699. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  86700. }
  86701. /**
  86702. * glTF V1 Loader
  86703. * @hidden
  86704. */
  86705. export class GLTFLoader implements IGLTFLoader {
  86706. static Extensions: {
  86707. [name: string]: GLTFLoaderExtension;
  86708. };
  86709. static RegisterExtension(extension: GLTFLoaderExtension): void;
  86710. state: Nullable<GLTFLoaderState>;
  86711. dispose(): void;
  86712. private _importMeshAsync;
  86713. /**
  86714. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  86715. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  86716. * @param scene the scene the meshes should be added to
  86717. * @param forAssetContainer defines if the entities must be stored in the scene
  86718. * @param data gltf data containing information of the meshes in a loaded file
  86719. * @param rootUrl root url to load from
  86720. * @param onProgress event that fires when loading progress has occured
  86721. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  86722. */
  86723. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  86724. private _loadAsync;
  86725. /**
  86726. * Imports all objects from a loaded gltf file and adds them to the scene
  86727. * @param scene the scene the objects should be added to
  86728. * @param data gltf data containing information of the meshes in a loaded file
  86729. * @param rootUrl root url to load from
  86730. * @param onProgress event that fires when loading progress has occured
  86731. * @returns a promise which completes when objects have been loaded to the scene
  86732. */
  86733. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  86734. private _loadShadersAsync;
  86735. private _loadBuffersAsync;
  86736. private _createNodes;
  86737. }
  86738. /** @hidden */
  86739. export abstract class GLTFLoaderExtension {
  86740. private _name;
  86741. constructor(name: string);
  86742. get name(): string;
  86743. /**
  86744. * Defines an override for loading the runtime
  86745. * Return true to stop further extensions from loading the runtime
  86746. */
  86747. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  86748. /**
  86749. * Defines an onverride for creating gltf runtime
  86750. * Return true to stop further extensions from creating the runtime
  86751. */
  86752. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  86753. /**
  86754. * Defines an override for loading buffers
  86755. * Return true to stop further extensions from loading this buffer
  86756. */
  86757. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  86758. /**
  86759. * Defines an override for loading texture buffers
  86760. * Return true to stop further extensions from loading this texture data
  86761. */
  86762. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  86763. /**
  86764. * Defines an override for creating textures
  86765. * Return true to stop further extensions from loading this texture
  86766. */
  86767. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  86768. /**
  86769. * Defines an override for loading shader strings
  86770. * Return true to stop further extensions from loading this shader data
  86771. */
  86772. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  86773. /**
  86774. * Defines an override for loading materials
  86775. * Return true to stop further extensions from loading this material
  86776. */
  86777. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  86778. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  86779. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  86780. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  86781. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  86782. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  86783. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  86784. private static LoadTextureBufferAsync;
  86785. private static CreateTextureAsync;
  86786. private static ApplyExtensions;
  86787. }
  86788. }
  86789. declare module BABYLON.GLTF1 {
  86790. /** @hidden */
  86791. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  86792. private _bin;
  86793. constructor();
  86794. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  86795. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  86796. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  86797. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  86798. }
  86799. }
  86800. declare module BABYLON.GLTF1 {
  86801. /** @hidden */
  86802. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  86803. constructor();
  86804. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  86805. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  86806. private _loadTexture;
  86807. }
  86808. }
  86809. declare module BABYLON.GLTF2.Loader {
  86810. /**
  86811. * Loader interface with an index field.
  86812. */
  86813. export interface IArrayItem {
  86814. /**
  86815. * The index of this item in the array.
  86816. */
  86817. index: number;
  86818. }
  86819. /**
  86820. * Loader interface with additional members.
  86821. */
  86822. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  86823. /** @hidden */
  86824. _data?: Promise<ArrayBufferView>;
  86825. /** @hidden */
  86826. _babylonVertexBuffer?: Promise<VertexBuffer>;
  86827. }
  86828. /**
  86829. * Loader interface with additional members.
  86830. */
  86831. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  86832. }
  86833. /** @hidden */
  86834. export interface _IAnimationSamplerData {
  86835. input: Float32Array;
  86836. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  86837. output: Float32Array;
  86838. }
  86839. /**
  86840. * Loader interface with additional members.
  86841. */
  86842. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  86843. /** @hidden */
  86844. _data?: Promise<_IAnimationSamplerData>;
  86845. }
  86846. /**
  86847. * Loader interface with additional members.
  86848. */
  86849. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  86850. channels: IAnimationChannel[];
  86851. samplers: IAnimationSampler[];
  86852. /** @hidden */
  86853. _babylonAnimationGroup?: AnimationGroup;
  86854. }
  86855. /**
  86856. * Loader interface with additional members.
  86857. */
  86858. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  86859. /** @hidden */
  86860. _data?: Promise<ArrayBufferView>;
  86861. }
  86862. /**
  86863. * Loader interface with additional members.
  86864. */
  86865. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  86866. /** @hidden */
  86867. _data?: Promise<ArrayBufferView>;
  86868. /** @hidden */
  86869. _babylonBuffer?: Promise<Buffer>;
  86870. }
  86871. /**
  86872. * Loader interface with additional members.
  86873. */
  86874. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  86875. }
  86876. /**
  86877. * Loader interface with additional members.
  86878. */
  86879. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  86880. /** @hidden */
  86881. _data?: Promise<ArrayBufferView>;
  86882. }
  86883. /**
  86884. * Loader interface with additional members.
  86885. */
  86886. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  86887. }
  86888. /**
  86889. * Loader interface with additional members.
  86890. */
  86891. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  86892. }
  86893. /**
  86894. * Loader interface with additional members.
  86895. */
  86896. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  86897. baseColorTexture?: ITextureInfo;
  86898. metallicRoughnessTexture?: ITextureInfo;
  86899. }
  86900. /**
  86901. * Loader interface with additional members.
  86902. */
  86903. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  86904. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  86905. normalTexture?: IMaterialNormalTextureInfo;
  86906. occlusionTexture?: IMaterialOcclusionTextureInfo;
  86907. emissiveTexture?: ITextureInfo;
  86908. /** @hidden */
  86909. _data?: {
  86910. [babylonDrawMode: number]: {
  86911. babylonMaterial: Material;
  86912. babylonMeshes: AbstractMesh[];
  86913. promise: Promise<void>;
  86914. };
  86915. };
  86916. }
  86917. /**
  86918. * Loader interface with additional members.
  86919. */
  86920. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  86921. primitives: IMeshPrimitive[];
  86922. }
  86923. /**
  86924. * Loader interface with additional members.
  86925. */
  86926. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  86927. /** @hidden */
  86928. _instanceData?: {
  86929. babylonSourceMesh: Mesh;
  86930. promise: Promise<any>;
  86931. };
  86932. }
  86933. /**
  86934. * Loader interface with additional members.
  86935. */
  86936. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  86937. /**
  86938. * The parent glTF node.
  86939. */
  86940. parent?: INode;
  86941. /** @hidden */
  86942. _babylonTransformNode?: TransformNode;
  86943. /** @hidden */
  86944. _primitiveBabylonMeshes?: AbstractMesh[];
  86945. /** @hidden */
  86946. _babylonBones?: Bone[];
  86947. /** @hidden */
  86948. _numMorphTargets?: number;
  86949. }
  86950. /** @hidden */
  86951. export interface _ISamplerData {
  86952. noMipMaps: boolean;
  86953. samplingMode: number;
  86954. wrapU: number;
  86955. wrapV: number;
  86956. }
  86957. /**
  86958. * Loader interface with additional members.
  86959. */
  86960. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  86961. /** @hidden */
  86962. _data?: _ISamplerData;
  86963. }
  86964. /**
  86965. * Loader interface with additional members.
  86966. */
  86967. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  86968. }
  86969. /**
  86970. * Loader interface with additional members.
  86971. */
  86972. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  86973. /** @hidden */
  86974. _data?: {
  86975. babylonSkeleton: Skeleton;
  86976. promise: Promise<void>;
  86977. };
  86978. }
  86979. /**
  86980. * Loader interface with additional members.
  86981. */
  86982. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  86983. /** @hidden */
  86984. _textureInfo: ITextureInfo;
  86985. }
  86986. /**
  86987. * Loader interface with additional members.
  86988. */
  86989. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  86990. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  86991. nonColorData?: boolean;
  86992. }
  86993. /**
  86994. * Loader interface with additional members.
  86995. */
  86996. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  86997. accessors?: IAccessor[];
  86998. animations?: IAnimation[];
  86999. buffers?: IBuffer[];
  87000. bufferViews?: IBufferView[];
  87001. cameras?: ICamera[];
  87002. images?: IImage[];
  87003. materials?: IMaterial[];
  87004. meshes?: IMesh[];
  87005. nodes?: INode[];
  87006. samplers?: ISampler[];
  87007. scenes?: IScene[];
  87008. skins?: ISkin[];
  87009. textures?: ITexture[];
  87010. }
  87011. }
  87012. declare module BABYLON.GLTF2 {
  87013. /**
  87014. * Interface for a glTF loader extension.
  87015. */
  87016. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  87017. /**
  87018. * Called after the loader state changes to LOADING.
  87019. */
  87020. onLoading?(): void;
  87021. /**
  87022. * Called after the loader state changes to READY.
  87023. */
  87024. onReady?(): void;
  87025. /**
  87026. * Define this method to modify the default behavior when loading scenes.
  87027. * @param context The context when loading the asset
  87028. * @param scene The glTF scene property
  87029. * @returns A promise that resolves when the load is complete or null if not handled
  87030. */
  87031. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  87032. /**
  87033. * Define this method to modify the default behavior when loading nodes.
  87034. * @param context The context when loading the asset
  87035. * @param node The glTF node property
  87036. * @param assign A function called synchronously after parsing the glTF properties
  87037. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  87038. */
  87039. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87040. /**
  87041. * Define this method to modify the default behavior when loading cameras.
  87042. * @param context The context when loading the asset
  87043. * @param camera The glTF camera property
  87044. * @param assign A function called synchronously after parsing the glTF properties
  87045. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  87046. */
  87047. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  87048. /**
  87049. * @hidden
  87050. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  87051. * @param context The context when loading the asset
  87052. * @param primitive The glTF mesh primitive property
  87053. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  87054. */
  87055. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  87056. /**
  87057. * @hidden
  87058. * Define this method to modify the default behavior when loading data for mesh primitives.
  87059. * @param context The context when loading the asset
  87060. * @param name The mesh name when loading the asset
  87061. * @param node The glTF node when loading the asset
  87062. * @param mesh The glTF mesh when loading the asset
  87063. * @param primitive The glTF mesh primitive property
  87064. * @param assign A function called synchronously after parsing the glTF properties
  87065. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87066. */
  87067. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  87068. /**
  87069. * @hidden
  87070. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  87071. * @param context The context when loading the asset
  87072. * @param material The glTF material property
  87073. * @param assign A function called synchronously after parsing the glTF properties
  87074. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  87075. */
  87076. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  87077. /**
  87078. * Define this method to modify the default behavior when creating materials.
  87079. * @param context The context when loading the asset
  87080. * @param material The glTF material property
  87081. * @param babylonDrawMode The draw mode for the Babylon material
  87082. * @returns The Babylon material or null if not handled
  87083. */
  87084. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  87085. /**
  87086. * Define this method to modify the default behavior when loading material properties.
  87087. * @param context The context when loading the asset
  87088. * @param material The glTF material property
  87089. * @param babylonMaterial The Babylon material
  87090. * @returns A promise that resolves when the load is complete or null if not handled
  87091. */
  87092. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87093. /**
  87094. * Define this method to modify the default behavior when loading texture infos.
  87095. * @param context The context when loading the asset
  87096. * @param textureInfo The glTF texture info property
  87097. * @param assign A function called synchronously after parsing the glTF properties
  87098. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87099. */
  87100. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87101. /**
  87102. * @hidden
  87103. * Define this method to modify the default behavior when loading textures.
  87104. * @param context The context when loading the asset
  87105. * @param texture The glTF texture property
  87106. * @param assign A function called synchronously after parsing the glTF properties
  87107. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87108. */
  87109. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87110. /**
  87111. * Define this method to modify the default behavior when loading animations.
  87112. * @param context The context when loading the asset
  87113. * @param animation The glTF animation property
  87114. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  87115. */
  87116. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  87117. /**
  87118. * @hidden
  87119. * Define this method to modify the default behavior when loading skins.
  87120. * @param context The context when loading the asset
  87121. * @param node The glTF node property
  87122. * @param skin The glTF skin property
  87123. * @returns A promise that resolves when the load is complete or null if not handled
  87124. */
  87125. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  87126. /**
  87127. * @hidden
  87128. * Define this method to modify the default behavior when loading uris.
  87129. * @param context The context when loading the asset
  87130. * @param property The glTF property associated with the uri
  87131. * @param uri The uri to load
  87132. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87133. */
  87134. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  87135. /**
  87136. * Define this method to modify the default behavior when loading buffer views.
  87137. * @param context The context when loading the asset
  87138. * @param bufferView The glTF buffer view property
  87139. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87140. */
  87141. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  87142. /**
  87143. * Define this method to modify the default behavior when loading buffers.
  87144. * @param context The context when loading the asset
  87145. * @param buffer The glTF buffer property
  87146. * @param byteOffset The byte offset to load
  87147. * @param byteLength The byte length to load
  87148. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87149. */
  87150. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  87151. }
  87152. }
  87153. declare module BABYLON.GLTF2 {
  87154. /**
  87155. * Helper class for working with arrays when loading the glTF asset
  87156. */
  87157. export class ArrayItem {
  87158. /**
  87159. * Gets an item from the given array.
  87160. * @param context The context when loading the asset
  87161. * @param array The array to get the item from
  87162. * @param index The index to the array
  87163. * @returns The array item
  87164. */
  87165. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  87166. /**
  87167. * Assign an `index` field to each item of the given array.
  87168. * @param array The array of items
  87169. */
  87170. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  87171. }
  87172. /**
  87173. * The glTF 2.0 loader
  87174. */
  87175. export class GLTFLoader implements IGLTFLoader {
  87176. /** @hidden */
  87177. _completePromises: Promise<any>[];
  87178. /** @hidden */
  87179. _forAssetContainer: boolean;
  87180. /** Storage */
  87181. _babylonLights: Light[];
  87182. /** @hidden */
  87183. _disableInstancedMesh: number;
  87184. private _disposed;
  87185. private _parent;
  87186. private _state;
  87187. private _extensions;
  87188. private _rootUrl;
  87189. private _fileName;
  87190. private _uniqueRootUrl;
  87191. private _gltf;
  87192. private _bin;
  87193. private _babylonScene;
  87194. private _rootBabylonMesh;
  87195. private _defaultBabylonMaterialData;
  87196. private static _RegisteredExtensions;
  87197. /**
  87198. * The default glTF sampler.
  87199. */
  87200. static readonly DefaultSampler: ISampler;
  87201. /**
  87202. * Registers a loader extension.
  87203. * @param name The name of the loader extension.
  87204. * @param factory The factory function that creates the loader extension.
  87205. */
  87206. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  87207. /**
  87208. * Unregisters a loader extension.
  87209. * @param name The name of the loader extension.
  87210. * @returns A boolean indicating whether the extension has been unregistered
  87211. */
  87212. static UnregisterExtension(name: string): boolean;
  87213. /**
  87214. * The loader state.
  87215. */
  87216. get state(): Nullable<GLTFLoaderState>;
  87217. /**
  87218. * The object that represents the glTF JSON.
  87219. */
  87220. get gltf(): IGLTF;
  87221. /**
  87222. * The BIN chunk of a binary glTF.
  87223. */
  87224. get bin(): Nullable<IDataBuffer>;
  87225. /**
  87226. * The parent file loader.
  87227. */
  87228. get parent(): GLTFFileLoader;
  87229. /**
  87230. * The Babylon scene when loading the asset.
  87231. */
  87232. get babylonScene(): Scene;
  87233. /**
  87234. * The root Babylon mesh when loading the asset.
  87235. */
  87236. get rootBabylonMesh(): Mesh;
  87237. /** @hidden */
  87238. constructor(parent: GLTFFileLoader);
  87239. /** @hidden */
  87240. dispose(): void;
  87241. /** @hidden */
  87242. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87243. /** @hidden */
  87244. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87245. private _loadAsync;
  87246. private _loadData;
  87247. private _setupData;
  87248. private _loadExtensions;
  87249. private _checkExtensions;
  87250. private _setState;
  87251. private _createRootNode;
  87252. /**
  87253. * Loads a glTF scene.
  87254. * @param context The context when loading the asset
  87255. * @param scene The glTF scene property
  87256. * @returns A promise that resolves when the load is complete
  87257. */
  87258. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  87259. private _forEachPrimitive;
  87260. private _getGeometries;
  87261. private _getMeshes;
  87262. private _getTransformNodes;
  87263. private _getSkeletons;
  87264. private _getAnimationGroups;
  87265. private _startAnimations;
  87266. /**
  87267. * Loads a glTF node.
  87268. * @param context The context when loading the asset
  87269. * @param node The glTF node property
  87270. * @param assign A function called synchronously after parsing the glTF properties
  87271. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  87272. */
  87273. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  87274. private _loadMeshAsync;
  87275. /**
  87276. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  87277. * @param context The context when loading the asset
  87278. * @param name The mesh name when loading the asset
  87279. * @param node The glTF node when loading the asset
  87280. * @param mesh The glTF mesh when loading the asset
  87281. * @param primitive The glTF mesh primitive property
  87282. * @param assign A function called synchronously after parsing the glTF properties
  87283. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87284. */
  87285. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  87286. private _loadVertexDataAsync;
  87287. private _createMorphTargets;
  87288. private _loadMorphTargetsAsync;
  87289. private _loadMorphTargetVertexDataAsync;
  87290. private static _LoadTransform;
  87291. private _loadSkinAsync;
  87292. private _loadBones;
  87293. private _loadBone;
  87294. private _loadSkinInverseBindMatricesDataAsync;
  87295. private _updateBoneMatrices;
  87296. private _getNodeMatrix;
  87297. /**
  87298. * Loads a glTF camera.
  87299. * @param context The context when loading the asset
  87300. * @param camera The glTF camera property
  87301. * @param assign A function called synchronously after parsing the glTF properties
  87302. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  87303. */
  87304. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  87305. private _loadAnimationsAsync;
  87306. /**
  87307. * Loads a glTF animation.
  87308. * @param context The context when loading the asset
  87309. * @param animation The glTF animation property
  87310. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  87311. */
  87312. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  87313. /**
  87314. * @hidden Loads a glTF animation channel.
  87315. * @param context The context when loading the asset
  87316. * @param animationContext The context of the animation when loading the asset
  87317. * @param animation The glTF animation property
  87318. * @param channel The glTF animation channel property
  87319. * @param babylonAnimationGroup The babylon animation group property
  87320. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  87321. * @returns A void promise when the channel load is complete
  87322. */
  87323. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  87324. private _loadAnimationSamplerAsync;
  87325. /**
  87326. * Loads a glTF buffer.
  87327. * @param context The context when loading the asset
  87328. * @param buffer The glTF buffer property
  87329. * @param byteOffset The byte offset to use
  87330. * @param byteLength The byte length to use
  87331. * @returns A promise that resolves with the loaded data when the load is complete
  87332. */
  87333. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  87334. /**
  87335. * Loads a glTF buffer view.
  87336. * @param context The context when loading the asset
  87337. * @param bufferView The glTF buffer view property
  87338. * @returns A promise that resolves with the loaded data when the load is complete
  87339. */
  87340. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  87341. private _loadAccessorAsync;
  87342. /** @hidden */
  87343. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  87344. private _loadIndicesAccessorAsync;
  87345. private _loadVertexBufferViewAsync;
  87346. private _loadVertexAccessorAsync;
  87347. private _loadMaterialMetallicRoughnessPropertiesAsync;
  87348. /** @hidden */
  87349. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  87350. private _createDefaultMaterial;
  87351. /**
  87352. * Creates a Babylon material from a glTF material.
  87353. * @param context The context when loading the asset
  87354. * @param material The glTF material property
  87355. * @param babylonDrawMode The draw mode for the Babylon material
  87356. * @returns The Babylon material
  87357. */
  87358. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  87359. /**
  87360. * Loads properties from a glTF material into a Babylon material.
  87361. * @param context The context when loading the asset
  87362. * @param material The glTF material property
  87363. * @param babylonMaterial The Babylon material
  87364. * @returns A promise that resolves when the load is complete
  87365. */
  87366. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  87367. /**
  87368. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  87369. * @param context The context when loading the asset
  87370. * @param material The glTF material property
  87371. * @param babylonMaterial The Babylon material
  87372. * @returns A promise that resolves when the load is complete
  87373. */
  87374. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  87375. /**
  87376. * Loads the alpha properties from a glTF material into a Babylon material.
  87377. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  87378. * @param context The context when loading the asset
  87379. * @param material The glTF material property
  87380. * @param babylonMaterial The Babylon material
  87381. */
  87382. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  87383. /**
  87384. * Loads a glTF texture info.
  87385. * @param context The context when loading the asset
  87386. * @param textureInfo The glTF texture info property
  87387. * @param assign A function called synchronously after parsing the glTF properties
  87388. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  87389. */
  87390. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  87391. /** @hidden */
  87392. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  87393. /** @hidden */
  87394. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  87395. private _loadSampler;
  87396. /**
  87397. * Loads a glTF image.
  87398. * @param context The context when loading the asset
  87399. * @param image The glTF image property
  87400. * @returns A promise that resolves with the loaded data when the load is complete
  87401. */
  87402. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  87403. /**
  87404. * Loads a glTF uri.
  87405. * @param context The context when loading the asset
  87406. * @param property The glTF property associated with the uri
  87407. * @param uri The base64 or relative uri
  87408. * @returns A promise that resolves with the loaded data when the load is complete
  87409. */
  87410. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  87411. /**
  87412. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  87413. * @param babylonObject the Babylon object with metadata
  87414. * @param pointer the JSON pointer
  87415. */
  87416. static AddPointerMetadata(babylonObject: {
  87417. metadata: any;
  87418. }, pointer: string): void;
  87419. private static _GetTextureWrapMode;
  87420. private static _GetTextureSamplingMode;
  87421. private static _GetTypedArrayConstructor;
  87422. private static _GetTypedArray;
  87423. private static _GetNumComponents;
  87424. private static _ValidateUri;
  87425. /** @hidden */
  87426. static _GetDrawMode(context: string, mode: number | undefined): number;
  87427. private _compileMaterialsAsync;
  87428. private _compileShadowGeneratorsAsync;
  87429. private _forEachExtensions;
  87430. private _applyExtensions;
  87431. private _extensionsOnLoading;
  87432. private _extensionsOnReady;
  87433. private _extensionsLoadSceneAsync;
  87434. private _extensionsLoadNodeAsync;
  87435. private _extensionsLoadCameraAsync;
  87436. private _extensionsLoadVertexDataAsync;
  87437. private _extensionsLoadMeshPrimitiveAsync;
  87438. private _extensionsLoadMaterialAsync;
  87439. private _extensionsCreateMaterial;
  87440. private _extensionsLoadMaterialPropertiesAsync;
  87441. private _extensionsLoadTextureInfoAsync;
  87442. private _extensionsLoadTextureAsync;
  87443. private _extensionsLoadAnimationAsync;
  87444. private _extensionsLoadSkinAsync;
  87445. private _extensionsLoadUriAsync;
  87446. private _extensionsLoadBufferViewAsync;
  87447. private _extensionsLoadBufferAsync;
  87448. /**
  87449. * Helper method called by a loader extension to load an glTF extension.
  87450. * @param context The context when loading the asset
  87451. * @param property The glTF property to load the extension from
  87452. * @param extensionName The name of the extension to load
  87453. * @param actionAsync The action to run
  87454. * @returns The promise returned by actionAsync or null if the extension does not exist
  87455. */
  87456. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  87457. /**
  87458. * Helper method called by a loader extension to load a glTF extra.
  87459. * @param context The context when loading the asset
  87460. * @param property The glTF property to load the extra from
  87461. * @param extensionName The name of the extension to load
  87462. * @param actionAsync The action to run
  87463. * @returns The promise returned by actionAsync or null if the extra does not exist
  87464. */
  87465. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  87466. /**
  87467. * Checks for presence of an extension.
  87468. * @param name The name of the extension to check
  87469. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  87470. */
  87471. isExtensionUsed(name: string): boolean;
  87472. /**
  87473. * Increments the indentation level and logs a message.
  87474. * @param message The message to log
  87475. */
  87476. logOpen(message: string): void;
  87477. /**
  87478. * Decrements the indentation level.
  87479. */
  87480. logClose(): void;
  87481. /**
  87482. * Logs a message
  87483. * @param message The message to log
  87484. */
  87485. log(message: string): void;
  87486. /**
  87487. * Starts a performance counter.
  87488. * @param counterName The name of the performance counter
  87489. */
  87490. startPerformanceCounter(counterName: string): void;
  87491. /**
  87492. * Ends a performance counter.
  87493. * @param counterName The name of the performance counter
  87494. */
  87495. endPerformanceCounter(counterName: string): void;
  87496. }
  87497. }
  87498. declare module BABYLON.GLTF2.Loader.Extensions {
  87499. /** @hidden */
  87500. interface IEXTLightsImageBased_LightImageBased {
  87501. _babylonTexture?: BaseTexture;
  87502. _loaded?: Promise<void>;
  87503. }
  87504. /**
  87505. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  87506. */
  87507. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  87508. /**
  87509. * The name of this extension.
  87510. */
  87511. readonly name: string;
  87512. /**
  87513. * Defines whether this extension is enabled.
  87514. */
  87515. enabled: boolean;
  87516. private _loader;
  87517. private _lights?;
  87518. /** @hidden */
  87519. constructor(loader: GLTFLoader);
  87520. /** @hidden */
  87521. dispose(): void;
  87522. /** @hidden */
  87523. onLoading(): void;
  87524. /** @hidden */
  87525. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  87526. private _loadLightAsync;
  87527. }
  87528. }
  87529. declare module BABYLON.GLTF2.Loader.Extensions {
  87530. /**
  87531. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  87532. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  87533. * !!! Experimental Extension Subject to Changes !!!
  87534. */
  87535. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  87536. /**
  87537. * The name of this extension.
  87538. */
  87539. readonly name: string;
  87540. /**
  87541. * Defines whether this extension is enabled.
  87542. */
  87543. enabled: boolean;
  87544. private _loader;
  87545. /** @hidden */
  87546. constructor(loader: GLTFLoader);
  87547. /** @hidden */
  87548. dispose(): void;
  87549. /** @hidden */
  87550. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87551. }
  87552. }
  87553. declare module BABYLON.GLTF2.Loader.Extensions {
  87554. /**
  87555. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  87556. *
  87557. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  87558. */
  87559. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  87560. /**
  87561. * The name of this extension.
  87562. */
  87563. readonly name: string;
  87564. /**
  87565. * Defines whether this extension is enabled.
  87566. */
  87567. enabled: boolean;
  87568. /**
  87569. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  87570. */
  87571. static DecoderPath: string;
  87572. private _loader;
  87573. private _decoderPromise?;
  87574. /** @hidden */
  87575. constructor(loader: GLTFLoader);
  87576. /** @hidden */
  87577. dispose(): void;
  87578. /** @hidden */
  87579. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  87580. }
  87581. }
  87582. declare module BABYLON.GLTF2.Loader.Extensions {
  87583. /**
  87584. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  87585. */
  87586. export class EXT_texture_webp implements IGLTFLoaderExtension {
  87587. /** The name of this extension. */
  87588. readonly name: string;
  87589. /** Defines whether this extension is enabled. */
  87590. enabled: boolean;
  87591. private _loader;
  87592. /** @hidden */
  87593. constructor(loader: GLTFLoader);
  87594. /** @hidden */
  87595. dispose(): void;
  87596. /** @hidden */
  87597. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87598. }
  87599. }
  87600. declare module BABYLON.GLTF2.Loader.Extensions {
  87601. /**
  87602. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  87603. */
  87604. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  87605. /**
  87606. * The name of this extension.
  87607. */
  87608. readonly name: string;
  87609. /**
  87610. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  87611. */
  87612. dracoCompression?: DracoCompression;
  87613. /**
  87614. * Defines whether this extension is enabled.
  87615. */
  87616. enabled: boolean;
  87617. private _loader;
  87618. /** @hidden */
  87619. constructor(loader: GLTFLoader);
  87620. /** @hidden */
  87621. dispose(): void;
  87622. /** @hidden */
  87623. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  87624. }
  87625. }
  87626. declare module BABYLON.GLTF2.Loader.Extensions {
  87627. /**
  87628. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  87629. */
  87630. export class KHR_lights implements IGLTFLoaderExtension {
  87631. /**
  87632. * The name of this extension.
  87633. */
  87634. readonly name: string;
  87635. /**
  87636. * Defines whether this extension is enabled.
  87637. */
  87638. enabled: boolean;
  87639. private _loader;
  87640. private _lights?;
  87641. /** @hidden */
  87642. constructor(loader: GLTFLoader);
  87643. /** @hidden */
  87644. dispose(): void;
  87645. /** @hidden */
  87646. onLoading(): void;
  87647. /** @hidden */
  87648. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87649. }
  87650. }
  87651. declare module BABYLON.GLTF2.Loader.Extensions {
  87652. /**
  87653. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  87654. */
  87655. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  87656. /**
  87657. * The name of this extension.
  87658. */
  87659. readonly name: string;
  87660. /**
  87661. * Defines whether this extension is enabled.
  87662. */
  87663. enabled: boolean;
  87664. /**
  87665. * Defines a number that determines the order the extensions are applied.
  87666. */
  87667. order: number;
  87668. private _loader;
  87669. /** @hidden */
  87670. constructor(loader: GLTFLoader);
  87671. /** @hidden */
  87672. dispose(): void;
  87673. /** @hidden */
  87674. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87675. private _loadSpecularGlossinessPropertiesAsync;
  87676. }
  87677. }
  87678. declare module BABYLON.GLTF2.Loader.Extensions {
  87679. /**
  87680. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  87681. */
  87682. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  87683. /**
  87684. * The name of this extension.
  87685. */
  87686. readonly name: string;
  87687. /**
  87688. * Defines whether this extension is enabled.
  87689. */
  87690. enabled: boolean;
  87691. /**
  87692. * Defines a number that determines the order the extensions are applied.
  87693. */
  87694. order: number;
  87695. private _loader;
  87696. /** @hidden */
  87697. constructor(loader: GLTFLoader);
  87698. /** @hidden */
  87699. dispose(): void;
  87700. /** @hidden */
  87701. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87702. private _loadUnlitPropertiesAsync;
  87703. }
  87704. }
  87705. declare module BABYLON.GLTF2.Loader.Extensions {
  87706. /**
  87707. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  87708. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  87709. */
  87710. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  87711. /**
  87712. * The name of this extension.
  87713. */
  87714. readonly name: string;
  87715. /**
  87716. * Defines whether this extension is enabled.
  87717. */
  87718. enabled: boolean;
  87719. /**
  87720. * Defines a number that determines the order the extensions are applied.
  87721. */
  87722. order: number;
  87723. private _loader;
  87724. /** @hidden */
  87725. constructor(loader: GLTFLoader);
  87726. /** @hidden */
  87727. dispose(): void;
  87728. /** @hidden */
  87729. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87730. private _loadClearCoatPropertiesAsync;
  87731. }
  87732. }
  87733. declare module BABYLON.GLTF2.Loader.Extensions {
  87734. /**
  87735. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  87736. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  87737. * !!! Experimental Extension Subject to Changes !!!
  87738. */
  87739. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  87740. /**
  87741. * The name of this extension.
  87742. */
  87743. readonly name: string;
  87744. /**
  87745. * Defines whether this extension is enabled.
  87746. */
  87747. enabled: boolean;
  87748. /**
  87749. * Defines a number that determines the order the extensions are applied.
  87750. */
  87751. order: number;
  87752. private _loader;
  87753. /** @hidden */
  87754. constructor(loader: GLTFLoader);
  87755. /** @hidden */
  87756. dispose(): void;
  87757. /** @hidden */
  87758. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87759. private _loadSheenPropertiesAsync;
  87760. }
  87761. }
  87762. declare module BABYLON.GLTF2.Loader.Extensions {
  87763. /**
  87764. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  87765. * !!! Experimental Extension Subject to Changes !!!
  87766. */
  87767. export class KHR_materials_specular implements IGLTFLoaderExtension {
  87768. /**
  87769. * The name of this extension.
  87770. */
  87771. readonly name: string;
  87772. /**
  87773. * Defines whether this extension is enabled.
  87774. */
  87775. enabled: boolean;
  87776. /**
  87777. * Defines a number that determines the order the extensions are applied.
  87778. */
  87779. order: number;
  87780. private _loader;
  87781. /** @hidden */
  87782. constructor(loader: GLTFLoader);
  87783. /** @hidden */
  87784. dispose(): void;
  87785. /** @hidden */
  87786. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87787. private _loadSpecularPropertiesAsync;
  87788. }
  87789. }
  87790. declare module BABYLON.GLTF2.Loader.Extensions {
  87791. /**
  87792. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  87793. * !!! Experimental Extension Subject to Changes !!!
  87794. */
  87795. export class KHR_materials_ior implements IGLTFLoaderExtension {
  87796. /**
  87797. * Default ior Value from the spec.
  87798. */
  87799. private static readonly _DEFAULT_IOR;
  87800. /**
  87801. * The name of this extension.
  87802. */
  87803. readonly name: string;
  87804. /**
  87805. * Defines whether this extension is enabled.
  87806. */
  87807. enabled: boolean;
  87808. /**
  87809. * Defines a number that determines the order the extensions are applied.
  87810. */
  87811. order: number;
  87812. private _loader;
  87813. /** @hidden */
  87814. constructor(loader: GLTFLoader);
  87815. /** @hidden */
  87816. dispose(): void;
  87817. /** @hidden */
  87818. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87819. private _loadIorPropertiesAsync;
  87820. }
  87821. }
  87822. declare module BABYLON.GLTF2.Loader.Extensions {
  87823. /**
  87824. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  87825. */
  87826. export class KHR_materials_variants implements IGLTFLoaderExtension {
  87827. /**
  87828. * The name of this extension.
  87829. */
  87830. readonly name: string;
  87831. /**
  87832. * Defines whether this extension is enabled.
  87833. */
  87834. enabled: boolean;
  87835. private _loader;
  87836. private _variants?;
  87837. /** @hidden */
  87838. constructor(loader: GLTFLoader);
  87839. /** @hidden */
  87840. dispose(): void;
  87841. /**
  87842. * Gets the list of available variant names for this asset.
  87843. * @param rootMesh The glTF root mesh
  87844. * @returns the list of all the variant names for this model
  87845. */
  87846. static GetAvailableVariants(rootMesh: Mesh): string[];
  87847. /**
  87848. * Gets the list of available variant names for this asset.
  87849. * @param rootMesh The glTF root mesh
  87850. * @returns the list of all the variant names for this model
  87851. */
  87852. getAvailableVariants(rootMesh: Mesh): string[];
  87853. /**
  87854. * Select a variant given a variant name or a list of variant names.
  87855. * @param rootMesh The glTF root mesh
  87856. * @param variantName The variant name(s) to select.
  87857. */
  87858. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  87859. /**
  87860. * Select a variant given a variant name or a list of variant names.
  87861. * @param rootMesh The glTF root mesh
  87862. * @param variantName The variant name(s) to select.
  87863. */
  87864. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  87865. /**
  87866. * Reset back to the original before selecting a variant.
  87867. * @param rootMesh The glTF root mesh
  87868. */
  87869. static Reset(rootMesh: Mesh): void;
  87870. /**
  87871. * Reset back to the original before selecting a variant.
  87872. * @param rootMesh The glTF root mesh
  87873. */
  87874. reset(rootMesh: Mesh): void;
  87875. /**
  87876. * Gets the last selected variant name(s) or null if original.
  87877. * @param rootMesh The glTF root mesh
  87878. * @returns The selected variant name(s).
  87879. */
  87880. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  87881. /**
  87882. * Gets the last selected variant name(s) or null if original.
  87883. * @param rootMesh The glTF root mesh
  87884. * @returns The selected variant name(s).
  87885. */
  87886. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  87887. private static _GetExtensionMetadata;
  87888. /** @hidden */
  87889. onLoading(): void;
  87890. /** @hidden */
  87891. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  87892. }
  87893. }
  87894. declare module BABYLON.GLTF2.Loader.Extensions {
  87895. /**
  87896. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  87897. */
  87898. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  87899. /**
  87900. * The name of this extension.
  87901. */
  87902. readonly name: string;
  87903. /**
  87904. * Defines whether this extension is enabled.
  87905. */
  87906. enabled: boolean;
  87907. /**
  87908. * Defines a number that determines the order the extensions are applied.
  87909. */
  87910. order: number;
  87911. private _loader;
  87912. /** @hidden */
  87913. constructor(loader: GLTFLoader);
  87914. /** @hidden */
  87915. dispose(): void;
  87916. /** @hidden */
  87917. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87918. private _loadTransparentPropertiesAsync;
  87919. }
  87920. }
  87921. declare module BABYLON.GLTF2.Loader.Extensions {
  87922. /**
  87923. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  87924. * !!! Experimental Extension Subject to Changes !!!
  87925. */
  87926. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  87927. /**
  87928. * The name of this extension.
  87929. */
  87930. readonly name: string;
  87931. /**
  87932. * Defines whether this extension is enabled.
  87933. */
  87934. enabled: boolean;
  87935. /**
  87936. * Defines a number that determines the order the extensions are applied.
  87937. */
  87938. order: number;
  87939. private _loader;
  87940. /** @hidden */
  87941. constructor(loader: GLTFLoader);
  87942. /** @hidden */
  87943. dispose(): void;
  87944. /** @hidden */
  87945. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87946. private _loadTranslucentPropertiesAsync;
  87947. }
  87948. }
  87949. declare module BABYLON.GLTF2.Loader.Extensions {
  87950. /**
  87951. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  87952. */
  87953. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  87954. /**
  87955. * The name of this extension.
  87956. */
  87957. readonly name: string;
  87958. /**
  87959. * Defines whether this extension is enabled.
  87960. */
  87961. enabled: boolean;
  87962. /** @hidden */
  87963. constructor(loader: GLTFLoader);
  87964. /** @hidden */
  87965. dispose(): void;
  87966. }
  87967. }
  87968. declare module BABYLON.GLTF2.Loader.Extensions {
  87969. /**
  87970. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  87971. * !!! Experimental Extension Subject to Changes !!!
  87972. */
  87973. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  87974. /** The name of this extension. */
  87975. readonly name: string;
  87976. /** Defines whether this extension is enabled. */
  87977. enabled: boolean;
  87978. private _loader;
  87979. /** @hidden */
  87980. constructor(loader: GLTFLoader);
  87981. /** @hidden */
  87982. dispose(): void;
  87983. /** @hidden */
  87984. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87985. }
  87986. }
  87987. declare module BABYLON.GLTF2.Loader.Extensions {
  87988. /**
  87989. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  87990. */
  87991. export class KHR_texture_transform implements IGLTFLoaderExtension {
  87992. /**
  87993. * The name of this extension.
  87994. */
  87995. readonly name: string;
  87996. /**
  87997. * Defines whether this extension is enabled.
  87998. */
  87999. enabled: boolean;
  88000. private _loader;
  88001. /** @hidden */
  88002. constructor(loader: GLTFLoader);
  88003. /** @hidden */
  88004. dispose(): void;
  88005. /** @hidden */
  88006. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88007. }
  88008. }
  88009. declare module BABYLON.GLTF2.Loader.Extensions {
  88010. /**
  88011. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  88012. */
  88013. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  88014. /**
  88015. * The name of this extension.
  88016. */
  88017. readonly name: string;
  88018. /**
  88019. * Defines whether this extension is enabled.
  88020. */
  88021. enabled: boolean;
  88022. private _loader;
  88023. private _clips;
  88024. private _emitters;
  88025. /** @hidden */
  88026. constructor(loader: GLTFLoader);
  88027. /** @hidden */
  88028. dispose(): void;
  88029. /** @hidden */
  88030. onLoading(): void;
  88031. /** @hidden */
  88032. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88033. /** @hidden */
  88034. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88035. /** @hidden */
  88036. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88037. private _loadClipAsync;
  88038. private _loadEmitterAsync;
  88039. private _getEventAction;
  88040. private _loadAnimationEventAsync;
  88041. }
  88042. }
  88043. declare module BABYLON.GLTF2.Loader.Extensions {
  88044. /**
  88045. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  88046. */
  88047. export class MSFT_lod implements IGLTFLoaderExtension {
  88048. /**
  88049. * The name of this extension.
  88050. */
  88051. readonly name: string;
  88052. /**
  88053. * Defines whether this extension is enabled.
  88054. */
  88055. enabled: boolean;
  88056. /**
  88057. * Defines a number that determines the order the extensions are applied.
  88058. */
  88059. order: number;
  88060. /**
  88061. * Maximum number of LODs to load, starting from the lowest LOD.
  88062. */
  88063. maxLODsToLoad: number;
  88064. /**
  88065. * Observable raised when all node LODs of one level are loaded.
  88066. * The event data is the index of the loaded LOD starting from zero.
  88067. * Dispose the loader to cancel the loading of the next level of LODs.
  88068. */
  88069. onNodeLODsLoadedObservable: Observable<number>;
  88070. /**
  88071. * Observable raised when all material LODs of one level are loaded.
  88072. * The event data is the index of the loaded LOD starting from zero.
  88073. * Dispose the loader to cancel the loading of the next level of LODs.
  88074. */
  88075. onMaterialLODsLoadedObservable: Observable<number>;
  88076. private _loader;
  88077. private _bufferLODs;
  88078. private _nodeIndexLOD;
  88079. private _nodeSignalLODs;
  88080. private _nodePromiseLODs;
  88081. private _nodeBufferLODs;
  88082. private _materialIndexLOD;
  88083. private _materialSignalLODs;
  88084. private _materialPromiseLODs;
  88085. private _materialBufferLODs;
  88086. /** @hidden */
  88087. constructor(loader: GLTFLoader);
  88088. /** @hidden */
  88089. dispose(): void;
  88090. /** @hidden */
  88091. onReady(): void;
  88092. /** @hidden */
  88093. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88094. /** @hidden */
  88095. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88096. /** @hidden */
  88097. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88098. /** @hidden */
  88099. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88100. /** @hidden */
  88101. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88102. private _loadBufferLOD;
  88103. /**
  88104. * Gets an array of LOD properties from lowest to highest.
  88105. */
  88106. private _getLODs;
  88107. private _disposeTransformNode;
  88108. private _disposeMaterials;
  88109. }
  88110. }
  88111. declare module BABYLON.GLTF2.Loader.Extensions {
  88112. /** @hidden */
  88113. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  88114. readonly name: string;
  88115. enabled: boolean;
  88116. private _loader;
  88117. constructor(loader: GLTFLoader);
  88118. dispose(): void;
  88119. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88120. }
  88121. }
  88122. declare module BABYLON.GLTF2.Loader.Extensions {
  88123. /** @hidden */
  88124. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  88125. readonly name: string;
  88126. enabled: boolean;
  88127. private _loader;
  88128. constructor(loader: GLTFLoader);
  88129. dispose(): void;
  88130. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88131. }
  88132. }
  88133. declare module BABYLON.GLTF2.Loader.Extensions {
  88134. /**
  88135. * Store glTF extras (if present) in BJS objects' metadata
  88136. */
  88137. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  88138. /**
  88139. * The name of this extension.
  88140. */
  88141. readonly name: string;
  88142. /**
  88143. * Defines whether this extension is enabled.
  88144. */
  88145. enabled: boolean;
  88146. private _loader;
  88147. private _assignExtras;
  88148. /** @hidden */
  88149. constructor(loader: GLTFLoader);
  88150. /** @hidden */
  88151. dispose(): void;
  88152. /** @hidden */
  88153. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88154. /** @hidden */
  88155. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88156. /** @hidden */
  88157. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88158. }
  88159. }
  88160. declare module BABYLON {
  88161. /**
  88162. * Class reading and parsing the MTL file bundled with the obj file.
  88163. */
  88164. export class MTLFileLoader {
  88165. /**
  88166. * Invert Y-Axis of referenced textures on load
  88167. */
  88168. static INVERT_TEXTURE_Y: boolean;
  88169. /**
  88170. * All material loaded from the mtl will be set here
  88171. */
  88172. materials: StandardMaterial[];
  88173. /**
  88174. * This function will read the mtl file and create each material described inside
  88175. * This function could be improve by adding :
  88176. * -some component missing (Ni, Tf...)
  88177. * -including the specific options available
  88178. *
  88179. * @param scene defines the scene the material will be created in
  88180. * @param data defines the mtl data to parse
  88181. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  88182. * @param forAssetContainer defines if the material should be registered in the scene
  88183. */
  88184. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  88185. /**
  88186. * Gets the texture for the material.
  88187. *
  88188. * If the material is imported from input file,
  88189. * We sanitize the url to ensure it takes the textre from aside the material.
  88190. *
  88191. * @param rootUrl The root url to load from
  88192. * @param value The value stored in the mtl
  88193. * @return The Texture
  88194. */
  88195. private static _getTexture;
  88196. }
  88197. }
  88198. declare module BABYLON {
  88199. /**
  88200. * Options for loading OBJ/MTL files
  88201. */
  88202. type MeshLoadOptions = {
  88203. /**
  88204. * Defines if UVs are optimized by default during load.
  88205. */
  88206. OptimizeWithUV: boolean;
  88207. /**
  88208. * Defines custom scaling of UV coordinates of loaded meshes.
  88209. */
  88210. UVScaling: Vector2;
  88211. /**
  88212. * Invert model on y-axis (does a model scaling inversion)
  88213. */
  88214. InvertY: boolean;
  88215. /**
  88216. * Invert Y-Axis of referenced textures on load
  88217. */
  88218. InvertTextureY: boolean;
  88219. /**
  88220. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88221. */
  88222. ImportVertexColors: boolean;
  88223. /**
  88224. * Compute the normals for the model, even if normals are present in the file.
  88225. */
  88226. ComputeNormals: boolean;
  88227. /**
  88228. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88229. */
  88230. SkipMaterials: boolean;
  88231. /**
  88232. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88233. */
  88234. MaterialLoadingFailsSilently: boolean;
  88235. };
  88236. /**
  88237. * OBJ file type loader.
  88238. * This is a babylon scene loader plugin.
  88239. */
  88240. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  88241. /**
  88242. * Defines if UVs are optimized by default during load.
  88243. */
  88244. static OPTIMIZE_WITH_UV: boolean;
  88245. /**
  88246. * Invert model on y-axis (does a model scaling inversion)
  88247. */
  88248. static INVERT_Y: boolean;
  88249. /**
  88250. * Invert Y-Axis of referenced textures on load
  88251. */
  88252. static get INVERT_TEXTURE_Y(): boolean;
  88253. static set INVERT_TEXTURE_Y(value: boolean);
  88254. /**
  88255. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88256. */
  88257. static IMPORT_VERTEX_COLORS: boolean;
  88258. /**
  88259. * Compute the normals for the model, even if normals are present in the file.
  88260. */
  88261. static COMPUTE_NORMALS: boolean;
  88262. /**
  88263. * Defines custom scaling of UV coordinates of loaded meshes.
  88264. */
  88265. static UV_SCALING: Vector2;
  88266. /**
  88267. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88268. */
  88269. static SKIP_MATERIALS: boolean;
  88270. /**
  88271. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88272. *
  88273. * Defaults to true for backwards compatibility.
  88274. */
  88275. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  88276. /**
  88277. * Defines the name of the plugin.
  88278. */
  88279. name: string;
  88280. /**
  88281. * Defines the extension the plugin is able to load.
  88282. */
  88283. extensions: string;
  88284. /** @hidden */
  88285. obj: RegExp;
  88286. /** @hidden */
  88287. group: RegExp;
  88288. /** @hidden */
  88289. mtllib: RegExp;
  88290. /** @hidden */
  88291. usemtl: RegExp;
  88292. /** @hidden */
  88293. smooth: RegExp;
  88294. /** @hidden */
  88295. vertexPattern: RegExp;
  88296. /** @hidden */
  88297. normalPattern: RegExp;
  88298. /** @hidden */
  88299. uvPattern: RegExp;
  88300. /** @hidden */
  88301. facePattern1: RegExp;
  88302. /** @hidden */
  88303. facePattern2: RegExp;
  88304. /** @hidden */
  88305. facePattern3: RegExp;
  88306. /** @hidden */
  88307. facePattern4: RegExp;
  88308. /** @hidden */
  88309. facePattern5: RegExp;
  88310. private _forAssetContainer;
  88311. private _meshLoadOptions;
  88312. /**
  88313. * Creates loader for .OBJ files
  88314. *
  88315. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  88316. */
  88317. constructor(meshLoadOptions?: MeshLoadOptions);
  88318. private static get currentMeshLoadOptions();
  88319. /**
  88320. * Calls synchronously the MTL file attached to this obj.
  88321. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  88322. * Without this function materials are not displayed in the first frame (but displayed after).
  88323. * In consequence it is impossible to get material information in your HTML file
  88324. *
  88325. * @param url The URL of the MTL file
  88326. * @param rootUrl
  88327. * @param onSuccess Callback function to be called when the MTL file is loaded
  88328. * @private
  88329. */
  88330. private _loadMTL;
  88331. /**
  88332. * Instantiates a OBJ file loader plugin.
  88333. * @returns the created plugin
  88334. */
  88335. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  88336. /**
  88337. * If the data string can be loaded directly.
  88338. *
  88339. * @param data string containing the file data
  88340. * @returns if the data can be loaded directly
  88341. */
  88342. canDirectLoad(data: string): boolean;
  88343. /**
  88344. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  88345. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  88346. * @param scene the scene the meshes should be added to
  88347. * @param data the OBJ data to load
  88348. * @param rootUrl root url to load from
  88349. * @param onProgress event that fires when loading progress has occured
  88350. * @param fileName Defines the name of the file to load
  88351. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  88352. */
  88353. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88354. /**
  88355. * Imports all objects from the loaded OBJ data and adds them to the scene
  88356. * @param scene the scene the objects should be added to
  88357. * @param data the OBJ data to load
  88358. * @param rootUrl root url to load from
  88359. * @param onProgress event that fires when loading progress has occured
  88360. * @param fileName Defines the name of the file to load
  88361. * @returns a promise which completes when objects have been loaded to the scene
  88362. */
  88363. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88364. /**
  88365. * Load into an asset container.
  88366. * @param scene The scene to load into
  88367. * @param data The data to import
  88368. * @param rootUrl The root url for scene and resources
  88369. * @param onProgress The callback when the load progresses
  88370. * @param fileName Defines the name of the file to load
  88371. * @returns The loaded asset container
  88372. */
  88373. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  88374. /**
  88375. * Read the OBJ file and create an Array of meshes.
  88376. * Each mesh contains all information given by the OBJ and the MTL file.
  88377. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  88378. *
  88379. * @param meshesNames
  88380. * @param scene Scene The scene where are displayed the data
  88381. * @param data String The content of the obj file
  88382. * @param rootUrl String The path to the folder
  88383. * @returns Array<AbstractMesh>
  88384. * @private
  88385. */
  88386. private _parseSolid;
  88387. }
  88388. }
  88389. declare module BABYLON {
  88390. /**
  88391. * STL file type loader.
  88392. * This is a babylon scene loader plugin.
  88393. */
  88394. export class STLFileLoader implements ISceneLoaderPlugin {
  88395. /** @hidden */
  88396. solidPattern: RegExp;
  88397. /** @hidden */
  88398. facetsPattern: RegExp;
  88399. /** @hidden */
  88400. normalPattern: RegExp;
  88401. /** @hidden */
  88402. vertexPattern: RegExp;
  88403. /**
  88404. * Defines the name of the plugin.
  88405. */
  88406. name: string;
  88407. /**
  88408. * Defines the extensions the stl loader is able to load.
  88409. * force data to come in as an ArrayBuffer
  88410. * we'll convert to string if it looks like it's an ASCII .stl
  88411. */
  88412. extensions: ISceneLoaderPluginExtensions;
  88413. /**
  88414. * Import meshes into a scene.
  88415. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  88416. * @param scene The scene to import into
  88417. * @param data The data to import
  88418. * @param rootUrl The root url for scene and resources
  88419. * @param meshes The meshes array to import into
  88420. * @param particleSystems The particle systems array to import into
  88421. * @param skeletons The skeletons array to import into
  88422. * @param onError The callback when import fails
  88423. * @returns True if successful or false otherwise
  88424. */
  88425. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  88426. /**
  88427. * Load into a scene.
  88428. * @param scene The scene to load into
  88429. * @param data The data to import
  88430. * @param rootUrl The root url for scene and resources
  88431. * @param onError The callback when import fails
  88432. * @returns true if successful or false otherwise
  88433. */
  88434. load(scene: Scene, data: any, rootUrl: string): boolean;
  88435. /**
  88436. * Load into an asset container.
  88437. * @param scene The scene to load into
  88438. * @param data The data to import
  88439. * @param rootUrl The root url for scene and resources
  88440. * @param onError The callback when import fails
  88441. * @returns The loaded asset container
  88442. */
  88443. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  88444. private _isBinary;
  88445. private _parseBinary;
  88446. private _parseASCII;
  88447. }
  88448. }
  88449. declare module BABYLON {
  88450. /**
  88451. * Class for generating OBJ data from a Babylon scene.
  88452. */
  88453. export class OBJExport {
  88454. /**
  88455. * Exports the geometry of a Mesh array in .OBJ file format (text)
  88456. * @param mesh defines the list of meshes to serialize
  88457. * @param materials defines if materials should be exported
  88458. * @param matlibname defines the name of the associated mtl file
  88459. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  88460. * @returns the OBJ content
  88461. */
  88462. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  88463. /**
  88464. * Exports the material(s) of a mesh in .MTL file format (text)
  88465. * @param mesh defines the mesh to extract the material from
  88466. * @returns the mtl content
  88467. */
  88468. static MTL(mesh: Mesh): string;
  88469. }
  88470. }
  88471. declare module BABYLON {
  88472. /** @hidden */
  88473. export var __IGLTFExporterExtension: number;
  88474. /**
  88475. * Interface for extending the exporter
  88476. * @hidden
  88477. */
  88478. export interface IGLTFExporterExtension {
  88479. /**
  88480. * The name of this extension
  88481. */
  88482. readonly name: string;
  88483. /**
  88484. * Defines whether this extension is enabled
  88485. */
  88486. enabled: boolean;
  88487. /**
  88488. * Defines whether this extension is required
  88489. */
  88490. required: boolean;
  88491. }
  88492. }
  88493. declare module BABYLON.GLTF2.Exporter {
  88494. /** @hidden */
  88495. export var __IGLTFExporterExtensionV2: number;
  88496. /**
  88497. * Interface for a glTF exporter extension
  88498. * @hidden
  88499. */
  88500. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  88501. /**
  88502. * Define this method to modify the default behavior before exporting a texture
  88503. * @param context The context when loading the asset
  88504. * @param babylonTexture The Babylon.js texture
  88505. * @param mimeType The mime-type of the generated image
  88506. * @returns A promise that resolves with the exported texture
  88507. */
  88508. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  88509. /**
  88510. * Define this method to get notified when a texture info is created
  88511. * @param context The context when loading the asset
  88512. * @param textureInfo The glTF texture info
  88513. * @param babylonTexture The Babylon.js texture
  88514. */
  88515. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  88516. /**
  88517. * Define this method to modify the default behavior when exporting texture info
  88518. * @param context The context when loading the asset
  88519. * @param meshPrimitive glTF mesh primitive
  88520. * @param babylonSubMesh Babylon submesh
  88521. * @param binaryWriter glTF serializer binary writer instance
  88522. * @returns nullable IMeshPrimitive promise
  88523. */
  88524. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  88525. /**
  88526. * Define this method to modify the default behavior when exporting a node
  88527. * @param context The context when exporting the node
  88528. * @param node glTF node
  88529. * @param babylonNode BabylonJS node
  88530. * @returns nullable INode promise
  88531. */
  88532. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  88533. [key: number]: number;
  88534. }): Promise<Nullable<INode>>;
  88535. /**
  88536. * Define this method to modify the default behavior when exporting a material
  88537. * @param material glTF material
  88538. * @param babylonMaterial BabylonJS material
  88539. * @returns nullable IMaterial promise
  88540. */
  88541. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  88542. /**
  88543. * Define this method to return additional textures to export from a material
  88544. * @param material glTF material
  88545. * @param babylonMaterial BabylonJS material
  88546. * @returns List of textures
  88547. */
  88548. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  88549. /** Gets a boolean indicating that this extension was used */
  88550. wasUsed: boolean;
  88551. /** Gets a boolean indicating that this extension is required for the file to work */
  88552. required: boolean;
  88553. /**
  88554. * Called after the exporter state changes to EXPORTING
  88555. */
  88556. onExporting?(): void;
  88557. }
  88558. }
  88559. declare module BABYLON.GLTF2.Exporter {
  88560. /**
  88561. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  88562. * @hidden
  88563. */
  88564. export class _GLTFMaterialExporter {
  88565. /**
  88566. * Represents the dielectric specular values for R, G and B
  88567. */
  88568. private static readonly _DielectricSpecular;
  88569. /**
  88570. * Allows the maximum specular power to be defined for material calculations
  88571. */
  88572. private static readonly _MaxSpecularPower;
  88573. /**
  88574. * Mapping to store textures
  88575. */
  88576. private _textureMap;
  88577. /**
  88578. * Numeric tolerance value
  88579. */
  88580. private static readonly _Epsilon;
  88581. /**
  88582. * Reference to the glTF Exporter
  88583. */
  88584. private _exporter;
  88585. constructor(exporter: _Exporter);
  88586. /**
  88587. * Specifies if two colors are approximately equal in value
  88588. * @param color1 first color to compare to
  88589. * @param color2 second color to compare to
  88590. * @param epsilon threshold value
  88591. */
  88592. private static FuzzyEquals;
  88593. /**
  88594. * Gets the materials from a Babylon scene and converts them to glTF materials
  88595. * @param scene babylonjs scene
  88596. * @param mimeType texture mime type
  88597. * @param images array of images
  88598. * @param textures array of textures
  88599. * @param materials array of materials
  88600. * @param imageData mapping of texture names to base64 textures
  88601. * @param hasTextureCoords specifies if texture coordinates are present on the material
  88602. */
  88603. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  88604. /**
  88605. * Makes a copy of the glTF material without the texture parameters
  88606. * @param originalMaterial original glTF material
  88607. * @returns glTF material without texture parameters
  88608. */
  88609. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  88610. /**
  88611. * Specifies if the material has any texture parameters present
  88612. * @param material glTF Material
  88613. * @returns boolean specifying if texture parameters are present
  88614. */
  88615. _hasTexturesPresent(material: IMaterial): boolean;
  88616. /**
  88617. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  88618. * @param babylonStandardMaterial
  88619. * @returns glTF Metallic Roughness Material representation
  88620. */
  88621. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  88622. /**
  88623. * Computes the metallic factor
  88624. * @param diffuse diffused value
  88625. * @param specular specular value
  88626. * @param oneMinusSpecularStrength one minus the specular strength
  88627. * @returns metallic value
  88628. */
  88629. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  88630. /**
  88631. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  88632. * @param glTFMaterial glTF material
  88633. * @param babylonMaterial Babylon material
  88634. */
  88635. private static _SetAlphaMode;
  88636. /**
  88637. * Converts a Babylon Standard Material to a glTF Material
  88638. * @param babylonStandardMaterial BJS Standard Material
  88639. * @param mimeType mime type to use for the textures
  88640. * @param images array of glTF image interfaces
  88641. * @param textures array of glTF texture interfaces
  88642. * @param materials array of glTF material interfaces
  88643. * @param imageData map of image file name to data
  88644. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  88645. */
  88646. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  88647. private _finishMaterial;
  88648. /**
  88649. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  88650. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  88651. * @param mimeType mime type to use for the textures
  88652. * @param images array of glTF image interfaces
  88653. * @param textures array of glTF texture interfaces
  88654. * @param materials array of glTF material interfaces
  88655. * @param imageData map of image file name to data
  88656. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  88657. */
  88658. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  88659. /**
  88660. * Converts an image typed array buffer to a base64 image
  88661. * @param buffer typed array buffer
  88662. * @param width width of the image
  88663. * @param height height of the image
  88664. * @param mimeType mimetype of the image
  88665. * @returns base64 image string
  88666. */
  88667. private _createBase64FromCanvasAsync;
  88668. /**
  88669. * Generates a white texture based on the specified width and height
  88670. * @param width width of the texture in pixels
  88671. * @param height height of the texture in pixels
  88672. * @param scene babylonjs scene
  88673. * @returns white texture
  88674. */
  88675. private _createWhiteTexture;
  88676. /**
  88677. * 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
  88678. * @param texture1 first texture to resize
  88679. * @param texture2 second texture to resize
  88680. * @param scene babylonjs scene
  88681. * @returns resized textures or null
  88682. */
  88683. private _resizeTexturesToSameDimensions;
  88684. /**
  88685. * Converts an array of pixels to a Float32Array
  88686. * Throws an error if the pixel format is not supported
  88687. * @param pixels - array buffer containing pixel values
  88688. * @returns Float32 of pixels
  88689. */
  88690. private _convertPixelArrayToFloat32;
  88691. /**
  88692. * Convert Specular Glossiness Textures to Metallic Roughness
  88693. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  88694. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  88695. * @param diffuseTexture texture used to store diffuse information
  88696. * @param specularGlossinessTexture texture used to store specular and glossiness information
  88697. * @param factors specular glossiness material factors
  88698. * @param mimeType the mime type to use for the texture
  88699. * @returns pbr metallic roughness interface or null
  88700. */
  88701. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  88702. /**
  88703. * Converts specular glossiness material properties to metallic roughness
  88704. * @param specularGlossiness interface with specular glossiness material properties
  88705. * @returns interface with metallic roughness material properties
  88706. */
  88707. private _convertSpecularGlossinessToMetallicRoughness;
  88708. /**
  88709. * Calculates the surface reflectance, independent of lighting conditions
  88710. * @param color Color source to calculate brightness from
  88711. * @returns number representing the perceived brightness, or zero if color is undefined
  88712. */
  88713. private _getPerceivedBrightness;
  88714. /**
  88715. * Returns the maximum color component value
  88716. * @param color
  88717. * @returns maximum color component value, or zero if color is null or undefined
  88718. */
  88719. private _getMaxComponent;
  88720. /**
  88721. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  88722. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  88723. * @param mimeType mime type to use for the textures
  88724. * @param images array of glTF image interfaces
  88725. * @param textures array of glTF texture interfaces
  88726. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  88727. * @param imageData map of image file name to data
  88728. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  88729. * @returns glTF PBR Metallic Roughness factors
  88730. */
  88731. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  88732. private _getGLTFTextureSampler;
  88733. private _getGLTFTextureWrapMode;
  88734. private _getGLTFTextureWrapModesSampler;
  88735. /**
  88736. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  88737. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  88738. * @param mimeType mime type to use for the textures
  88739. * @param images array of glTF image interfaces
  88740. * @param textures array of glTF texture interfaces
  88741. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  88742. * @param imageData map of image file name to data
  88743. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  88744. * @returns glTF PBR Metallic Roughness factors
  88745. */
  88746. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  88747. /**
  88748. * Converts a Babylon PBR Base Material to a glTF Material
  88749. * @param babylonPBRMaterial BJS PBR Base Material
  88750. * @param mimeType mime type to use for the textures
  88751. * @param images array of glTF image interfaces
  88752. * @param textures array of glTF texture interfaces
  88753. * @param materials array of glTF material interfaces
  88754. * @param imageData map of image file name to data
  88755. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  88756. */
  88757. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  88758. private setMetallicRoughnessPbrMaterial;
  88759. private getPixelsFromTexture;
  88760. /**
  88761. * Extracts a texture from a Babylon texture into file data and glTF data
  88762. * @param babylonTexture Babylon texture to extract
  88763. * @param mimeType Mime Type of the babylonTexture
  88764. * @return glTF texture info, or null if the texture format is not supported
  88765. */
  88766. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  88767. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  88768. /**
  88769. * Builds a texture from base64 string
  88770. * @param base64Texture base64 texture string
  88771. * @param baseTextureName Name to use for the texture
  88772. * @param mimeType image mime type for the texture
  88773. * @param images array of images
  88774. * @param textures array of textures
  88775. * @param imageData map of image data
  88776. * @returns glTF texture info, or null if the texture format is not supported
  88777. */
  88778. private _getTextureInfoFromBase64;
  88779. }
  88780. }
  88781. declare module BABYLON {
  88782. /**
  88783. * Class for holding and downloading glTF file data
  88784. */
  88785. export class GLTFData {
  88786. /**
  88787. * Object which contains the file name as the key and its data as the value
  88788. */
  88789. glTFFiles: {
  88790. [fileName: string]: string | Blob;
  88791. };
  88792. /**
  88793. * Initializes the glTF file object
  88794. */
  88795. constructor();
  88796. /**
  88797. * Downloads the glTF data as files based on their names and data
  88798. */
  88799. downloadFiles(): void;
  88800. }
  88801. }
  88802. declare module BABYLON {
  88803. /**
  88804. * Holds a collection of exporter options and parameters
  88805. */
  88806. export interface IExportOptions {
  88807. /**
  88808. * Function which indicates whether a babylon node should be exported or not
  88809. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  88810. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  88811. */
  88812. shouldExportNode?(node: Node): boolean;
  88813. /**
  88814. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  88815. * @param metadata source metadata to read from
  88816. * @returns the data to store to glTF node extras
  88817. */
  88818. metadataSelector?(metadata: any): any;
  88819. /**
  88820. * The sample rate to bake animation curves
  88821. */
  88822. animationSampleRate?: number;
  88823. /**
  88824. * Begin serialization without waiting for the scene to be ready
  88825. */
  88826. exportWithoutWaitingForScene?: boolean;
  88827. /**
  88828. * Indicates if coordinate system swapping root nodes should be included in export
  88829. */
  88830. includeCoordinateSystemConversionNodes?: boolean;
  88831. }
  88832. /**
  88833. * Class for generating glTF data from a Babylon scene.
  88834. */
  88835. export class GLTF2Export {
  88836. /**
  88837. * Exports the geometry of the scene to .gltf file format asynchronously
  88838. * @param scene Babylon scene with scene hierarchy information
  88839. * @param filePrefix File prefix to use when generating the glTF file
  88840. * @param options Exporter options
  88841. * @returns Returns an object with a .gltf file and associates texture names
  88842. * as keys and their data and paths as values
  88843. */
  88844. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  88845. private static _PreExportAsync;
  88846. private static _PostExportAsync;
  88847. /**
  88848. * Exports the geometry of the scene to .glb file format asychronously
  88849. * @param scene Babylon scene with scene hierarchy information
  88850. * @param filePrefix File prefix to use when generating glb file
  88851. * @param options Exporter options
  88852. * @returns Returns an object with a .glb filename as key and data as value
  88853. */
  88854. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  88855. }
  88856. }
  88857. declare module BABYLON.GLTF2.Exporter {
  88858. /**
  88859. * @hidden
  88860. */
  88861. export class _GLTFUtilities {
  88862. /**
  88863. * Creates a buffer view based on the supplied arguments
  88864. * @param bufferIndex index value of the specified buffer
  88865. * @param byteOffset byte offset value
  88866. * @param byteLength byte length of the bufferView
  88867. * @param byteStride byte distance between conequential elements
  88868. * @param name name of the buffer view
  88869. * @returns bufferView for glTF
  88870. */
  88871. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  88872. /**
  88873. * Creates an accessor based on the supplied arguments
  88874. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  88875. * @param name The name of the accessor
  88876. * @param type The type of the accessor
  88877. * @param componentType The datatype of components in the attribute
  88878. * @param count The number of attributes referenced by this accessor
  88879. * @param byteOffset The offset relative to the start of the bufferView in bytes
  88880. * @param min Minimum value of each component in this attribute
  88881. * @param max Maximum value of each component in this attribute
  88882. * @returns accessor for glTF
  88883. */
  88884. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  88885. /**
  88886. * Calculates the minimum and maximum values of an array of position floats
  88887. * @param positions Positions array of a mesh
  88888. * @param vertexStart Starting vertex offset to calculate min and max values
  88889. * @param vertexCount Number of vertices to check for min and max values
  88890. * @returns min number array and max number array
  88891. */
  88892. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  88893. min: number[];
  88894. max: number[];
  88895. };
  88896. /**
  88897. * Converts a new right-handed Vector3
  88898. * @param vector vector3 array
  88899. * @returns right-handed Vector3
  88900. */
  88901. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  88902. /**
  88903. * Converts a Vector3 to right-handed
  88904. * @param vector Vector3 to convert to right-handed
  88905. */
  88906. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  88907. /**
  88908. * Converts a three element number array to right-handed
  88909. * @param vector number array to convert to right-handed
  88910. */
  88911. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  88912. /**
  88913. * Converts a new right-handed Vector3
  88914. * @param vector vector3 array
  88915. * @returns right-handed Vector3
  88916. */
  88917. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  88918. /**
  88919. * Converts a Vector3 to right-handed
  88920. * @param vector Vector3 to convert to right-handed
  88921. */
  88922. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  88923. /**
  88924. * Converts a three element number array to right-handed
  88925. * @param vector number array to convert to right-handed
  88926. */
  88927. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  88928. /**
  88929. * Converts a Vector4 to right-handed
  88930. * @param vector Vector4 to convert to right-handed
  88931. */
  88932. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  88933. /**
  88934. * Converts a Vector4 to right-handed
  88935. * @param vector Vector4 to convert to right-handed
  88936. */
  88937. static _GetRightHandedArray4FromRef(vector: number[]): void;
  88938. /**
  88939. * Converts a Quaternion to right-handed
  88940. * @param quaternion Source quaternion to convert to right-handed
  88941. */
  88942. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  88943. /**
  88944. * Converts a Quaternion to right-handed
  88945. * @param quaternion Source quaternion to convert to right-handed
  88946. */
  88947. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  88948. static _NormalizeTangentFromRef(tangent: Vector4): void;
  88949. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  88950. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  88951. }
  88952. }
  88953. declare module BABYLON.GLTF2.Exporter {
  88954. /**
  88955. * Converts Babylon Scene into glTF 2.0.
  88956. * @hidden
  88957. */
  88958. export class _Exporter {
  88959. /**
  88960. * Stores the glTF to export
  88961. */
  88962. _glTF: IGLTF;
  88963. /**
  88964. * Stores all generated buffer views, which represents views into the main glTF buffer data
  88965. */
  88966. _bufferViews: IBufferView[];
  88967. /**
  88968. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  88969. */
  88970. _accessors: IAccessor[];
  88971. /**
  88972. * Stores all the generated nodes, which contains transform and/or mesh information per node
  88973. */
  88974. _nodes: INode[];
  88975. /**
  88976. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  88977. */
  88978. private _scenes;
  88979. /**
  88980. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  88981. */
  88982. private _meshes;
  88983. /**
  88984. * Stores all the generated material information, which represents the appearance of each primitive
  88985. */
  88986. _materials: IMaterial[];
  88987. _materialMap: {
  88988. [materialID: number]: number;
  88989. };
  88990. /**
  88991. * Stores all the generated texture information, which is referenced by glTF materials
  88992. */
  88993. _textures: ITexture[];
  88994. /**
  88995. * Stores all the generated image information, which is referenced by glTF textures
  88996. */
  88997. _images: IImage[];
  88998. /**
  88999. * Stores all the texture samplers
  89000. */
  89001. _samplers: ISampler[];
  89002. /**
  89003. * Stores all the generated glTF skins
  89004. */
  89005. _skins: ISkin[];
  89006. /**
  89007. * Stores all the generated animation samplers, which is referenced by glTF animations
  89008. */
  89009. /**
  89010. * Stores the animations for glTF models
  89011. */
  89012. private _animations;
  89013. /**
  89014. * Stores the total amount of bytes stored in the glTF buffer
  89015. */
  89016. private _totalByteLength;
  89017. /**
  89018. * Stores a reference to the Babylon scene containing the source geometry and material information
  89019. */
  89020. _babylonScene: Scene;
  89021. /**
  89022. * Stores a map of the image data, where the key is the file name and the value
  89023. * is the image data
  89024. */
  89025. _imageData: {
  89026. [fileName: string]: {
  89027. data: Uint8Array;
  89028. mimeType: ImageMimeType;
  89029. };
  89030. };
  89031. protected _orderedImageData: Array<{
  89032. data: Uint8Array;
  89033. mimeType: ImageMimeType;
  89034. }>;
  89035. /**
  89036. * Stores a map of the unique id of a node to its index in the node array
  89037. */
  89038. _nodeMap: {
  89039. [key: number]: number;
  89040. };
  89041. /**
  89042. * Specifies if the source Babylon scene was left handed, and needed conversion.
  89043. */
  89044. _convertToRightHandedSystem: boolean;
  89045. /**
  89046. * Specifies if a Babylon node should be converted to right-handed on export
  89047. */
  89048. _convertToRightHandedSystemMap: {
  89049. [nodeId: number]: boolean;
  89050. };
  89051. _includeCoordinateSystemConversionNodes: boolean;
  89052. /**
  89053. * Baked animation sample rate
  89054. */
  89055. private _animationSampleRate;
  89056. private _options;
  89057. private _localEngine;
  89058. _glTFMaterialExporter: _GLTFMaterialExporter;
  89059. private _extensions;
  89060. private static _ExtensionNames;
  89061. private static _ExtensionFactories;
  89062. private _applyExtension;
  89063. private _applyExtensions;
  89064. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  89065. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  89066. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89067. [key: number]: number;
  89068. }): Promise<Nullable<INode>>;
  89069. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  89070. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  89071. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89072. private _forEachExtensions;
  89073. private _extensionsOnExporting;
  89074. /**
  89075. * Load glTF serializer extensions
  89076. */
  89077. private _loadExtensions;
  89078. /**
  89079. * Creates a glTF Exporter instance, which can accept optional exporter options
  89080. * @param babylonScene Babylon scene object
  89081. * @param options Options to modify the behavior of the exporter
  89082. */
  89083. constructor(babylonScene: Scene, options?: IExportOptions);
  89084. dispose(): void;
  89085. /**
  89086. * Registers a glTF exporter extension
  89087. * @param name Name of the extension to export
  89088. * @param factory The factory function that creates the exporter extension
  89089. */
  89090. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  89091. /**
  89092. * Un-registers an exporter extension
  89093. * @param name The name fo the exporter extension
  89094. * @returns A boolean indicating whether the extension has been un-registered
  89095. */
  89096. static UnregisterExtension(name: string): boolean;
  89097. private reorderIndicesBasedOnPrimitiveMode;
  89098. /**
  89099. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  89100. * clock-wise during export to glTF
  89101. * @param submesh BabylonJS submesh
  89102. * @param primitiveMode Primitive mode of the mesh
  89103. * @param sideOrientation the winding order of the submesh
  89104. * @param vertexBufferKind The type of vertex attribute
  89105. * @param meshAttributeArray The vertex attribute data
  89106. * @param byteOffset The offset to the binary data
  89107. * @param binaryWriter The binary data for the glTF file
  89108. * @param convertToRightHandedSystem Converts the values to right-handed
  89109. */
  89110. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  89111. /**
  89112. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  89113. * clock-wise during export to glTF
  89114. * @param submesh BabylonJS submesh
  89115. * @param primitiveMode Primitive mode of the mesh
  89116. * @param sideOrientation the winding order of the submesh
  89117. * @param vertexBufferKind The type of vertex attribute
  89118. * @param meshAttributeArray The vertex attribute data
  89119. * @param byteOffset The offset to the binary data
  89120. * @param binaryWriter The binary data for the glTF file
  89121. * @param convertToRightHandedSystem Converts the values to right-handed
  89122. */
  89123. private reorderTriangleFillMode;
  89124. /**
  89125. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  89126. * clock-wise during export to glTF
  89127. * @param submesh BabylonJS submesh
  89128. * @param primitiveMode Primitive mode of the mesh
  89129. * @param sideOrientation the winding order of the submesh
  89130. * @param vertexBufferKind The type of vertex attribute
  89131. * @param meshAttributeArray The vertex attribute data
  89132. * @param byteOffset The offset to the binary data
  89133. * @param binaryWriter The binary data for the glTF file
  89134. * @param convertToRightHandedSystem Converts the values to right-handed
  89135. */
  89136. private reorderTriangleStripDrawMode;
  89137. /**
  89138. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  89139. * clock-wise during export to glTF
  89140. * @param submesh BabylonJS submesh
  89141. * @param primitiveMode Primitive mode of the mesh
  89142. * @param sideOrientation the winding order of the submesh
  89143. * @param vertexBufferKind The type of vertex attribute
  89144. * @param meshAttributeArray The vertex attribute data
  89145. * @param byteOffset The offset to the binary data
  89146. * @param binaryWriter The binary data for the glTF file
  89147. * @param convertToRightHandedSystem Converts the values to right-handed
  89148. */
  89149. private reorderTriangleFanMode;
  89150. /**
  89151. * Writes the vertex attribute data to binary
  89152. * @param vertices The vertices to write to the binary writer
  89153. * @param byteOffset The offset into the binary writer to overwrite binary data
  89154. * @param vertexAttributeKind The vertex attribute type
  89155. * @param meshAttributeArray The vertex attribute data
  89156. * @param binaryWriter The writer containing the binary data
  89157. * @param convertToRightHandedSystem Converts the values to right-handed
  89158. */
  89159. private writeVertexAttributeData;
  89160. /**
  89161. * Writes mesh attribute data to a data buffer
  89162. * Returns the bytelength of the data
  89163. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89164. * @param meshAttributeArray Array containing the attribute data
  89165. * @param byteStride Specifies the space between data
  89166. * @param binaryWriter The buffer to write the binary data to
  89167. * @param convertToRightHandedSystem Converts the values to right-handed
  89168. */
  89169. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  89170. /**
  89171. * Writes mesh attribute data to a data buffer
  89172. * Returns the bytelength of the data
  89173. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89174. * @param meshAttributeArray Array containing the attribute data
  89175. * @param byteStride Specifies the space between data
  89176. * @param binaryWriter The buffer to write the binary data to
  89177. * @param convertToRightHandedSystem Converts the values to right-handed
  89178. */
  89179. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  89180. /**
  89181. * Generates glTF json data
  89182. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  89183. * @param glTFPrefix Text to use when prefixing a glTF file
  89184. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  89185. * @returns json data as string
  89186. */
  89187. private generateJSON;
  89188. /**
  89189. * Generates data for .gltf and .bin files based on the glTF prefix string
  89190. * @param glTFPrefix Text to use when prefixing a glTF file
  89191. * @param dispose Dispose the exporter
  89192. * @returns GLTFData with glTF file data
  89193. */
  89194. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89195. /**
  89196. * Creates a binary buffer for glTF
  89197. * @returns array buffer for binary data
  89198. */
  89199. private _generateBinaryAsync;
  89200. /**
  89201. * Pads the number to a multiple of 4
  89202. * @param num number to pad
  89203. * @returns padded number
  89204. */
  89205. private _getPadding;
  89206. /**
  89207. * @hidden
  89208. */
  89209. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89210. /**
  89211. * Sets the TRS for each node
  89212. * @param node glTF Node for storing the transformation data
  89213. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  89214. * @param convertToRightHandedSystem Converts the values to right-handed
  89215. */
  89216. private setNodeTransformation;
  89217. private getVertexBufferFromMesh;
  89218. /**
  89219. * Creates a bufferview based on the vertices type for the Babylon mesh
  89220. * @param kind Indicates the type of vertices data
  89221. * @param componentType Indicates the numerical type used to store the data
  89222. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  89223. * @param binaryWriter The buffer to write the bufferview data to
  89224. * @param convertToRightHandedSystem Converts the values to right-handed
  89225. */
  89226. private createBufferViewKind;
  89227. /**
  89228. * Creates a bufferview based on the vertices type for the Babylon mesh
  89229. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  89230. * @param babylonMorphTarget the morph target to be exported
  89231. * @param binaryWriter The buffer to write the bufferview data to
  89232. * @param convertToRightHandedSystem Converts the values to right-handed
  89233. */
  89234. private setMorphTargetAttributes;
  89235. /**
  89236. * The primitive mode of the Babylon mesh
  89237. * @param babylonMesh The BabylonJS mesh
  89238. */
  89239. private getMeshPrimitiveMode;
  89240. /**
  89241. * Sets the primitive mode of the glTF mesh primitive
  89242. * @param meshPrimitive glTF mesh primitive
  89243. * @param primitiveMode The primitive mode
  89244. */
  89245. private setPrimitiveMode;
  89246. /**
  89247. * Sets the vertex attribute accessor based of the glTF mesh primitive
  89248. * @param meshPrimitive glTF mesh primitive
  89249. * @param attributeKind vertex attribute
  89250. * @returns boolean specifying if uv coordinates are present
  89251. */
  89252. private setAttributeKind;
  89253. /**
  89254. * Sets data for the primitive attributes of each submesh
  89255. * @param mesh glTF Mesh object to store the primitive attribute information
  89256. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  89257. * @param binaryWriter Buffer to write the attribute data to
  89258. * @param convertToRightHandedSystem Converts the values to right-handed
  89259. */
  89260. private setPrimitiveAttributesAsync;
  89261. /**
  89262. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  89263. * @param node The node to check
  89264. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  89265. */
  89266. private isBabylonCoordinateSystemConvertingNode;
  89267. /**
  89268. * Creates a glTF scene based on the array of meshes
  89269. * Returns the the total byte offset
  89270. * @param babylonScene Babylon scene to get the mesh data from
  89271. * @param binaryWriter Buffer to write binary data to
  89272. */
  89273. private createSceneAsync;
  89274. /**
  89275. * Creates a mapping of Node unique id to node index and handles animations
  89276. * @param babylonScene Babylon Scene
  89277. * @param nodes Babylon transform nodes
  89278. * @param binaryWriter Buffer to write binary data to
  89279. * @returns Node mapping of unique id to index
  89280. */
  89281. private createNodeMapAndAnimationsAsync;
  89282. /**
  89283. * Creates a glTF node from a Babylon mesh
  89284. * @param babylonMesh Source Babylon mesh
  89285. * @param binaryWriter Buffer for storing geometry data
  89286. * @param convertToRightHandedSystem Converts the values to right-handed
  89287. * @param nodeMap Node mapping of unique id to glTF node index
  89288. * @returns glTF node
  89289. */
  89290. private createNodeAsync;
  89291. /**
  89292. * Creates a glTF skin from a Babylon skeleton
  89293. * @param babylonScene Babylon Scene
  89294. * @param nodes Babylon transform nodes
  89295. * @param binaryWriter Buffer to write binary data to
  89296. * @returns Node mapping of unique id to index
  89297. */
  89298. private createSkinsAsync;
  89299. }
  89300. /**
  89301. * @hidden
  89302. *
  89303. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  89304. */
  89305. export class _BinaryWriter {
  89306. /**
  89307. * Array buffer which stores all binary data
  89308. */
  89309. private _arrayBuffer;
  89310. /**
  89311. * View of the array buffer
  89312. */
  89313. private _dataView;
  89314. /**
  89315. * byte offset of data in array buffer
  89316. */
  89317. private _byteOffset;
  89318. /**
  89319. * Initialize binary writer with an initial byte length
  89320. * @param byteLength Initial byte length of the array buffer
  89321. */
  89322. constructor(byteLength: number);
  89323. /**
  89324. * Resize the array buffer to the specified byte length
  89325. * @param byteLength
  89326. */
  89327. private resizeBuffer;
  89328. /**
  89329. * Get an array buffer with the length of the byte offset
  89330. * @returns ArrayBuffer resized to the byte offset
  89331. */
  89332. getArrayBuffer(): ArrayBuffer;
  89333. /**
  89334. * Get the byte offset of the array buffer
  89335. * @returns byte offset
  89336. */
  89337. getByteOffset(): number;
  89338. /**
  89339. * Stores an UInt8 in the array buffer
  89340. * @param entry
  89341. * @param byteOffset If defined, specifies where to set the value as an offset.
  89342. */
  89343. setUInt8(entry: number, byteOffset?: number): void;
  89344. /**
  89345. * Stores an UInt16 in the array buffer
  89346. * @param entry
  89347. * @param byteOffset If defined, specifies where to set the value as an offset.
  89348. */
  89349. setUInt16(entry: number, byteOffset?: number): void;
  89350. /**
  89351. * Gets an UInt32 in the array buffer
  89352. * @param entry
  89353. * @param byteOffset If defined, specifies where to set the value as an offset.
  89354. */
  89355. getUInt32(byteOffset: number): number;
  89356. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  89357. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  89358. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  89359. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  89360. /**
  89361. * Stores a Float32 in the array buffer
  89362. * @param entry
  89363. */
  89364. setFloat32(entry: number, byteOffset?: number): void;
  89365. /**
  89366. * Stores an UInt32 in the array buffer
  89367. * @param entry
  89368. * @param byteOffset If defined, specifies where to set the value as an offset.
  89369. */
  89370. setUInt32(entry: number, byteOffset?: number): void;
  89371. }
  89372. }
  89373. declare module BABYLON.GLTF2.Exporter {
  89374. /**
  89375. * @hidden
  89376. * Interface to store animation data.
  89377. */
  89378. export interface _IAnimationData {
  89379. /**
  89380. * Keyframe data.
  89381. */
  89382. inputs: number[];
  89383. /**
  89384. * Value data.
  89385. */
  89386. outputs: number[][];
  89387. /**
  89388. * Animation interpolation data.
  89389. */
  89390. samplerInterpolation: AnimationSamplerInterpolation;
  89391. /**
  89392. * Minimum keyframe value.
  89393. */
  89394. inputsMin: number;
  89395. /**
  89396. * Maximum keyframe value.
  89397. */
  89398. inputsMax: number;
  89399. }
  89400. /**
  89401. * @hidden
  89402. */
  89403. export interface _IAnimationInfo {
  89404. /**
  89405. * The target channel for the animation
  89406. */
  89407. animationChannelTargetPath: AnimationChannelTargetPath;
  89408. /**
  89409. * The glTF accessor type for the data.
  89410. */
  89411. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  89412. /**
  89413. * Specifies if quaternions should be used.
  89414. */
  89415. useQuaternion: boolean;
  89416. }
  89417. /**
  89418. * @hidden
  89419. * Utility class for generating glTF animation data from BabylonJS.
  89420. */
  89421. export class _GLTFAnimation {
  89422. /**
  89423. * @ignore
  89424. *
  89425. * Creates glTF channel animation from BabylonJS animation.
  89426. * @param babylonTransformNode - BabylonJS mesh.
  89427. * @param animation - animation.
  89428. * @param animationChannelTargetPath - The target animation channel.
  89429. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  89430. * @param useQuaternion - Specifies if quaternions are used.
  89431. * @returns nullable IAnimationData
  89432. */
  89433. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  89434. private static _DeduceAnimationInfo;
  89435. /**
  89436. * @ignore
  89437. * Create node animations from the transform node animations
  89438. * @param babylonNode
  89439. * @param runtimeGLTFAnimation
  89440. * @param idleGLTFAnimations
  89441. * @param nodeMap
  89442. * @param nodes
  89443. * @param binaryWriter
  89444. * @param bufferViews
  89445. * @param accessors
  89446. * @param convertToRightHandedSystem
  89447. * @param animationSampleRate
  89448. */
  89449. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  89450. [key: number]: number;
  89451. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  89452. /**
  89453. * @ignore
  89454. * Create individual morph animations from the mesh's morph target animation tracks
  89455. * @param babylonNode
  89456. * @param runtimeGLTFAnimation
  89457. * @param idleGLTFAnimations
  89458. * @param nodeMap
  89459. * @param nodes
  89460. * @param binaryWriter
  89461. * @param bufferViews
  89462. * @param accessors
  89463. * @param convertToRightHandedSystem
  89464. * @param animationSampleRate
  89465. */
  89466. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  89467. [key: number]: number;
  89468. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  89469. /**
  89470. * @ignore
  89471. * Create node and morph animations from the animation groups
  89472. * @param babylonScene
  89473. * @param glTFAnimations
  89474. * @param nodeMap
  89475. * @param nodes
  89476. * @param binaryWriter
  89477. * @param bufferViews
  89478. * @param accessors
  89479. * @param convertToRightHandedSystemMap
  89480. * @param animationSampleRate
  89481. */
  89482. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  89483. [key: number]: number;
  89484. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  89485. [nodeId: number]: boolean;
  89486. }, animationSampleRate: number): void;
  89487. private static AddAnimation;
  89488. /**
  89489. * Create a baked animation
  89490. * @param babylonTransformNode BabylonJS mesh
  89491. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  89492. * @param animationChannelTargetPath animation target channel
  89493. * @param minFrame minimum animation frame
  89494. * @param maxFrame maximum animation frame
  89495. * @param fps frames per second of the animation
  89496. * @param inputs input key frames of the animation
  89497. * @param outputs output key frame data of the animation
  89498. * @param convertToRightHandedSystem converts the values to right-handed
  89499. * @param useQuaternion specifies if quaternions should be used
  89500. */
  89501. private static _CreateBakedAnimation;
  89502. private static _ConvertFactorToVector3OrQuaternion;
  89503. private static _SetInterpolatedValue;
  89504. /**
  89505. * Creates linear animation from the animation key frames
  89506. * @param babylonTransformNode BabylonJS mesh
  89507. * @param animation BabylonJS animation
  89508. * @param animationChannelTargetPath The target animation channel
  89509. * @param frameDelta The difference between the last and first frame of the animation
  89510. * @param inputs Array to store the key frame times
  89511. * @param outputs Array to store the key frame data
  89512. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  89513. * @param useQuaternion Specifies if quaternions are used in the animation
  89514. */
  89515. private static _CreateLinearOrStepAnimation;
  89516. /**
  89517. * Creates cubic spline animation from the animation key frames
  89518. * @param babylonTransformNode BabylonJS mesh
  89519. * @param animation BabylonJS animation
  89520. * @param animationChannelTargetPath The target animation channel
  89521. * @param frameDelta The difference between the last and first frame of the animation
  89522. * @param inputs Array to store the key frame times
  89523. * @param outputs Array to store the key frame data
  89524. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  89525. * @param useQuaternion Specifies if quaternions are used in the animation
  89526. */
  89527. private static _CreateCubicSplineAnimation;
  89528. private static _GetBasePositionRotationOrScale;
  89529. /**
  89530. * Adds a key frame value
  89531. * @param keyFrame
  89532. * @param animation
  89533. * @param outputs
  89534. * @param animationChannelTargetPath
  89535. * @param basePositionRotationOrScale
  89536. * @param convertToRightHandedSystem
  89537. * @param useQuaternion
  89538. */
  89539. private static _AddKeyframeValue;
  89540. /**
  89541. * Determine the interpolation based on the key frames
  89542. * @param keyFrames
  89543. * @param animationChannelTargetPath
  89544. * @param useQuaternion
  89545. */
  89546. private static _DeduceInterpolation;
  89547. /**
  89548. * Adds an input tangent or output tangent to the output data
  89549. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  89550. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  89551. * @param outputs The animation data by keyframe
  89552. * @param animationChannelTargetPath The target animation channel
  89553. * @param interpolation The interpolation type
  89554. * @param keyFrame The key frame with the animation data
  89555. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  89556. * @param useQuaternion Specifies if quaternions are used
  89557. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  89558. */
  89559. private static AddSplineTangent;
  89560. /**
  89561. * Get the minimum and maximum key frames' frame values
  89562. * @param keyFrames animation key frames
  89563. * @returns the minimum and maximum key frame value
  89564. */
  89565. private static calculateMinMaxKeyFrames;
  89566. }
  89567. }
  89568. declare module BABYLON.GLTF2.Exporter {
  89569. /** @hidden */
  89570. export var textureTransformPixelShader: {
  89571. name: string;
  89572. shader: string;
  89573. };
  89574. }
  89575. declare module BABYLON.GLTF2.Exporter.Extensions {
  89576. /**
  89577. * @hidden
  89578. */
  89579. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  89580. private _recordedTextures;
  89581. /** Name of this extension */
  89582. readonly name: string;
  89583. /** Defines whether this extension is enabled */
  89584. enabled: boolean;
  89585. /** Defines whether this extension is required */
  89586. required: boolean;
  89587. /** Reference to the glTF exporter */
  89588. private _wasUsed;
  89589. constructor(exporter: _Exporter);
  89590. dispose(): void;
  89591. /** @hidden */
  89592. get wasUsed(): boolean;
  89593. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  89594. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  89595. /**
  89596. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  89597. * @param babylonTexture
  89598. * @param offset
  89599. * @param rotation
  89600. * @param scale
  89601. * @param scene
  89602. */
  89603. private _textureTransformTextureAsync;
  89604. }
  89605. }
  89606. declare module BABYLON.GLTF2.Exporter.Extensions {
  89607. /**
  89608. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  89609. */
  89610. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  89611. /** The name of this extension. */
  89612. readonly name: string;
  89613. /** Defines whether this extension is enabled. */
  89614. enabled: boolean;
  89615. /** Defines whether this extension is required */
  89616. required: boolean;
  89617. /** Reference to the glTF exporter */
  89618. private _exporter;
  89619. private _lights;
  89620. /** @hidden */
  89621. constructor(exporter: _Exporter);
  89622. /** @hidden */
  89623. dispose(): void;
  89624. /** @hidden */
  89625. get wasUsed(): boolean;
  89626. /** @hidden */
  89627. onExporting(): void;
  89628. /**
  89629. * Define this method to modify the default behavior when exporting a node
  89630. * @param context The context when exporting the node
  89631. * @param node glTF node
  89632. * @param babylonNode BabylonJS node
  89633. * @param nodeMap Node mapping of unique id to glTF node index
  89634. * @returns nullable INode promise
  89635. */
  89636. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89637. [key: number]: number;
  89638. }): Promise<Nullable<INode>>;
  89639. }
  89640. }
  89641. declare module BABYLON.GLTF2.Exporter.Extensions {
  89642. /**
  89643. * @hidden
  89644. */
  89645. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  89646. /** Name of this extension */
  89647. readonly name: string;
  89648. /** Defines whether this extension is enabled */
  89649. enabled: boolean;
  89650. /** Defines whether this extension is required */
  89651. required: boolean;
  89652. /** Reference to the glTF exporter */
  89653. private _textureInfos;
  89654. private _exportedTextures;
  89655. private _wasUsed;
  89656. constructor(exporter: _Exporter);
  89657. dispose(): void;
  89658. /** @hidden */
  89659. get wasUsed(): boolean;
  89660. private _getTextureIndex;
  89661. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  89662. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  89663. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  89664. }
  89665. }
  89666. declare module BABYLON.GLTF2.Exporter.Extensions {
  89667. /**
  89668. * @hidden
  89669. */
  89670. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  89671. /** Name of this extension */
  89672. readonly name: string;
  89673. /** Defines whether this extension is enabled */
  89674. enabled: boolean;
  89675. /** Defines whether this extension is required */
  89676. required: boolean;
  89677. private _wasUsed;
  89678. constructor(exporter: _Exporter);
  89679. /** @hidden */
  89680. get wasUsed(): boolean;
  89681. dispose(): void;
  89682. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  89683. }
  89684. }
  89685. declare module BABYLON {
  89686. /**
  89687. * Class for generating STL data from a Babylon scene.
  89688. */
  89689. export class STLExport {
  89690. /**
  89691. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  89692. * @param meshes list defines the mesh to serialize
  89693. * @param download triggers the automatic download of the file.
  89694. * @param fileName changes the downloads fileName.
  89695. * @param binary changes the STL to a binary type.
  89696. * @param isLittleEndian toggle for binary type exporter.
  89697. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  89698. * @returns the STL as UTF8 string
  89699. */
  89700. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  89701. }
  89702. }
  89703. declare module "babylonjs-gltf2interface" {
  89704. export = BABYLON.GLTF2;
  89705. }
  89706. /**
  89707. * Module for glTF 2.0 Interface
  89708. */
  89709. declare module BABYLON.GLTF2 {
  89710. /**
  89711. * The datatype of the components in the attribute
  89712. */
  89713. const enum AccessorComponentType {
  89714. /**
  89715. * Byte
  89716. */
  89717. BYTE = 5120,
  89718. /**
  89719. * Unsigned Byte
  89720. */
  89721. UNSIGNED_BYTE = 5121,
  89722. /**
  89723. * Short
  89724. */
  89725. SHORT = 5122,
  89726. /**
  89727. * Unsigned Short
  89728. */
  89729. UNSIGNED_SHORT = 5123,
  89730. /**
  89731. * Unsigned Int
  89732. */
  89733. UNSIGNED_INT = 5125,
  89734. /**
  89735. * Float
  89736. */
  89737. FLOAT = 5126,
  89738. }
  89739. /**
  89740. * Specifies if the attirbute is a scalar, vector, or matrix
  89741. */
  89742. const enum AccessorType {
  89743. /**
  89744. * Scalar
  89745. */
  89746. SCALAR = "SCALAR",
  89747. /**
  89748. * Vector2
  89749. */
  89750. VEC2 = "VEC2",
  89751. /**
  89752. * Vector3
  89753. */
  89754. VEC3 = "VEC3",
  89755. /**
  89756. * Vector4
  89757. */
  89758. VEC4 = "VEC4",
  89759. /**
  89760. * Matrix2x2
  89761. */
  89762. MAT2 = "MAT2",
  89763. /**
  89764. * Matrix3x3
  89765. */
  89766. MAT3 = "MAT3",
  89767. /**
  89768. * Matrix4x4
  89769. */
  89770. MAT4 = "MAT4",
  89771. }
  89772. /**
  89773. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  89774. */
  89775. const enum AnimationChannelTargetPath {
  89776. /**
  89777. * Translation
  89778. */
  89779. TRANSLATION = "translation",
  89780. /**
  89781. * Rotation
  89782. */
  89783. ROTATION = "rotation",
  89784. /**
  89785. * Scale
  89786. */
  89787. SCALE = "scale",
  89788. /**
  89789. * Weights
  89790. */
  89791. WEIGHTS = "weights",
  89792. }
  89793. /**
  89794. * Interpolation algorithm
  89795. */
  89796. const enum AnimationSamplerInterpolation {
  89797. /**
  89798. * The animated values are linearly interpolated between keyframes
  89799. */
  89800. LINEAR = "LINEAR",
  89801. /**
  89802. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  89803. */
  89804. STEP = "STEP",
  89805. /**
  89806. * The animation's interpolation is computed using a cubic spline with specified tangents
  89807. */
  89808. CUBICSPLINE = "CUBICSPLINE",
  89809. }
  89810. /**
  89811. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  89812. */
  89813. const enum CameraType {
  89814. /**
  89815. * A perspective camera containing properties to create a perspective projection matrix
  89816. */
  89817. PERSPECTIVE = "perspective",
  89818. /**
  89819. * An orthographic camera containing properties to create an orthographic projection matrix
  89820. */
  89821. ORTHOGRAPHIC = "orthographic",
  89822. }
  89823. /**
  89824. * The mime-type of the image
  89825. */
  89826. const enum ImageMimeType {
  89827. /**
  89828. * JPEG Mime-type
  89829. */
  89830. JPEG = "image/jpeg",
  89831. /**
  89832. * PNG Mime-type
  89833. */
  89834. PNG = "image/png",
  89835. }
  89836. /**
  89837. * The alpha rendering mode of the material
  89838. */
  89839. const enum MaterialAlphaMode {
  89840. /**
  89841. * The alpha value is ignored and the rendered output is fully opaque
  89842. */
  89843. OPAQUE = "OPAQUE",
  89844. /**
  89845. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  89846. */
  89847. MASK = "MASK",
  89848. /**
  89849. * 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)
  89850. */
  89851. BLEND = "BLEND",
  89852. }
  89853. /**
  89854. * The type of the primitives to render
  89855. */
  89856. const enum MeshPrimitiveMode {
  89857. /**
  89858. * Points
  89859. */
  89860. POINTS = 0,
  89861. /**
  89862. * Lines
  89863. */
  89864. LINES = 1,
  89865. /**
  89866. * Line Loop
  89867. */
  89868. LINE_LOOP = 2,
  89869. /**
  89870. * Line Strip
  89871. */
  89872. LINE_STRIP = 3,
  89873. /**
  89874. * Triangles
  89875. */
  89876. TRIANGLES = 4,
  89877. /**
  89878. * Triangle Strip
  89879. */
  89880. TRIANGLE_STRIP = 5,
  89881. /**
  89882. * Triangle Fan
  89883. */
  89884. TRIANGLE_FAN = 6,
  89885. }
  89886. /**
  89887. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  89888. */
  89889. const enum TextureMagFilter {
  89890. /**
  89891. * Nearest
  89892. */
  89893. NEAREST = 9728,
  89894. /**
  89895. * Linear
  89896. */
  89897. LINEAR = 9729,
  89898. }
  89899. /**
  89900. * Minification filter. All valid values correspond to WebGL enums
  89901. */
  89902. const enum TextureMinFilter {
  89903. /**
  89904. * Nearest
  89905. */
  89906. NEAREST = 9728,
  89907. /**
  89908. * Linear
  89909. */
  89910. LINEAR = 9729,
  89911. /**
  89912. * Nearest Mip-Map Nearest
  89913. */
  89914. NEAREST_MIPMAP_NEAREST = 9984,
  89915. /**
  89916. * Linear Mipmap Nearest
  89917. */
  89918. LINEAR_MIPMAP_NEAREST = 9985,
  89919. /**
  89920. * Nearest Mipmap Linear
  89921. */
  89922. NEAREST_MIPMAP_LINEAR = 9986,
  89923. /**
  89924. * Linear Mipmap Linear
  89925. */
  89926. LINEAR_MIPMAP_LINEAR = 9987,
  89927. }
  89928. /**
  89929. * S (U) wrapping mode. All valid values correspond to WebGL enums
  89930. */
  89931. const enum TextureWrapMode {
  89932. /**
  89933. * Clamp to Edge
  89934. */
  89935. CLAMP_TO_EDGE = 33071,
  89936. /**
  89937. * Mirrored Repeat
  89938. */
  89939. MIRRORED_REPEAT = 33648,
  89940. /**
  89941. * Repeat
  89942. */
  89943. REPEAT = 10497,
  89944. }
  89945. /**
  89946. * glTF Property
  89947. */
  89948. interface IProperty {
  89949. /**
  89950. * Dictionary object with extension-specific objects
  89951. */
  89952. extensions?: {
  89953. [key: string]: any;
  89954. };
  89955. /**
  89956. * Application-Specific data
  89957. */
  89958. extras?: any;
  89959. }
  89960. /**
  89961. * glTF Child of Root Property
  89962. */
  89963. interface IChildRootProperty extends IProperty {
  89964. /**
  89965. * The user-defined name of this object
  89966. */
  89967. name?: string;
  89968. }
  89969. /**
  89970. * Indices of those attributes that deviate from their initialization value
  89971. */
  89972. interface IAccessorSparseIndices extends IProperty {
  89973. /**
  89974. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  89975. */
  89976. bufferView: number;
  89977. /**
  89978. * The offset relative to the start of the bufferView in bytes. Must be aligned
  89979. */
  89980. byteOffset?: number;
  89981. /**
  89982. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  89983. */
  89984. componentType: AccessorComponentType;
  89985. }
  89986. /**
  89987. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  89988. */
  89989. interface IAccessorSparseValues extends IProperty {
  89990. /**
  89991. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  89992. */
  89993. bufferView: number;
  89994. /**
  89995. * The offset relative to the start of the bufferView in bytes. Must be aligned
  89996. */
  89997. byteOffset?: number;
  89998. }
  89999. /**
  90000. * Sparse storage of attributes that deviate from their initialization value
  90001. */
  90002. interface IAccessorSparse extends IProperty {
  90003. /**
  90004. * The number of attributes encoded in this sparse accessor
  90005. */
  90006. count: number;
  90007. /**
  90008. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  90009. */
  90010. indices: IAccessorSparseIndices;
  90011. /**
  90012. * 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
  90013. */
  90014. values: IAccessorSparseValues;
  90015. }
  90016. /**
  90017. * 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
  90018. */
  90019. interface IAccessor extends IChildRootProperty {
  90020. /**
  90021. * The index of the bufferview
  90022. */
  90023. bufferView?: number;
  90024. /**
  90025. * The offset relative to the start of the bufferView in bytes
  90026. */
  90027. byteOffset?: number;
  90028. /**
  90029. * The datatype of components in the attribute
  90030. */
  90031. componentType: AccessorComponentType;
  90032. /**
  90033. * Specifies whether integer data values should be normalized
  90034. */
  90035. normalized?: boolean;
  90036. /**
  90037. * The number of attributes referenced by this accessor
  90038. */
  90039. count: number;
  90040. /**
  90041. * Specifies if the attribute is a scalar, vector, or matrix
  90042. */
  90043. type: AccessorType;
  90044. /**
  90045. * Maximum value of each component in this attribute
  90046. */
  90047. max?: number[];
  90048. /**
  90049. * Minimum value of each component in this attribute
  90050. */
  90051. min?: number[];
  90052. /**
  90053. * Sparse storage of attributes that deviate from their initialization value
  90054. */
  90055. sparse?: IAccessorSparse;
  90056. }
  90057. /**
  90058. * Targets an animation's sampler at a node's property
  90059. */
  90060. interface IAnimationChannel extends IProperty {
  90061. /**
  90062. * The index of a sampler in this animation used to compute the value for the target
  90063. */
  90064. sampler: number;
  90065. /**
  90066. * The index of the node and TRS property to target
  90067. */
  90068. target: IAnimationChannelTarget;
  90069. }
  90070. /**
  90071. * The index of the node and TRS property that an animation channel targets
  90072. */
  90073. interface IAnimationChannelTarget extends IProperty {
  90074. /**
  90075. * The index of the node to target
  90076. */
  90077. node: number;
  90078. /**
  90079. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90080. */
  90081. path: AnimationChannelTargetPath;
  90082. }
  90083. /**
  90084. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90085. */
  90086. interface IAnimationSampler extends IProperty {
  90087. /**
  90088. * The index of an accessor containing keyframe input values, e.g., time
  90089. */
  90090. input: number;
  90091. /**
  90092. * Interpolation algorithm
  90093. */
  90094. interpolation?: AnimationSamplerInterpolation;
  90095. /**
  90096. * The index of an accessor, containing keyframe output values
  90097. */
  90098. output: number;
  90099. }
  90100. /**
  90101. * A keyframe animation
  90102. */
  90103. interface IAnimation extends IChildRootProperty {
  90104. /**
  90105. * An array of channels, each of which targets an animation's sampler at a node's property
  90106. */
  90107. channels: IAnimationChannel[];
  90108. /**
  90109. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90110. */
  90111. samplers: IAnimationSampler[];
  90112. }
  90113. /**
  90114. * Metadata about the glTF asset
  90115. */
  90116. interface IAsset extends IChildRootProperty {
  90117. /**
  90118. * A copyright message suitable for display to credit the content creator
  90119. */
  90120. copyright?: string;
  90121. /**
  90122. * Tool that generated this glTF model. Useful for debugging
  90123. */
  90124. generator?: string;
  90125. /**
  90126. * The glTF version that this asset targets
  90127. */
  90128. version: string;
  90129. /**
  90130. * The minimum glTF version that this asset targets
  90131. */
  90132. minVersion?: string;
  90133. }
  90134. /**
  90135. * A buffer points to binary geometry, animation, or skins
  90136. */
  90137. interface IBuffer extends IChildRootProperty {
  90138. /**
  90139. * 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
  90140. */
  90141. uri?: string;
  90142. /**
  90143. * The length of the buffer in bytes
  90144. */
  90145. byteLength: number;
  90146. }
  90147. /**
  90148. * A view into a buffer generally representing a subset of the buffer
  90149. */
  90150. interface IBufferView extends IChildRootProperty {
  90151. /**
  90152. * The index of the buffer
  90153. */
  90154. buffer: number;
  90155. /**
  90156. * The offset into the buffer in bytes
  90157. */
  90158. byteOffset?: number;
  90159. /**
  90160. * The lenth of the bufferView in bytes
  90161. */
  90162. byteLength: number;
  90163. /**
  90164. * The stride, in bytes
  90165. */
  90166. byteStride?: number;
  90167. }
  90168. /**
  90169. * An orthographic camera containing properties to create an orthographic projection matrix
  90170. */
  90171. interface ICameraOrthographic extends IProperty {
  90172. /**
  90173. * The floating-point horizontal magnification of the view. Must not be zero
  90174. */
  90175. xmag: number;
  90176. /**
  90177. * The floating-point vertical magnification of the view. Must not be zero
  90178. */
  90179. ymag: number;
  90180. /**
  90181. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  90182. */
  90183. zfar: number;
  90184. /**
  90185. * The floating-point distance to the near clipping plane
  90186. */
  90187. znear: number;
  90188. }
  90189. /**
  90190. * A perspective camera containing properties to create a perspective projection matrix
  90191. */
  90192. interface ICameraPerspective extends IProperty {
  90193. /**
  90194. * The floating-point aspect ratio of the field of view
  90195. */
  90196. aspectRatio?: number;
  90197. /**
  90198. * The floating-point vertical field of view in radians
  90199. */
  90200. yfov: number;
  90201. /**
  90202. * The floating-point distance to the far clipping plane
  90203. */
  90204. zfar?: number;
  90205. /**
  90206. * The floating-point distance to the near clipping plane
  90207. */
  90208. znear: number;
  90209. }
  90210. /**
  90211. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90212. */
  90213. interface ICamera extends IChildRootProperty {
  90214. /**
  90215. * An orthographic camera containing properties to create an orthographic projection matrix
  90216. */
  90217. orthographic?: ICameraOrthographic;
  90218. /**
  90219. * A perspective camera containing properties to create a perspective projection matrix
  90220. */
  90221. perspective?: ICameraPerspective;
  90222. /**
  90223. * Specifies if the camera uses a perspective or orthographic projection
  90224. */
  90225. type: CameraType;
  90226. }
  90227. /**
  90228. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  90229. */
  90230. interface IImage extends IChildRootProperty {
  90231. /**
  90232. * 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
  90233. */
  90234. uri?: string;
  90235. /**
  90236. * The image's MIME type
  90237. */
  90238. mimeType?: ImageMimeType;
  90239. /**
  90240. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  90241. */
  90242. bufferView?: number;
  90243. }
  90244. /**
  90245. * Material Normal Texture Info
  90246. */
  90247. interface IMaterialNormalTextureInfo extends ITextureInfo {
  90248. /**
  90249. * The scalar multiplier applied to each normal vector of the normal texture
  90250. */
  90251. scale?: number;
  90252. }
  90253. /**
  90254. * Material Occlusion Texture Info
  90255. */
  90256. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  90257. /**
  90258. * A scalar multiplier controlling the amount of occlusion applied
  90259. */
  90260. strength?: number;
  90261. }
  90262. /**
  90263. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  90264. */
  90265. interface IMaterialPbrMetallicRoughness {
  90266. /**
  90267. * The material's base color factor
  90268. */
  90269. baseColorFactor?: number[];
  90270. /**
  90271. * The base color texture
  90272. */
  90273. baseColorTexture?: ITextureInfo;
  90274. /**
  90275. * The metalness of the material
  90276. */
  90277. metallicFactor?: number;
  90278. /**
  90279. * The roughness of the material
  90280. */
  90281. roughnessFactor?: number;
  90282. /**
  90283. * The metallic-roughness texture
  90284. */
  90285. metallicRoughnessTexture?: ITextureInfo;
  90286. }
  90287. /**
  90288. * The material appearance of a primitive
  90289. */
  90290. interface IMaterial extends IChildRootProperty {
  90291. /**
  90292. * 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
  90293. */
  90294. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  90295. /**
  90296. * The normal map texture
  90297. */
  90298. normalTexture?: IMaterialNormalTextureInfo;
  90299. /**
  90300. * The occlusion map texture
  90301. */
  90302. occlusionTexture?: IMaterialOcclusionTextureInfo;
  90303. /**
  90304. * The emissive map texture
  90305. */
  90306. emissiveTexture?: ITextureInfo;
  90307. /**
  90308. * 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
  90309. */
  90310. emissiveFactor?: number[];
  90311. /**
  90312. * The alpha rendering mode of the material
  90313. */
  90314. alphaMode?: MaterialAlphaMode;
  90315. /**
  90316. * The alpha cutoff value of the material
  90317. */
  90318. alphaCutoff?: number;
  90319. /**
  90320. * Specifies whether the material is double sided
  90321. */
  90322. doubleSided?: boolean;
  90323. }
  90324. /**
  90325. * Geometry to be rendered with the given material
  90326. */
  90327. interface IMeshPrimitive extends IProperty {
  90328. /**
  90329. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  90330. */
  90331. attributes: {
  90332. [name: string]: number;
  90333. };
  90334. /**
  90335. * The index of the accessor that contains the indices
  90336. */
  90337. indices?: number;
  90338. /**
  90339. * The index of the material to apply to this primitive when rendering
  90340. */
  90341. material?: number;
  90342. /**
  90343. * The type of primitives to render. All valid values correspond to WebGL enums
  90344. */
  90345. mode?: MeshPrimitiveMode;
  90346. /**
  90347. * 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
  90348. */
  90349. targets?: {
  90350. [name: string]: number;
  90351. }[];
  90352. }
  90353. /**
  90354. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  90355. */
  90356. interface IMesh extends IChildRootProperty {
  90357. /**
  90358. * An array of primitives, each defining geometry to be rendered with a material
  90359. */
  90360. primitives: IMeshPrimitive[];
  90361. /**
  90362. * Array of weights to be applied to the Morph Targets
  90363. */
  90364. weights?: number[];
  90365. }
  90366. /**
  90367. * A node in the node hierarchy
  90368. */
  90369. interface INode extends IChildRootProperty {
  90370. /**
  90371. * The index of the camera referenced by this node
  90372. */
  90373. camera?: number;
  90374. /**
  90375. * The indices of this node's children
  90376. */
  90377. children?: number[];
  90378. /**
  90379. * The index of the skin referenced by this node
  90380. */
  90381. skin?: number;
  90382. /**
  90383. * A floating-point 4x4 transformation matrix stored in column-major order
  90384. */
  90385. matrix?: number[];
  90386. /**
  90387. * The index of the mesh in this node
  90388. */
  90389. mesh?: number;
  90390. /**
  90391. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  90392. */
  90393. rotation?: number[];
  90394. /**
  90395. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  90396. */
  90397. scale?: number[];
  90398. /**
  90399. * The node's translation along the x, y, and z axes
  90400. */
  90401. translation?: number[];
  90402. /**
  90403. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  90404. */
  90405. weights?: number[];
  90406. }
  90407. /**
  90408. * Texture sampler properties for filtering and wrapping modes
  90409. */
  90410. interface ISampler extends IChildRootProperty {
  90411. /**
  90412. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90413. */
  90414. magFilter?: TextureMagFilter;
  90415. /**
  90416. * Minification filter. All valid values correspond to WebGL enums
  90417. */
  90418. minFilter?: TextureMinFilter;
  90419. /**
  90420. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90421. */
  90422. wrapS?: TextureWrapMode;
  90423. /**
  90424. * T (V) wrapping mode. All valid values correspond to WebGL enums
  90425. */
  90426. wrapT?: TextureWrapMode;
  90427. }
  90428. /**
  90429. * The root nodes of a scene
  90430. */
  90431. interface IScene extends IChildRootProperty {
  90432. /**
  90433. * The indices of each root node
  90434. */
  90435. nodes: number[];
  90436. }
  90437. /**
  90438. * Joints and matrices defining a skin
  90439. */
  90440. interface ISkin extends IChildRootProperty {
  90441. /**
  90442. * 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
  90443. */
  90444. inverseBindMatrices?: number;
  90445. /**
  90446. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  90447. */
  90448. skeleton?: number;
  90449. /**
  90450. * 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)
  90451. */
  90452. joints: number[];
  90453. }
  90454. /**
  90455. * A texture and its sampler
  90456. */
  90457. interface ITexture extends IChildRootProperty {
  90458. /**
  90459. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  90460. */
  90461. sampler?: number;
  90462. /**
  90463. * The index of the image used by this texture
  90464. */
  90465. source: number;
  90466. }
  90467. /**
  90468. * Reference to a texture
  90469. */
  90470. interface ITextureInfo extends IProperty {
  90471. /**
  90472. * The index of the texture
  90473. */
  90474. index: number;
  90475. /**
  90476. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  90477. */
  90478. texCoord?: number;
  90479. }
  90480. /**
  90481. * The root object for a glTF asset
  90482. */
  90483. interface IGLTF extends IProperty {
  90484. /**
  90485. * An array of accessors. An accessor is a typed view into a bufferView
  90486. */
  90487. accessors?: IAccessor[];
  90488. /**
  90489. * An array of keyframe animations
  90490. */
  90491. animations?: IAnimation[];
  90492. /**
  90493. * Metadata about the glTF asset
  90494. */
  90495. asset: IAsset;
  90496. /**
  90497. * An array of buffers. A buffer points to binary geometry, animation, or skins
  90498. */
  90499. buffers?: IBuffer[];
  90500. /**
  90501. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  90502. */
  90503. bufferViews?: IBufferView[];
  90504. /**
  90505. * An array of cameras
  90506. */
  90507. cameras?: ICamera[];
  90508. /**
  90509. * Names of glTF extensions used somewhere in this asset
  90510. */
  90511. extensionsUsed?: string[];
  90512. /**
  90513. * Names of glTF extensions required to properly load this asset
  90514. */
  90515. extensionsRequired?: string[];
  90516. /**
  90517. * An array of images. An image defines data used to create a texture
  90518. */
  90519. images?: IImage[];
  90520. /**
  90521. * An array of materials. A material defines the appearance of a primitive
  90522. */
  90523. materials?: IMaterial[];
  90524. /**
  90525. * An array of meshes. A mesh is a set of primitives to be rendered
  90526. */
  90527. meshes?: IMesh[];
  90528. /**
  90529. * An array of nodes
  90530. */
  90531. nodes?: INode[];
  90532. /**
  90533. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  90534. */
  90535. samplers?: ISampler[];
  90536. /**
  90537. * The index of the default scene
  90538. */
  90539. scene?: number;
  90540. /**
  90541. * An array of scenes
  90542. */
  90543. scenes?: IScene[];
  90544. /**
  90545. * An array of skins. A skin is defined by joints and matrices
  90546. */
  90547. skins?: ISkin[];
  90548. /**
  90549. * An array of textures
  90550. */
  90551. textures?: ITexture[];
  90552. }
  90553. /**
  90554. * The glTF validation results
  90555. * @ignore
  90556. */
  90557. interface IGLTFValidationResults {
  90558. info: {
  90559. generator: string;
  90560. hasAnimations: boolean;
  90561. hasDefaultScene: boolean;
  90562. hasMaterials: boolean;
  90563. hasMorphTargets: boolean;
  90564. hasSkins: boolean;
  90565. hasTextures: boolean;
  90566. maxAttributesUsed: number;
  90567. primitivesCount: number
  90568. };
  90569. issues: {
  90570. messages: Array<string>;
  90571. numErrors: number;
  90572. numHints: number;
  90573. numInfos: number;
  90574. numWarnings: number;
  90575. truncated: boolean
  90576. };
  90577. mimeType: string;
  90578. uri: string;
  90579. validatedAt: string;
  90580. validatorVersion: string;
  90581. }
  90582. /**
  90583. * The glTF validation options
  90584. */
  90585. interface IGLTFValidationOptions {
  90586. /** Uri to use */
  90587. uri?: string;
  90588. /** Function used to load external resources */
  90589. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  90590. /** Boolean indicating that we need to validate accessor data */
  90591. validateAccessorData?: boolean;
  90592. /** max number of issues allowed */
  90593. maxIssues?: number;
  90594. /** Ignored issues */
  90595. ignoredIssues?: Array<string>;
  90596. /** Value to override severy settings */
  90597. severityOverrides?: Object;
  90598. }
  90599. /**
  90600. * The glTF validator object
  90601. * @ignore
  90602. */
  90603. interface IGLTFValidator {
  90604. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  90605. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  90606. }
  90607. /**
  90608. * Interfaces from the EXT_lights_image_based extension
  90609. */
  90610. /** @hidden */
  90611. interface IEXTLightsImageBased_LightReferenceImageBased {
  90612. light: number;
  90613. }
  90614. /** @hidden */
  90615. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  90616. intensity: number;
  90617. rotation: number[];
  90618. specularImageSize: number;
  90619. specularImages: number[][];
  90620. irradianceCoefficients: number[][];
  90621. }
  90622. /** @hidden */
  90623. interface IEXTLightsImageBased {
  90624. lights: IEXTLightsImageBased_LightImageBased[];
  90625. }
  90626. /**
  90627. * Interfaces from the EXT_mesh_gpu_instancing extension
  90628. * !!! Experimental Extension Subject to Changes !!!
  90629. */
  90630. /** @hidden */
  90631. interface IEXTMeshGpuInstancing {
  90632. mesh?: number;
  90633. attributes: { [name: string]: number };
  90634. }
  90635. /**
  90636. * Interfaces from the KHR_draco_mesh_compression extension
  90637. */
  90638. /** @hidden */
  90639. interface IKHRDracoMeshCompression {
  90640. bufferView: number;
  90641. attributes: { [name: string]: number };
  90642. }
  90643. /**
  90644. * Interfaces from the KHR_lights_punctual extension
  90645. */
  90646. /** @hidden */
  90647. const enum IKHRLightsPunctual_LightType {
  90648. DIRECTIONAL = "directional",
  90649. POINT = "point",
  90650. SPOT = "spot"
  90651. }
  90652. /** @hidden */
  90653. interface IKHRLightsPunctual_LightReference {
  90654. light: number;
  90655. }
  90656. /** @hidden */
  90657. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  90658. type: IKHRLightsPunctual_LightType;
  90659. color?: number[];
  90660. intensity?: number;
  90661. range?: number;
  90662. spot?: {
  90663. innerConeAngle?: number;
  90664. outerConeAngle?: number;
  90665. };
  90666. }
  90667. /** @hidden */
  90668. interface IKHRLightsPunctual {
  90669. lights: IKHRLightsPunctual_Light[];
  90670. }
  90671. /**
  90672. * Interfaces from the KHR_materials_clearcoat extension
  90673. * !!! Experimental Extension Subject to Changes !!!
  90674. */
  90675. /** @hidden */
  90676. interface IKHRMaterialsClearcoat {
  90677. clearcoatFactor: number;
  90678. clearcoatTexture: ITextureInfo;
  90679. clearcoatRoughnessFactor: number;
  90680. clearcoatRoughnessTexture: ITextureInfo;
  90681. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  90682. }
  90683. /**
  90684. * Interfaces from the KHR_materials_ior extension
  90685. * !!! Experimental Extension Subject to Changes !!!
  90686. */
  90687. /** @hidden */
  90688. interface IKHRMaterialsIor {
  90689. ior: number;
  90690. }
  90691. /**
  90692. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  90693. */
  90694. /** @hidden */
  90695. interface IKHRMaterialsPbrSpecularGlossiness {
  90696. diffuseFactor: number[];
  90697. diffuseTexture: ITextureInfo;
  90698. specularFactor: number[];
  90699. glossinessFactor: number;
  90700. specularGlossinessTexture: ITextureInfo;
  90701. }
  90702. /**
  90703. * Interfaces from the KHR_materials_sheen extension
  90704. * !!! Experimental Extension Subject to Changes !!!
  90705. */
  90706. /** @hidden */
  90707. interface IKHRMaterialsSheen {
  90708. sheenColorFactor?: number[];
  90709. sheenColorTexture?: ITextureInfo;
  90710. sheenRoughnessFactor?: number;
  90711. sheenRoughnessTexture?: ITextureInfo;
  90712. }
  90713. /**
  90714. * Interfaces from the KHR_materials_specular extension
  90715. * !!! Experimental Extension Subject to Changes !!!
  90716. */
  90717. /** @hidden */
  90718. interface IKHRMaterialsSpecular {
  90719. specularFactor: number;
  90720. specularColorFactor: number[];
  90721. specularTexture: ITextureInfo;
  90722. }
  90723. /**
  90724. * Interfaces from the KHR_materials_transmission extension
  90725. * !!! Experimental Extension Subject to Changes !!!
  90726. */
  90727. /** @hidden */
  90728. interface IKHRMaterialsTransmission {
  90729. transmissionFactor?: number;
  90730. transmissionTexture?: ITextureInfo;
  90731. }
  90732. /**
  90733. * Interfaces from the KHR_materials_translucency extension
  90734. * !!! Experimental Extension Subject to Changes !!!
  90735. */
  90736. /** @hidden */
  90737. interface IKHRMaterialsTranslucency {
  90738. translucencyFactor?: number;
  90739. translucencyTexture?: ITextureInfo;
  90740. }
  90741. /**
  90742. * Interfaces from the KHR_materials_variants extension
  90743. * !!! Experimental Extension Subject to Changes !!!
  90744. */
  90745. /** @hidden */
  90746. interface IKHRMaterialVariants_Mapping extends IProperty {
  90747. mappings: Array<{
  90748. variants: number[];
  90749. material: number;
  90750. }>;
  90751. }
  90752. /** @hidden */
  90753. interface IKHRMaterialVariants_Variant extends IProperty {
  90754. name: string;
  90755. }
  90756. /** @hidden */
  90757. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  90758. variants: Array<IKHRMaterialVariants_Variant>;
  90759. }
  90760. /**
  90761. * Interfaces from the KHR_texture_basisu extension
  90762. * !!! Experimental Extension Subject to Changes !!!
  90763. */
  90764. /** @hidden */
  90765. interface IKHRTextureBasisU {
  90766. source: number;
  90767. }
  90768. /**
  90769. * Interfaces from the EXT_texture_webp extension
  90770. */
  90771. /** @hidden */
  90772. interface IEXTTextureWebP {
  90773. source: number;
  90774. }
  90775. /**
  90776. * Interfaces from the KHR_texture_transform extension
  90777. */
  90778. /** @hidden */
  90779. interface IKHRTextureTransform {
  90780. offset?: number[];
  90781. rotation?: number;
  90782. scale?: number[];
  90783. texCoord?: number;
  90784. }
  90785. /**
  90786. * Interfaces from the KHR_xmp extension
  90787. * !!! Experimental Extension Subject to Changes !!!
  90788. */
  90789. /** @hidden */
  90790. interface IKHRXmp_Data {
  90791. [key: string]: unknown;
  90792. }
  90793. /** @hidden */
  90794. interface IKHRXmp_Gltf {
  90795. packets: IKHRXmp_Data[];
  90796. }
  90797. /** @hidden */
  90798. interface IKHRXmp_Node {
  90799. packet: number;
  90800. }
  90801. /**
  90802. * Interfaces from the MSFT_audio_emitter extension
  90803. */
  90804. /** @hidden */
  90805. interface IMSFTAudioEmitter_ClipReference {
  90806. clip: number;
  90807. weight?: number;
  90808. }
  90809. /** @hidden */
  90810. interface IMSFTAudioEmitter_EmittersReference {
  90811. emitters: number[];
  90812. }
  90813. /** @hidden */
  90814. const enum IMSFTAudioEmitter_DistanceModel {
  90815. linear = "linear",
  90816. inverse = "inverse",
  90817. exponential = "exponential",
  90818. }
  90819. /** @hidden */
  90820. interface IMSFTAudioEmitter_Emitter {
  90821. name?: string;
  90822. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  90823. refDistance?: number;
  90824. maxDistance?: number;
  90825. rolloffFactor?: number;
  90826. innerAngle?: number;
  90827. outerAngle?: number;
  90828. loop?: boolean;
  90829. volume?: number;
  90830. clips: IMSFTAudioEmitter_ClipReference[];
  90831. }
  90832. /** @hidden */
  90833. const enum IMSFTAudioEmitter_AudioMimeType {
  90834. WAV = "audio/wav",
  90835. }
  90836. /** @hidden */
  90837. interface IMSFTAudioEmitter_Clip extends IProperty {
  90838. uri?: string;
  90839. bufferView?: number;
  90840. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  90841. }
  90842. /** @hidden */
  90843. const enum IMSFTAudioEmitter_AnimationEventAction {
  90844. play = "play",
  90845. pause = "pause",
  90846. stop = "stop",
  90847. }
  90848. /** @hidden */
  90849. interface IMSFTAudioEmitter_AnimationEvent {
  90850. action: IMSFTAudioEmitter_AnimationEventAction;
  90851. emitter: number;
  90852. time: number;
  90853. startOffset?: number;
  90854. }
  90855. /**
  90856. * Interfaces from the MSFT_lod extension
  90857. */
  90858. /** @hidden */
  90859. interface IMSFTLOD {
  90860. ids: number[];
  90861. }
  90862. /**
  90863. * Interfaces from the EXT_meshopt_compression extension
  90864. */
  90865. /** @hidden */
  90866. interface IEXTMeshoptCompression {
  90867. buffer: number;
  90868. byteOffset?: number;
  90869. byteLength: number;
  90870. byteStride: number;
  90871. count: number;
  90872. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  90873. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  90874. }
  90875. }
  90876. declare module BABYLON {
  90877. /** @hidden */
  90878. export var cellPixelShader: {
  90879. name: string;
  90880. shader: string;
  90881. };
  90882. }
  90883. declare module BABYLON {
  90884. /** @hidden */
  90885. export var cellVertexShader: {
  90886. name: string;
  90887. shader: string;
  90888. };
  90889. }
  90890. declare module BABYLON {
  90891. export class CellMaterial extends BABYLON.PushMaterial {
  90892. private _diffuseTexture;
  90893. diffuseTexture: BABYLON.BaseTexture;
  90894. diffuseColor: BABYLON.Color3;
  90895. _computeHighLevel: boolean;
  90896. computeHighLevel: boolean;
  90897. private _disableLighting;
  90898. disableLighting: boolean;
  90899. private _maxSimultaneousLights;
  90900. maxSimultaneousLights: number;
  90901. constructor(name: string, scene: BABYLON.Scene);
  90902. needAlphaBlending(): boolean;
  90903. needAlphaTesting(): boolean;
  90904. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  90905. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  90906. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  90907. getAnimatables(): BABYLON.IAnimatable[];
  90908. getActiveTextures(): BABYLON.BaseTexture[];
  90909. hasTexture(texture: BABYLON.BaseTexture): boolean;
  90910. dispose(forceDisposeEffect?: boolean): void;
  90911. getClassName(): string;
  90912. clone(name: string): CellMaterial;
  90913. serialize(): any;
  90914. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  90915. }
  90916. }
  90917. declare module BABYLON {
  90918. export class CustomShaderStructure {
  90919. FragmentStore: string;
  90920. VertexStore: string;
  90921. constructor();
  90922. }
  90923. export class ShaderSpecialParts {
  90924. constructor();
  90925. Fragment_Begin: string;
  90926. Fragment_Definitions: string;
  90927. Fragment_MainBegin: string;
  90928. Fragment_Custom_Diffuse: string;
  90929. Fragment_Before_Lights: string;
  90930. Fragment_Before_Fog: string;
  90931. Fragment_Custom_Alpha: string;
  90932. Fragment_Before_FragColor: string;
  90933. Vertex_Begin: string;
  90934. Vertex_Definitions: string;
  90935. Vertex_MainBegin: string;
  90936. Vertex_Before_PositionUpdated: string;
  90937. Vertex_Before_NormalUpdated: string;
  90938. Vertex_After_WorldPosComputed: string;
  90939. Vertex_MainEnd: string;
  90940. }
  90941. export class CustomMaterial extends BABYLON.StandardMaterial {
  90942. static ShaderIndexer: number;
  90943. CustomParts: ShaderSpecialParts;
  90944. _isCreatedShader: boolean;
  90945. _createdShaderName: string;
  90946. _customUniform: string[];
  90947. _newUniforms: string[];
  90948. _newUniformInstances: {
  90949. [name: string]: any;
  90950. };
  90951. _newSamplerInstances: {
  90952. [name: string]: BABYLON.Texture;
  90953. };
  90954. _customAttributes: string[];
  90955. FragmentShader: string;
  90956. VertexShader: string;
  90957. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  90958. ReviewUniform(name: string, arr: string[]): string[];
  90959. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  90960. constructor(name: string, scene: BABYLON.Scene);
  90961. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  90962. AddAttribute(name: string): CustomMaterial;
  90963. Fragment_Begin(shaderPart: string): CustomMaterial;
  90964. Fragment_Definitions(shaderPart: string): CustomMaterial;
  90965. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  90966. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  90967. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  90968. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  90969. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  90970. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  90971. Vertex_Begin(shaderPart: string): CustomMaterial;
  90972. Vertex_Definitions(shaderPart: string): CustomMaterial;
  90973. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  90974. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  90975. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  90976. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  90977. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  90978. }
  90979. }
  90980. declare module BABYLON {
  90981. export class ShaderAlebdoParts {
  90982. constructor();
  90983. Fragment_Begin: string;
  90984. Fragment_Definitions: string;
  90985. Fragment_MainBegin: string;
  90986. Fragment_Custom_Albedo: string;
  90987. Fragment_Before_Lights: string;
  90988. Fragment_Custom_MetallicRoughness: string;
  90989. Fragment_Custom_MicroSurface: string;
  90990. Fragment_Before_Fog: string;
  90991. Fragment_Custom_Alpha: string;
  90992. Fragment_Before_FragColor: string;
  90993. Vertex_Begin: string;
  90994. Vertex_Definitions: string;
  90995. Vertex_MainBegin: string;
  90996. Vertex_Before_PositionUpdated: string;
  90997. Vertex_Before_NormalUpdated: string;
  90998. Vertex_After_WorldPosComputed: string;
  90999. Vertex_MainEnd: string;
  91000. }
  91001. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  91002. static ShaderIndexer: number;
  91003. CustomParts: ShaderAlebdoParts;
  91004. _isCreatedShader: boolean;
  91005. _createdShaderName: string;
  91006. _customUniform: string[];
  91007. _newUniforms: string[];
  91008. _newUniformInstances: {
  91009. [name: string]: any;
  91010. };
  91011. _newSamplerInstances: {
  91012. [name: string]: BABYLON.Texture;
  91013. };
  91014. _customAttributes: string[];
  91015. FragmentShader: string;
  91016. VertexShader: string;
  91017. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91018. ReviewUniform(name: string, arr: string[]): string[];
  91019. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91020. constructor(name: string, scene: BABYLON.Scene);
  91021. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  91022. AddAttribute(name: string): PBRCustomMaterial;
  91023. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  91024. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  91025. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  91026. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  91027. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  91028. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  91029. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  91030. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  91031. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  91032. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  91033. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  91034. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  91035. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  91036. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  91037. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  91038. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  91039. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  91040. }
  91041. }
  91042. declare module BABYLON {
  91043. /** @hidden */
  91044. export var firePixelShader: {
  91045. name: string;
  91046. shader: string;
  91047. };
  91048. }
  91049. declare module BABYLON {
  91050. /** @hidden */
  91051. export var fireVertexShader: {
  91052. name: string;
  91053. shader: string;
  91054. };
  91055. }
  91056. declare module BABYLON {
  91057. export class FireMaterial extends BABYLON.PushMaterial {
  91058. private _diffuseTexture;
  91059. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91060. private _distortionTexture;
  91061. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91062. private _opacityTexture;
  91063. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91064. diffuseColor: BABYLON.Color3;
  91065. speed: number;
  91066. private _scaledDiffuse;
  91067. private _lastTime;
  91068. constructor(name: string, scene: BABYLON.Scene);
  91069. needAlphaBlending(): boolean;
  91070. needAlphaTesting(): boolean;
  91071. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91072. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91073. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91074. getAnimatables(): BABYLON.IAnimatable[];
  91075. getActiveTextures(): BABYLON.BaseTexture[];
  91076. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91077. getClassName(): string;
  91078. dispose(forceDisposeEffect?: boolean): void;
  91079. clone(name: string): FireMaterial;
  91080. serialize(): any;
  91081. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  91082. }
  91083. }
  91084. declare module BABYLON {
  91085. /** @hidden */
  91086. export var furPixelShader: {
  91087. name: string;
  91088. shader: string;
  91089. };
  91090. }
  91091. declare module BABYLON {
  91092. /** @hidden */
  91093. export var furVertexShader: {
  91094. name: string;
  91095. shader: string;
  91096. };
  91097. }
  91098. declare module BABYLON {
  91099. export class FurMaterial extends BABYLON.PushMaterial {
  91100. private _diffuseTexture;
  91101. diffuseTexture: BABYLON.BaseTexture;
  91102. private _heightTexture;
  91103. heightTexture: BABYLON.BaseTexture;
  91104. diffuseColor: BABYLON.Color3;
  91105. furLength: number;
  91106. furAngle: number;
  91107. furColor: BABYLON.Color3;
  91108. furOffset: number;
  91109. furSpacing: number;
  91110. furGravity: BABYLON.Vector3;
  91111. furSpeed: number;
  91112. furDensity: number;
  91113. furOcclusion: number;
  91114. furTexture: BABYLON.DynamicTexture;
  91115. private _disableLighting;
  91116. disableLighting: boolean;
  91117. private _maxSimultaneousLights;
  91118. maxSimultaneousLights: number;
  91119. highLevelFur: boolean;
  91120. _meshes: BABYLON.AbstractMesh[];
  91121. private _furTime;
  91122. constructor(name: string, scene: BABYLON.Scene);
  91123. get furTime(): number;
  91124. set furTime(furTime: number);
  91125. needAlphaBlending(): boolean;
  91126. needAlphaTesting(): boolean;
  91127. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91128. updateFur(): void;
  91129. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91130. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91131. getAnimatables(): BABYLON.IAnimatable[];
  91132. getActiveTextures(): BABYLON.BaseTexture[];
  91133. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91134. dispose(forceDisposeEffect?: boolean): void;
  91135. clone(name: string): FurMaterial;
  91136. serialize(): any;
  91137. getClassName(): string;
  91138. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  91139. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  91140. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  91141. }
  91142. }
  91143. declare module BABYLON {
  91144. /** @hidden */
  91145. export var gradientPixelShader: {
  91146. name: string;
  91147. shader: string;
  91148. };
  91149. }
  91150. declare module BABYLON {
  91151. /** @hidden */
  91152. export var gradientVertexShader: {
  91153. name: string;
  91154. shader: string;
  91155. };
  91156. }
  91157. declare module BABYLON {
  91158. export class GradientMaterial extends BABYLON.PushMaterial {
  91159. private _maxSimultaneousLights;
  91160. maxSimultaneousLights: number;
  91161. topColor: BABYLON.Color3;
  91162. topColorAlpha: number;
  91163. bottomColor: BABYLON.Color3;
  91164. bottomColorAlpha: number;
  91165. offset: number;
  91166. scale: number;
  91167. smoothness: number;
  91168. private _disableLighting;
  91169. disableLighting: boolean;
  91170. constructor(name: string, scene: BABYLON.Scene);
  91171. needAlphaBlending(): boolean;
  91172. needAlphaTesting(): boolean;
  91173. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91174. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91175. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91176. getAnimatables(): BABYLON.IAnimatable[];
  91177. dispose(forceDisposeEffect?: boolean): void;
  91178. clone(name: string): GradientMaterial;
  91179. serialize(): any;
  91180. getClassName(): string;
  91181. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  91182. }
  91183. }
  91184. declare module BABYLON {
  91185. /** @hidden */
  91186. export var gridPixelShader: {
  91187. name: string;
  91188. shader: string;
  91189. };
  91190. }
  91191. declare module BABYLON {
  91192. /** @hidden */
  91193. export var gridVertexShader: {
  91194. name: string;
  91195. shader: string;
  91196. };
  91197. }
  91198. declare module BABYLON {
  91199. /**
  91200. * The grid materials allows you to wrap any shape with a grid.
  91201. * Colors are customizable.
  91202. */
  91203. export class GridMaterial extends BABYLON.PushMaterial {
  91204. /**
  91205. * Main color of the grid (e.g. between lines)
  91206. */
  91207. mainColor: BABYLON.Color3;
  91208. /**
  91209. * Color of the grid lines.
  91210. */
  91211. lineColor: BABYLON.Color3;
  91212. /**
  91213. * The scale of the grid compared to unit.
  91214. */
  91215. gridRatio: number;
  91216. /**
  91217. * Allows setting an offset for the grid lines.
  91218. */
  91219. gridOffset: BABYLON.Vector3;
  91220. /**
  91221. * The frequency of thicker lines.
  91222. */
  91223. majorUnitFrequency: number;
  91224. /**
  91225. * The visibility of minor units in the grid.
  91226. */
  91227. minorUnitVisibility: number;
  91228. /**
  91229. * The grid opacity outside of the lines.
  91230. */
  91231. opacity: number;
  91232. /**
  91233. * Determine RBG output is premultiplied by alpha value.
  91234. */
  91235. preMultiplyAlpha: boolean;
  91236. private _opacityTexture;
  91237. opacityTexture: BABYLON.BaseTexture;
  91238. private _gridControl;
  91239. /**
  91240. * constructor
  91241. * @param name The name given to the material in order to identify it afterwards.
  91242. * @param scene The scene the material is used in.
  91243. */
  91244. constructor(name: string, scene: BABYLON.Scene);
  91245. /**
  91246. * Returns wehter or not the grid requires alpha blending.
  91247. */
  91248. needAlphaBlending(): boolean;
  91249. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  91250. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91251. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91252. /**
  91253. * Dispose the material and its associated resources.
  91254. * @param forceDisposeEffect will also dispose the used effect when true
  91255. */
  91256. dispose(forceDisposeEffect?: boolean): void;
  91257. clone(name: string): GridMaterial;
  91258. serialize(): any;
  91259. getClassName(): string;
  91260. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  91261. }
  91262. }
  91263. declare module BABYLON {
  91264. /** @hidden */
  91265. export var lavaPixelShader: {
  91266. name: string;
  91267. shader: string;
  91268. };
  91269. }
  91270. declare module BABYLON {
  91271. /** @hidden */
  91272. export var lavaVertexShader: {
  91273. name: string;
  91274. shader: string;
  91275. };
  91276. }
  91277. declare module BABYLON {
  91278. export class LavaMaterial extends BABYLON.PushMaterial {
  91279. private _diffuseTexture;
  91280. diffuseTexture: BABYLON.BaseTexture;
  91281. noiseTexture: BABYLON.BaseTexture;
  91282. fogColor: BABYLON.Color3;
  91283. speed: number;
  91284. movingSpeed: number;
  91285. lowFrequencySpeed: number;
  91286. fogDensity: number;
  91287. private _lastTime;
  91288. diffuseColor: BABYLON.Color3;
  91289. private _disableLighting;
  91290. disableLighting: boolean;
  91291. private _unlit;
  91292. unlit: boolean;
  91293. private _maxSimultaneousLights;
  91294. maxSimultaneousLights: number;
  91295. private _scaledDiffuse;
  91296. constructor(name: string, scene: BABYLON.Scene);
  91297. needAlphaBlending(): boolean;
  91298. needAlphaTesting(): boolean;
  91299. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91300. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91301. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91302. getAnimatables(): BABYLON.IAnimatable[];
  91303. getActiveTextures(): BABYLON.BaseTexture[];
  91304. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91305. dispose(forceDisposeEffect?: boolean): void;
  91306. clone(name: string): LavaMaterial;
  91307. serialize(): any;
  91308. getClassName(): string;
  91309. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  91310. }
  91311. }
  91312. declare module BABYLON {
  91313. /** @hidden */
  91314. export var mixPixelShader: {
  91315. name: string;
  91316. shader: string;
  91317. };
  91318. }
  91319. declare module BABYLON {
  91320. /** @hidden */
  91321. export var mixVertexShader: {
  91322. name: string;
  91323. shader: string;
  91324. };
  91325. }
  91326. declare module BABYLON {
  91327. export class MixMaterial extends BABYLON.PushMaterial {
  91328. /**
  91329. * Mix textures
  91330. */
  91331. private _mixTexture1;
  91332. mixTexture1: BABYLON.BaseTexture;
  91333. private _mixTexture2;
  91334. mixTexture2: BABYLON.BaseTexture;
  91335. /**
  91336. * Diffuse textures
  91337. */
  91338. private _diffuseTexture1;
  91339. diffuseTexture1: BABYLON.Texture;
  91340. private _diffuseTexture2;
  91341. diffuseTexture2: BABYLON.Texture;
  91342. private _diffuseTexture3;
  91343. diffuseTexture3: BABYLON.Texture;
  91344. private _diffuseTexture4;
  91345. diffuseTexture4: BABYLON.Texture;
  91346. private _diffuseTexture5;
  91347. diffuseTexture5: BABYLON.Texture;
  91348. private _diffuseTexture6;
  91349. diffuseTexture6: BABYLON.Texture;
  91350. private _diffuseTexture7;
  91351. diffuseTexture7: BABYLON.Texture;
  91352. private _diffuseTexture8;
  91353. diffuseTexture8: BABYLON.Texture;
  91354. /**
  91355. * Uniforms
  91356. */
  91357. diffuseColor: BABYLON.Color3;
  91358. specularColor: BABYLON.Color3;
  91359. specularPower: number;
  91360. private _disableLighting;
  91361. disableLighting: boolean;
  91362. private _maxSimultaneousLights;
  91363. maxSimultaneousLights: number;
  91364. constructor(name: string, scene: BABYLON.Scene);
  91365. needAlphaBlending(): boolean;
  91366. needAlphaTesting(): boolean;
  91367. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91368. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91369. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91370. getAnimatables(): BABYLON.IAnimatable[];
  91371. getActiveTextures(): BABYLON.BaseTexture[];
  91372. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91373. dispose(forceDisposeEffect?: boolean): void;
  91374. clone(name: string): MixMaterial;
  91375. serialize(): any;
  91376. getClassName(): string;
  91377. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  91378. }
  91379. }
  91380. declare module BABYLON {
  91381. /** @hidden */
  91382. export var normalPixelShader: {
  91383. name: string;
  91384. shader: string;
  91385. };
  91386. }
  91387. declare module BABYLON {
  91388. /** @hidden */
  91389. export var normalVertexShader: {
  91390. name: string;
  91391. shader: string;
  91392. };
  91393. }
  91394. declare module BABYLON {
  91395. export class NormalMaterial extends BABYLON.PushMaterial {
  91396. private _diffuseTexture;
  91397. diffuseTexture: BABYLON.BaseTexture;
  91398. diffuseColor: BABYLON.Color3;
  91399. private _disableLighting;
  91400. disableLighting: boolean;
  91401. private _maxSimultaneousLights;
  91402. maxSimultaneousLights: number;
  91403. constructor(name: string, scene: BABYLON.Scene);
  91404. needAlphaBlending(): boolean;
  91405. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  91406. needAlphaTesting(): boolean;
  91407. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91408. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91409. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91410. getAnimatables(): BABYLON.IAnimatable[];
  91411. getActiveTextures(): BABYLON.BaseTexture[];
  91412. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91413. dispose(forceDisposeEffect?: boolean): void;
  91414. clone(name: string): NormalMaterial;
  91415. serialize(): any;
  91416. getClassName(): string;
  91417. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  91418. }
  91419. }
  91420. declare module BABYLON {
  91421. /** @hidden */
  91422. export var shadowOnlyPixelShader: {
  91423. name: string;
  91424. shader: string;
  91425. };
  91426. }
  91427. declare module BABYLON {
  91428. /** @hidden */
  91429. export var shadowOnlyVertexShader: {
  91430. name: string;
  91431. shader: string;
  91432. };
  91433. }
  91434. declare module BABYLON {
  91435. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  91436. private _activeLight;
  91437. private _needAlphaBlending;
  91438. constructor(name: string, scene: BABYLON.Scene);
  91439. shadowColor: BABYLON.Color3;
  91440. needAlphaBlending(): boolean;
  91441. needAlphaTesting(): boolean;
  91442. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91443. get activeLight(): BABYLON.IShadowLight;
  91444. set activeLight(light: BABYLON.IShadowLight);
  91445. private _getFirstShadowLightForMesh;
  91446. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91447. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91448. clone(name: string): ShadowOnlyMaterial;
  91449. serialize(): any;
  91450. getClassName(): string;
  91451. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  91452. }
  91453. }
  91454. declare module BABYLON {
  91455. /** @hidden */
  91456. export var simplePixelShader: {
  91457. name: string;
  91458. shader: string;
  91459. };
  91460. }
  91461. declare module BABYLON {
  91462. /** @hidden */
  91463. export var simpleVertexShader: {
  91464. name: string;
  91465. shader: string;
  91466. };
  91467. }
  91468. declare module BABYLON {
  91469. export class SimpleMaterial extends BABYLON.PushMaterial {
  91470. private _diffuseTexture;
  91471. diffuseTexture: BABYLON.BaseTexture;
  91472. diffuseColor: BABYLON.Color3;
  91473. private _disableLighting;
  91474. disableLighting: boolean;
  91475. private _maxSimultaneousLights;
  91476. maxSimultaneousLights: number;
  91477. constructor(name: string, scene: BABYLON.Scene);
  91478. needAlphaBlending(): boolean;
  91479. needAlphaTesting(): boolean;
  91480. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91481. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91482. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91483. getAnimatables(): BABYLON.IAnimatable[];
  91484. getActiveTextures(): BABYLON.BaseTexture[];
  91485. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91486. dispose(forceDisposeEffect?: boolean): void;
  91487. clone(name: string): SimpleMaterial;
  91488. serialize(): any;
  91489. getClassName(): string;
  91490. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  91491. }
  91492. }
  91493. declare module BABYLON {
  91494. /** @hidden */
  91495. export var skyPixelShader: {
  91496. name: string;
  91497. shader: string;
  91498. };
  91499. }
  91500. declare module BABYLON {
  91501. /** @hidden */
  91502. export var skyVertexShader: {
  91503. name: string;
  91504. shader: string;
  91505. };
  91506. }
  91507. declare module BABYLON {
  91508. /**
  91509. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  91510. * @see https://doc.babylonjs.com/extensions/sky
  91511. */
  91512. export class SkyMaterial extends BABYLON.PushMaterial {
  91513. /**
  91514. * Defines the overall luminance of sky in interval ]0, 1[.
  91515. */
  91516. luminance: number;
  91517. /**
  91518. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  91519. */
  91520. turbidity: number;
  91521. /**
  91522. * Defines the sky appearance (light intensity).
  91523. */
  91524. rayleigh: number;
  91525. /**
  91526. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  91527. */
  91528. mieCoefficient: number;
  91529. /**
  91530. * Defines the amount of haze particles following the Mie scattering theory.
  91531. */
  91532. mieDirectionalG: number;
  91533. /**
  91534. * Defines the distance of the sun according to the active scene camera.
  91535. */
  91536. distance: number;
  91537. /**
  91538. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  91539. * "inclined".
  91540. */
  91541. inclination: number;
  91542. /**
  91543. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  91544. * an object direction and a reference direction.
  91545. */
  91546. azimuth: number;
  91547. /**
  91548. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  91549. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  91550. */
  91551. sunPosition: BABYLON.Vector3;
  91552. /**
  91553. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  91554. * .sunPosition property.
  91555. */
  91556. useSunPosition: boolean;
  91557. /**
  91558. * Defines an offset vector used to get a horizon offset.
  91559. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  91560. */
  91561. cameraOffset: BABYLON.Vector3;
  91562. private _cameraPosition;
  91563. /**
  91564. * Instantiates a new sky material.
  91565. * This material allows to create dynamic and texture free
  91566. * effects for skyboxes by taking care of the atmosphere state.
  91567. * @see https://doc.babylonjs.com/extensions/sky
  91568. * @param name Define the name of the material in the scene
  91569. * @param scene Define the scene the material belong to
  91570. */
  91571. constructor(name: string, scene: BABYLON.Scene);
  91572. /**
  91573. * Specifies if the material will require alpha blending
  91574. * @returns a boolean specifying if alpha blending is needed
  91575. */
  91576. needAlphaBlending(): boolean;
  91577. /**
  91578. * Specifies if this material should be rendered in alpha test mode
  91579. * @returns false as the sky material doesn't need alpha testing.
  91580. */
  91581. needAlphaTesting(): boolean;
  91582. /**
  91583. * Get the texture used for alpha test purpose.
  91584. * @returns null as the sky material has no texture.
  91585. */
  91586. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91587. /**
  91588. * Get if the submesh is ready to be used and all its information available.
  91589. * Child classes can use it to update shaders
  91590. * @param mesh defines the mesh to check
  91591. * @param subMesh defines which submesh to check
  91592. * @param useInstances specifies that instances should be used
  91593. * @returns a boolean indicating that the submesh is ready or not
  91594. */
  91595. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91596. /**
  91597. * Binds the submesh to this material by preparing the effect and shader to draw
  91598. * @param world defines the world transformation matrix
  91599. * @param mesh defines the mesh containing the submesh
  91600. * @param subMesh defines the submesh to bind the material to
  91601. */
  91602. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91603. /**
  91604. * Get the list of animatables in the material.
  91605. * @returns the list of animatables object used in the material
  91606. */
  91607. getAnimatables(): BABYLON.IAnimatable[];
  91608. /**
  91609. * Disposes the material
  91610. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91611. */
  91612. dispose(forceDisposeEffect?: boolean): void;
  91613. /**
  91614. * Makes a duplicate of the material, and gives it a new name
  91615. * @param name defines the new name for the duplicated material
  91616. * @returns the cloned material
  91617. */
  91618. clone(name: string): SkyMaterial;
  91619. /**
  91620. * Serializes this material in a JSON representation
  91621. * @returns the serialized material object
  91622. */
  91623. serialize(): any;
  91624. /**
  91625. * Gets the current class name of the material e.g. "SkyMaterial"
  91626. * Mainly use in serialization.
  91627. * @returns the class name
  91628. */
  91629. getClassName(): string;
  91630. /**
  91631. * Creates a sky material from parsed material data
  91632. * @param source defines the JSON representation of the material
  91633. * @param scene defines the hosting scene
  91634. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91635. * @returns a new sky material
  91636. */
  91637. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  91638. }
  91639. }
  91640. declare module BABYLON {
  91641. /** @hidden */
  91642. export var terrainPixelShader: {
  91643. name: string;
  91644. shader: string;
  91645. };
  91646. }
  91647. declare module BABYLON {
  91648. /** @hidden */
  91649. export var terrainVertexShader: {
  91650. name: string;
  91651. shader: string;
  91652. };
  91653. }
  91654. declare module BABYLON {
  91655. export class TerrainMaterial extends BABYLON.PushMaterial {
  91656. private _mixTexture;
  91657. mixTexture: BABYLON.BaseTexture;
  91658. private _diffuseTexture1;
  91659. diffuseTexture1: BABYLON.Texture;
  91660. private _diffuseTexture2;
  91661. diffuseTexture2: BABYLON.Texture;
  91662. private _diffuseTexture3;
  91663. diffuseTexture3: BABYLON.Texture;
  91664. private _bumpTexture1;
  91665. bumpTexture1: BABYLON.Texture;
  91666. private _bumpTexture2;
  91667. bumpTexture2: BABYLON.Texture;
  91668. private _bumpTexture3;
  91669. bumpTexture3: BABYLON.Texture;
  91670. diffuseColor: BABYLON.Color3;
  91671. specularColor: BABYLON.Color3;
  91672. specularPower: number;
  91673. private _disableLighting;
  91674. disableLighting: boolean;
  91675. private _maxSimultaneousLights;
  91676. maxSimultaneousLights: number;
  91677. constructor(name: string, scene: BABYLON.Scene);
  91678. needAlphaBlending(): boolean;
  91679. needAlphaTesting(): boolean;
  91680. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91681. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91682. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91683. getAnimatables(): BABYLON.IAnimatable[];
  91684. getActiveTextures(): BABYLON.BaseTexture[];
  91685. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91686. dispose(forceDisposeEffect?: boolean): void;
  91687. clone(name: string): TerrainMaterial;
  91688. serialize(): any;
  91689. getClassName(): string;
  91690. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  91691. }
  91692. }
  91693. declare module BABYLON {
  91694. /** @hidden */
  91695. export var triplanarPixelShader: {
  91696. name: string;
  91697. shader: string;
  91698. };
  91699. }
  91700. declare module BABYLON {
  91701. /** @hidden */
  91702. export var triplanarVertexShader: {
  91703. name: string;
  91704. shader: string;
  91705. };
  91706. }
  91707. declare module BABYLON {
  91708. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  91709. mixTexture: BABYLON.BaseTexture;
  91710. private _diffuseTextureX;
  91711. diffuseTextureX: BABYLON.BaseTexture;
  91712. private _diffuseTextureY;
  91713. diffuseTextureY: BABYLON.BaseTexture;
  91714. private _diffuseTextureZ;
  91715. diffuseTextureZ: BABYLON.BaseTexture;
  91716. private _normalTextureX;
  91717. normalTextureX: BABYLON.BaseTexture;
  91718. private _normalTextureY;
  91719. normalTextureY: BABYLON.BaseTexture;
  91720. private _normalTextureZ;
  91721. normalTextureZ: BABYLON.BaseTexture;
  91722. tileSize: number;
  91723. diffuseColor: BABYLON.Color3;
  91724. specularColor: BABYLON.Color3;
  91725. specularPower: number;
  91726. private _disableLighting;
  91727. disableLighting: boolean;
  91728. private _maxSimultaneousLights;
  91729. maxSimultaneousLights: number;
  91730. constructor(name: string, scene: BABYLON.Scene);
  91731. needAlphaBlending(): boolean;
  91732. needAlphaTesting(): boolean;
  91733. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91734. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91735. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91736. getAnimatables(): BABYLON.IAnimatable[];
  91737. getActiveTextures(): BABYLON.BaseTexture[];
  91738. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91739. dispose(forceDisposeEffect?: boolean): void;
  91740. clone(name: string): TriPlanarMaterial;
  91741. serialize(): any;
  91742. getClassName(): string;
  91743. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  91744. }
  91745. }
  91746. declare module BABYLON {
  91747. /** @hidden */
  91748. export var waterPixelShader: {
  91749. name: string;
  91750. shader: string;
  91751. };
  91752. }
  91753. declare module BABYLON {
  91754. /** @hidden */
  91755. export var waterVertexShader: {
  91756. name: string;
  91757. shader: string;
  91758. };
  91759. }
  91760. declare module BABYLON {
  91761. export class WaterMaterial extends BABYLON.PushMaterial {
  91762. renderTargetSize: BABYLON.Vector2;
  91763. private _bumpTexture;
  91764. bumpTexture: BABYLON.BaseTexture;
  91765. diffuseColor: BABYLON.Color3;
  91766. specularColor: BABYLON.Color3;
  91767. specularPower: number;
  91768. private _disableLighting;
  91769. disableLighting: boolean;
  91770. private _maxSimultaneousLights;
  91771. maxSimultaneousLights: number;
  91772. /**
  91773. * Defines the wind force.
  91774. */
  91775. windForce: number;
  91776. /**
  91777. * Defines the direction of the wind in the plane (X, Z).
  91778. */
  91779. windDirection: BABYLON.Vector2;
  91780. /**
  91781. * Defines the height of the waves.
  91782. */
  91783. waveHeight: number;
  91784. /**
  91785. * Defines the bump height related to the bump map.
  91786. */
  91787. bumpHeight: number;
  91788. /**
  91789. * Defines wether or not: to add a smaller moving bump to less steady waves.
  91790. */
  91791. private _bumpSuperimpose;
  91792. bumpSuperimpose: boolean;
  91793. /**
  91794. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  91795. */
  91796. private _fresnelSeparate;
  91797. fresnelSeparate: boolean;
  91798. /**
  91799. * Defines wether or not bump Wwves modify the reflection.
  91800. */
  91801. private _bumpAffectsReflection;
  91802. bumpAffectsReflection: boolean;
  91803. /**
  91804. * Defines the water color blended with the refraction (near).
  91805. */
  91806. waterColor: BABYLON.Color3;
  91807. /**
  91808. * Defines the blend factor related to the water color.
  91809. */
  91810. colorBlendFactor: number;
  91811. /**
  91812. * Defines the water color blended with the reflection (far).
  91813. */
  91814. waterColor2: BABYLON.Color3;
  91815. /**
  91816. * Defines the blend factor related to the water color (reflection, far).
  91817. */
  91818. colorBlendFactor2: number;
  91819. /**
  91820. * Defines the maximum length of a wave.
  91821. */
  91822. waveLength: number;
  91823. /**
  91824. * Defines the waves speed.
  91825. */
  91826. waveSpeed: number;
  91827. /**
  91828. * 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.
  91829. */
  91830. waveCount: number;
  91831. /**
  91832. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  91833. * will avoid calculating useless pixels in the pixel shader of the water material.
  91834. */
  91835. disableClipPlane: boolean;
  91836. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  91837. private _mesh;
  91838. private _refractionRTT;
  91839. private _reflectionRTT;
  91840. private _reflectionTransform;
  91841. private _lastTime;
  91842. private _lastDeltaTime;
  91843. private _useLogarithmicDepth;
  91844. private _waitingRenderList;
  91845. private _imageProcessingConfiguration;
  91846. private _imageProcessingObserver;
  91847. /**
  91848. * Gets a boolean indicating that current material needs to register RTT
  91849. */
  91850. get hasRenderTargetTextures(): boolean;
  91851. /**
  91852. * Constructor
  91853. */
  91854. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  91855. get useLogarithmicDepth(): boolean;
  91856. set useLogarithmicDepth(value: boolean);
  91857. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  91858. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  91859. addToRenderList(node: any): void;
  91860. enableRenderTargets(enable: boolean): void;
  91861. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  91862. get renderTargetsEnabled(): boolean;
  91863. needAlphaBlending(): boolean;
  91864. needAlphaTesting(): boolean;
  91865. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91866. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91867. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91868. private _createRenderTargets;
  91869. getAnimatables(): BABYLON.IAnimatable[];
  91870. getActiveTextures(): BABYLON.BaseTexture[];
  91871. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91872. dispose(forceDisposeEffect?: boolean): void;
  91873. clone(name: string): WaterMaterial;
  91874. serialize(): any;
  91875. getClassName(): string;
  91876. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  91877. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  91878. }
  91879. }
  91880. declare module BABYLON {
  91881. /** @hidden */
  91882. export var asciiartPixelShader: {
  91883. name: string;
  91884. shader: string;
  91885. };
  91886. }
  91887. declare module BABYLON {
  91888. /**
  91889. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  91890. *
  91891. * It basically takes care rendering the font front the given font size to a texture.
  91892. * This is used later on in the postprocess.
  91893. */
  91894. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  91895. private _font;
  91896. private _text;
  91897. private _charSize;
  91898. /**
  91899. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  91900. */
  91901. get charSize(): number;
  91902. /**
  91903. * Create a new instance of the Ascii Art FontTexture class
  91904. * @param name the name of the texture
  91905. * @param font the font to use, use the W3C CSS notation
  91906. * @param text the caracter set to use in the rendering.
  91907. * @param scene the scene that owns the texture
  91908. */
  91909. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  91910. /**
  91911. * Gets the max char width of a font.
  91912. * @param font the font to use, use the W3C CSS notation
  91913. * @return the max char width
  91914. */
  91915. private getFontWidth;
  91916. /**
  91917. * Gets the max char height of a font.
  91918. * @param font the font to use, use the W3C CSS notation
  91919. * @return the max char height
  91920. */
  91921. private getFontHeight;
  91922. /**
  91923. * Clones the current AsciiArtTexture.
  91924. * @return the clone of the texture.
  91925. */
  91926. clone(): AsciiArtFontTexture;
  91927. /**
  91928. * Parses a json object representing the texture and returns an instance of it.
  91929. * @param source the source JSON representation
  91930. * @param scene the scene to create the texture for
  91931. * @return the parsed texture
  91932. */
  91933. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  91934. }
  91935. /**
  91936. * Option available in the Ascii Art Post Process.
  91937. */
  91938. export interface IAsciiArtPostProcessOptions {
  91939. /**
  91940. * The font to use following the w3c font definition.
  91941. */
  91942. font?: string;
  91943. /**
  91944. * The character set to use in the postprocess.
  91945. */
  91946. characterSet?: string;
  91947. /**
  91948. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  91949. * This number is defined between 0 and 1;
  91950. */
  91951. mixToTile?: number;
  91952. /**
  91953. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  91954. * This number is defined between 0 and 1;
  91955. */
  91956. mixToNormal?: number;
  91957. }
  91958. /**
  91959. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  91960. *
  91961. * Simmply add it to your scene and let the nerd that lives in you have fun.
  91962. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  91963. */
  91964. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  91965. /**
  91966. * The font texture used to render the char in the post process.
  91967. */
  91968. private _asciiArtFontTexture;
  91969. /**
  91970. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  91971. * This number is defined between 0 and 1;
  91972. */
  91973. mixToTile: number;
  91974. /**
  91975. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  91976. * This number is defined between 0 and 1;
  91977. */
  91978. mixToNormal: number;
  91979. /**
  91980. * Instantiates a new Ascii Art Post Process.
  91981. * @param name the name to give to the postprocess
  91982. * @camera the camera to apply the post process to.
  91983. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  91984. */
  91985. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  91986. }
  91987. }
  91988. declare module BABYLON {
  91989. /** @hidden */
  91990. export var digitalrainPixelShader: {
  91991. name: string;
  91992. shader: string;
  91993. };
  91994. }
  91995. declare module BABYLON {
  91996. /**
  91997. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  91998. *
  91999. * It basically takes care rendering the font front the given font size to a texture.
  92000. * This is used later on in the postprocess.
  92001. */
  92002. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  92003. private _font;
  92004. private _text;
  92005. private _charSize;
  92006. /**
  92007. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92008. */
  92009. get charSize(): number;
  92010. /**
  92011. * Create a new instance of the Digital Rain FontTexture class
  92012. * @param name the name of the texture
  92013. * @param font the font to use, use the W3C CSS notation
  92014. * @param text the caracter set to use in the rendering.
  92015. * @param scene the scene that owns the texture
  92016. */
  92017. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92018. /**
  92019. * Gets the max char width of a font.
  92020. * @param font the font to use, use the W3C CSS notation
  92021. * @return the max char width
  92022. */
  92023. private getFontWidth;
  92024. /**
  92025. * Gets the max char height of a font.
  92026. * @param font the font to use, use the W3C CSS notation
  92027. * @return the max char height
  92028. */
  92029. private getFontHeight;
  92030. /**
  92031. * Clones the current DigitalRainFontTexture.
  92032. * @return the clone of the texture.
  92033. */
  92034. clone(): DigitalRainFontTexture;
  92035. /**
  92036. * Parses a json object representing the texture and returns an instance of it.
  92037. * @param source the source JSON representation
  92038. * @param scene the scene to create the texture for
  92039. * @return the parsed texture
  92040. */
  92041. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  92042. }
  92043. /**
  92044. * Option available in the Digital Rain Post Process.
  92045. */
  92046. export interface IDigitalRainPostProcessOptions {
  92047. /**
  92048. * The font to use following the w3c font definition.
  92049. */
  92050. font?: string;
  92051. /**
  92052. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92053. * This number is defined between 0 and 1;
  92054. */
  92055. mixToTile?: number;
  92056. /**
  92057. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92058. * This number is defined between 0 and 1;
  92059. */
  92060. mixToNormal?: number;
  92061. }
  92062. /**
  92063. * DigitalRainPostProcess helps rendering everithing in digital rain.
  92064. *
  92065. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92066. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  92067. */
  92068. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  92069. /**
  92070. * The font texture used to render the char in the post process.
  92071. */
  92072. private _digitalRainFontTexture;
  92073. /**
  92074. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92075. * This number is defined between 0 and 1;
  92076. */
  92077. mixToTile: number;
  92078. /**
  92079. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92080. * This number is defined between 0 and 1;
  92081. */
  92082. mixToNormal: number;
  92083. /**
  92084. * Instantiates a new Digital Rain Post Process.
  92085. * @param name the name to give to the postprocess
  92086. * @camera the camera to apply the post process to.
  92087. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  92088. */
  92089. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  92090. }
  92091. }
  92092. declare module BABYLON {
  92093. /** @hidden */
  92094. export var brickProceduralTexturePixelShader: {
  92095. name: string;
  92096. shader: string;
  92097. };
  92098. }
  92099. declare module BABYLON {
  92100. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  92101. private _numberOfBricksHeight;
  92102. private _numberOfBricksWidth;
  92103. private _jointColor;
  92104. private _brickColor;
  92105. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92106. updateShaderUniforms(): void;
  92107. get numberOfBricksHeight(): number;
  92108. set numberOfBricksHeight(value: number);
  92109. get numberOfBricksWidth(): number;
  92110. set numberOfBricksWidth(value: number);
  92111. get jointColor(): BABYLON.Color3;
  92112. set jointColor(value: BABYLON.Color3);
  92113. get brickColor(): BABYLON.Color3;
  92114. set brickColor(value: BABYLON.Color3);
  92115. /**
  92116. * Serializes this brick procedural texture
  92117. * @returns a serialized brick procedural texture object
  92118. */
  92119. serialize(): any;
  92120. /**
  92121. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  92122. * @param parsedTexture defines parsed texture data
  92123. * @param scene defines the current scene
  92124. * @param rootUrl defines the root URL containing brick procedural texture information
  92125. * @returns a parsed Brick Procedural BABYLON.Texture
  92126. */
  92127. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  92128. }
  92129. }
  92130. declare module BABYLON {
  92131. /** @hidden */
  92132. export var cloudProceduralTexturePixelShader: {
  92133. name: string;
  92134. shader: string;
  92135. };
  92136. }
  92137. declare module BABYLON {
  92138. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  92139. private _skyColor;
  92140. private _cloudColor;
  92141. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92142. updateShaderUniforms(): void;
  92143. get skyColor(): BABYLON.Color4;
  92144. set skyColor(value: BABYLON.Color4);
  92145. get cloudColor(): BABYLON.Color4;
  92146. set cloudColor(value: BABYLON.Color4);
  92147. /**
  92148. * Serializes this cloud procedural texture
  92149. * @returns a serialized cloud procedural texture object
  92150. */
  92151. serialize(): any;
  92152. /**
  92153. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  92154. * @param parsedTexture defines parsed texture data
  92155. * @param scene defines the current scene
  92156. * @param rootUrl defines the root URL containing cloud procedural texture information
  92157. * @returns a parsed Cloud Procedural BABYLON.Texture
  92158. */
  92159. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  92160. }
  92161. }
  92162. declare module BABYLON {
  92163. /** @hidden */
  92164. export var fireProceduralTexturePixelShader: {
  92165. name: string;
  92166. shader: string;
  92167. };
  92168. }
  92169. declare module BABYLON {
  92170. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  92171. private _time;
  92172. private _speed;
  92173. private _autoGenerateTime;
  92174. private _fireColors;
  92175. private _alphaThreshold;
  92176. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92177. updateShaderUniforms(): void;
  92178. render(useCameraPostProcess?: boolean): void;
  92179. static get PurpleFireColors(): BABYLON.Color3[];
  92180. static get GreenFireColors(): BABYLON.Color3[];
  92181. static get RedFireColors(): BABYLON.Color3[];
  92182. static get BlueFireColors(): BABYLON.Color3[];
  92183. get autoGenerateTime(): boolean;
  92184. set autoGenerateTime(value: boolean);
  92185. get fireColors(): BABYLON.Color3[];
  92186. set fireColors(value: BABYLON.Color3[]);
  92187. get time(): number;
  92188. set time(value: number);
  92189. get speed(): BABYLON.Vector2;
  92190. set speed(value: BABYLON.Vector2);
  92191. get alphaThreshold(): number;
  92192. set alphaThreshold(value: number);
  92193. /**
  92194. * Serializes this fire procedural texture
  92195. * @returns a serialized fire procedural texture object
  92196. */
  92197. serialize(): any;
  92198. /**
  92199. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  92200. * @param parsedTexture defines parsed texture data
  92201. * @param scene defines the current scene
  92202. * @param rootUrl defines the root URL containing fire procedural texture information
  92203. * @returns a parsed Fire Procedural BABYLON.Texture
  92204. */
  92205. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  92206. }
  92207. }
  92208. declare module BABYLON {
  92209. /** @hidden */
  92210. export var grassProceduralTexturePixelShader: {
  92211. name: string;
  92212. shader: string;
  92213. };
  92214. }
  92215. declare module BABYLON {
  92216. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  92217. private _grassColors;
  92218. private _groundColor;
  92219. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92220. updateShaderUniforms(): void;
  92221. get grassColors(): BABYLON.Color3[];
  92222. set grassColors(value: BABYLON.Color3[]);
  92223. get groundColor(): BABYLON.Color3;
  92224. set groundColor(value: BABYLON.Color3);
  92225. /**
  92226. * Serializes this grass procedural texture
  92227. * @returns a serialized grass procedural texture object
  92228. */
  92229. serialize(): any;
  92230. /**
  92231. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  92232. * @param parsedTexture defines parsed texture data
  92233. * @param scene defines the current scene
  92234. * @param rootUrl defines the root URL containing grass procedural texture information
  92235. * @returns a parsed Grass Procedural BABYLON.Texture
  92236. */
  92237. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  92238. }
  92239. }
  92240. declare module BABYLON {
  92241. /** @hidden */
  92242. export var marbleProceduralTexturePixelShader: {
  92243. name: string;
  92244. shader: string;
  92245. };
  92246. }
  92247. declare module BABYLON {
  92248. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  92249. private _numberOfTilesHeight;
  92250. private _numberOfTilesWidth;
  92251. private _amplitude;
  92252. private _jointColor;
  92253. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92254. updateShaderUniforms(): void;
  92255. get numberOfTilesHeight(): number;
  92256. set numberOfTilesHeight(value: number);
  92257. get amplitude(): number;
  92258. set amplitude(value: number);
  92259. get numberOfTilesWidth(): number;
  92260. set numberOfTilesWidth(value: number);
  92261. get jointColor(): BABYLON.Color3;
  92262. set jointColor(value: BABYLON.Color3);
  92263. /**
  92264. * Serializes this marble procedural texture
  92265. * @returns a serialized marble procedural texture object
  92266. */
  92267. serialize(): any;
  92268. /**
  92269. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  92270. * @param parsedTexture defines parsed texture data
  92271. * @param scene defines the current scene
  92272. * @param rootUrl defines the root URL containing marble procedural texture information
  92273. * @returns a parsed Marble Procedural BABYLON.Texture
  92274. */
  92275. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  92276. }
  92277. }
  92278. declare module BABYLON {
  92279. /** @hidden */
  92280. export var normalMapProceduralTexturePixelShader: {
  92281. name: string;
  92282. shader: string;
  92283. };
  92284. }
  92285. declare module BABYLON {
  92286. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  92287. private _baseTexture;
  92288. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92289. updateShaderUniforms(): void;
  92290. render(useCameraPostProcess?: boolean): void;
  92291. resize(size: any, generateMipMaps: any): void;
  92292. isReady(): boolean;
  92293. get baseTexture(): BABYLON.Texture;
  92294. set baseTexture(texture: BABYLON.Texture);
  92295. /**
  92296. * Serializes this normal map procedural texture
  92297. * @returns a serialized normal map procedural texture object
  92298. */
  92299. serialize(): any;
  92300. /**
  92301. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  92302. * @param parsedTexture defines parsed texture data
  92303. * @param scene defines the current scene
  92304. * @param rootUrl defines the root URL containing normal map procedural texture information
  92305. * @returns a parsed Normal Map Procedural BABYLON.Texture
  92306. */
  92307. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  92308. }
  92309. }
  92310. declare module BABYLON {
  92311. /** @hidden */
  92312. export var perlinNoiseProceduralTexturePixelShader: {
  92313. name: string;
  92314. shader: string;
  92315. };
  92316. }
  92317. declare module BABYLON {
  92318. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  92319. time: number;
  92320. timeScale: number;
  92321. translationSpeed: number;
  92322. private _currentTranslation;
  92323. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92324. updateShaderUniforms(): void;
  92325. render(useCameraPostProcess?: boolean): void;
  92326. resize(size: any, generateMipMaps: any): void;
  92327. /**
  92328. * Serializes this perlin noise procedural texture
  92329. * @returns a serialized perlin noise procedural texture object
  92330. */
  92331. serialize(): any;
  92332. /**
  92333. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  92334. * @param parsedTexture defines parsed texture data
  92335. * @param scene defines the current scene
  92336. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  92337. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  92338. */
  92339. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  92340. }
  92341. }
  92342. declare module BABYLON {
  92343. /** @hidden */
  92344. export var roadProceduralTexturePixelShader: {
  92345. name: string;
  92346. shader: string;
  92347. };
  92348. }
  92349. declare module BABYLON {
  92350. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  92351. private _roadColor;
  92352. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92353. updateShaderUniforms(): void;
  92354. get roadColor(): BABYLON.Color3;
  92355. set roadColor(value: BABYLON.Color3);
  92356. /**
  92357. * Serializes this road procedural texture
  92358. * @returns a serialized road procedural texture object
  92359. */
  92360. serialize(): any;
  92361. /**
  92362. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  92363. * @param parsedTexture defines parsed texture data
  92364. * @param scene defines the current scene
  92365. * @param rootUrl defines the root URL containing road procedural texture information
  92366. * @returns a parsed Road Procedural BABYLON.Texture
  92367. */
  92368. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  92369. }
  92370. }
  92371. declare module BABYLON {
  92372. /** @hidden */
  92373. export var starfieldProceduralTexturePixelShader: {
  92374. name: string;
  92375. shader: string;
  92376. };
  92377. }
  92378. declare module BABYLON {
  92379. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  92380. private _time;
  92381. private _alpha;
  92382. private _beta;
  92383. private _zoom;
  92384. private _formuparam;
  92385. private _stepsize;
  92386. private _tile;
  92387. private _brightness;
  92388. private _darkmatter;
  92389. private _distfading;
  92390. private _saturation;
  92391. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92392. updateShaderUniforms(): void;
  92393. get time(): number;
  92394. set time(value: number);
  92395. get alpha(): number;
  92396. set alpha(value: number);
  92397. get beta(): number;
  92398. set beta(value: number);
  92399. get formuparam(): number;
  92400. set formuparam(value: number);
  92401. get stepsize(): number;
  92402. set stepsize(value: number);
  92403. get zoom(): number;
  92404. set zoom(value: number);
  92405. get tile(): number;
  92406. set tile(value: number);
  92407. get brightness(): number;
  92408. set brightness(value: number);
  92409. get darkmatter(): number;
  92410. set darkmatter(value: number);
  92411. get distfading(): number;
  92412. set distfading(value: number);
  92413. get saturation(): number;
  92414. set saturation(value: number);
  92415. /**
  92416. * Serializes this starfield procedural texture
  92417. * @returns a serialized starfield procedural texture object
  92418. */
  92419. serialize(): any;
  92420. /**
  92421. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  92422. * @param parsedTexture defines parsed texture data
  92423. * @param scene defines the current scene
  92424. * @param rootUrl defines the root URL containing startfield procedural texture information
  92425. * @returns a parsed Starfield Procedural BABYLON.Texture
  92426. */
  92427. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  92428. }
  92429. }
  92430. declare module BABYLON {
  92431. /** @hidden */
  92432. export var woodProceduralTexturePixelShader: {
  92433. name: string;
  92434. shader: string;
  92435. };
  92436. }
  92437. declare module BABYLON {
  92438. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  92439. private _ampScale;
  92440. private _woodColor;
  92441. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92442. updateShaderUniforms(): void;
  92443. get ampScale(): number;
  92444. set ampScale(value: number);
  92445. get woodColor(): BABYLON.Color3;
  92446. set woodColor(value: BABYLON.Color3);
  92447. /**
  92448. * Serializes this wood procedural texture
  92449. * @returns a serialized wood procedural texture object
  92450. */
  92451. serialize(): any;
  92452. /**
  92453. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  92454. * @param parsedTexture defines parsed texture data
  92455. * @param scene defines the current scene
  92456. * @param rootUrl defines the root URL containing wood procedural texture information
  92457. * @returns a parsed Wood Procedural BABYLON.Texture
  92458. */
  92459. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  92460. }
  92461. }